Browse Source

Kernel: rename() should fail with EXDEV for cross-device requests

POSIX does not support rename() from one file system to another.
Andreas Kling 5 years ago
parent
commit
3f74e66e82
1 changed files with 3 additions and 0 deletions
  1. 3 0
      Kernel/FileSystem/VirtualFileSystem.cpp

+ 3 - 0
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& old_parent_inode = old_parent_custody->inode();
     auto& new_parent_inode = new_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()))
     if (!new_parent_inode.metadata().may_write(current->process()))
         return KResult(-EACCES);
         return KResult(-EACCES);