Skip to content

Commit

Permalink
btrfs: return EXDEV when linking from different subvolumes
Browse files Browse the repository at this point in the history
btrfs_link returns EPERM if a cross-subvolume link is attempted.

However, in this case I believe EXDEV to be the more appropriate value.
>From the link(2) man page:

EXDEV  oldpath and newpath are not on the same mounted file system.  (Linux
       permits a file system to be mounted at multiple points, but link()
       does not work across different mount points, even if the same file
       system is mounted on both.)

This matters because an application may have different behaviors based on
return codes.

Signed-off-by: Mark Fasheh <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
Mark Fasheh authored and root committed Mar 28, 2011
1 parent 75e7cb7 commit 3ab3564
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4817,7 +4817,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,

/* do not allow sys_link's with other subvols of the same device */
if (root->objectid != BTRFS_I(inode)->root->objectid)
return -EPERM;
return -EXDEV;

btrfs_inc_nlink(inode);
inode->i_ctime = CURRENT_TIME;
Expand Down

0 comments on commit 3ab3564

Please sign in to comment.