mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
vfs: hoist the btrfs deduplication ioctl to the vfs
Hoist the btrfs EXTENT_SAME ioctl up to the VFS and make the name more systematic (FIDEDUPERANGE). Signed-off-by: Darrick J. Wong <[email protected]> Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
d79bdd52d8
commit
54dbc15172
5 changed files with 173 additions and 0 deletions
38
fs/ioctl.c
38
fs/ioctl.c
|
|
@ -568,6 +568,41 @@ static int ioctl_fsthaw(struct file *filp)
|
|||
return thaw_super(sb);
|
||||
}
|
||||
|
||||
static long ioctl_file_dedupe_range(struct file *file, void __user *arg)
|
||||
{
|
||||
struct file_dedupe_range __user *argp = arg;
|
||||
struct file_dedupe_range *same = NULL;
|
||||
int ret;
|
||||
unsigned long size;
|
||||
u16 count;
|
||||
|
||||
if (get_user(count, &argp->dest_count)) {
|
||||
ret = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
size = offsetof(struct file_dedupe_range __user, info[count]);
|
||||
|
||||
same = memdup_user(argp, size);
|
||||
if (IS_ERR(same)) {
|
||||
ret = PTR_ERR(same);
|
||||
same = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = vfs_dedupe_file_range(file, same);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = copy_to_user(argp, same, size);
|
||||
if (ret)
|
||||
ret = -EFAULT;
|
||||
|
||||
out:
|
||||
kfree(same);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* When you add any new common ioctls to the switches above and below
|
||||
* please update compat_sys_ioctl() too.
|
||||
|
|
@ -629,6 +664,9 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
|
|||
case FICLONERANGE:
|
||||
return ioctl_file_clone_range(filp, argp);
|
||||
|
||||
case FIDEDUPERANGE:
|
||||
return ioctl_file_dedupe_range(filp, argp);
|
||||
|
||||
default:
|
||||
if (S_ISREG(inode->i_mode))
|
||||
error = file_ioctl(filp, cmd, arg);
|
||||
|
|
|
|||
Loading…
Reference in a new issue