aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorjeff.liu <jeff.liu@oracle.com>2013-01-04 21:48:01 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-02-20 12:59:58 -0500
commit867ab667e74377160c4a683375ee5b8bf8801724 (patch)
tree9473c309f58be6efd176f09417358ea42a4f8db4 /fs/btrfs/ioctl.c
parent569e0f358c0c37f6733702d4a5d2c412860f7169 (diff)
Btrfs: Add a new ioctl to get the label of a mounted file system
Add a new ioctl(2) BTRFS_IOC_GET_FSLABLE, so that we can get the label upon a mounted filesystem. Signed-off-by: Jie Liu <jeff.liu@oracle.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> Cc: Miao Xie <miaox@cn.fujitsu.com> Cc: Goffredo Baroncelli <kreijack@inwind.it> Cc: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index d02ec577f70f..fcc15a6804a9 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3917,6 +3917,25 @@ out:
3917 return ret; 3917 return ret;
3918} 3918}
3919 3919
3920static int btrfs_ioctl_get_fslabel(struct file *file, void __user *arg)
3921{
3922 struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root;
3923 const char *label = root->fs_info->super_copy->label;
3924 size_t len = strnlen(label, BTRFS_LABEL_SIZE);
3925 int ret;
3926
3927 if (len == BTRFS_LABEL_SIZE) {
3928 pr_warn("btrfs: label is too long, return the first %zu bytes\n",
3929 --len);
3930 }
3931
3932 mutex_lock(&root->fs_info->volume_mutex);
3933 ret = copy_to_user(arg, label, len);
3934 mutex_unlock(&root->fs_info->volume_mutex);
3935
3936 return ret ? -EFAULT : 0;
3937}
3938
3920long btrfs_ioctl(struct file *file, unsigned int 3939long btrfs_ioctl(struct file *file, unsigned int
3921 cmd, unsigned long arg) 3940 cmd, unsigned long arg)
3922{ 3941{
@@ -4017,6 +4036,8 @@ long btrfs_ioctl(struct file *file, unsigned int
4017 return btrfs_ioctl_qgroup_limit(file, argp); 4036 return btrfs_ioctl_qgroup_limit(file, argp);
4018 case BTRFS_IOC_DEV_REPLACE: 4037 case BTRFS_IOC_DEV_REPLACE:
4019 return btrfs_ioctl_dev_replace(root, argp); 4038 return btrfs_ioctl_dev_replace(root, argp);
4039 case BTRFS_IOC_GET_FSLABEL:
4040 return btrfs_ioctl_get_fslabel(file, argp);
4020 } 4041 }
4021 4042
4022 return -ENOTTY; 4043 return -ENOTTY;