Skip to content

Commit 21dc07a

Browse files
ntfs3: add FS_IOC_SETFSLABEL ioctl
Add support for the FS_IOC_SETFSLABEL ioctl. Signed-off-by: Ethan Ferguson <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
1 parent e4dff97 commit 21dc07a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

fs/ntfs3/file.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ static int ntfs_ioctl_get_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf)
5757
return 0;
5858
}
5959

60+
static int ntfs_ioctl_set_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf)
61+
{
62+
u8 user[FSLABEL_MAX] = {0};
63+
int len;
64+
65+
if (!capable(CAP_SYS_ADMIN))
66+
return -EPERM;
67+
68+
if (copy_from_user(user, buf, FSLABEL_MAX))
69+
return -EFAULT;
70+
71+
len = strnlen(user, FSLABEL_MAX);
72+
73+
return ntfs_set_label(sbi, user, len);
74+
}
75+
6076
/*
6177
* ntfs_ioctl - file_operations::unlocked_ioctl
6278
*/
@@ -74,6 +90,8 @@ long ntfs_ioctl(struct file *filp, u32 cmd, unsigned long arg)
7490
return ntfs_ioctl_fitrim(sbi, arg);
7591
case FS_IOC_GETFSLABEL:
7692
return ntfs_ioctl_get_volume_label(sbi, (u8 __user *)arg);
93+
case FS_IOC_SETFSLABEL:
94+
return ntfs_ioctl_set_volume_label(sbi, (u8 __user *)arg);
7795
}
7896
return -ENOTTY; /* Inappropriate ioctl for device. */
7997
}

0 commit comments

Comments
 (0)