summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2020-01-03 04:10:05 +0100
committerAndreas Kling <awesomekling@gmail.com>2020-01-03 04:10:05 +0100
commit3f74e66e823f7c07f6817bb8c2288f0e4230be85 (patch)
tree8ce1542bc3881c03261d99b6c69b1e051d1abf0c
parentbbedad119784abb9f637dbed4d3956e0f97aeba1 (diff)
downloadserenity-3f74e66e823f7c07f6817bb8c2288f0e4230be85.zip
Kernel: rename() should fail with EXDEV for cross-device requests
POSIX does not support rename() from one file system to another.
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp
index 5539032e69..377bb14e93 100644
--- a/Kernel/FileSystem/VirtualFileSystem.cpp
+++ b/Kernel/FileSystem/VirtualFileSystem.cpp
@@ -396,6 +396,9 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
auto& old_parent_inode = old_parent_custody->inode();
auto& new_parent_inode = new_parent_custody->inode();
+ if (&old_parent_inode.fs() != &new_parent_inode.fs())
+ return KResult(-EXDEV);
+
if (!new_parent_inode.metadata().may_write(current->process()))
return KResult(-EACCES);