linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ntfs3: Add support for FS_IOC_{GET,SET}FSLABEL ioctl
@ 2025-08-28 20:37 Ethan Ferguson
  2025-08-28 20:37 ` [PATCH 1/3] ntfs3: transition magic number to shared constant Ethan Ferguson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ethan Ferguson @ 2025-08-28 20:37 UTC (permalink / raw)
  To: almaz.alexandrovich; +Cc: ntfs3, linux-fsdevel, linux-kernel, Ethan Ferguson

Hi all,

Given the FS_IOC_{GET,SET}FSLABEL ioctls are now the de-facto standard
for reading and writing the FS label, implement these ioctls for the
ntfs3 driver.

Use the common FSLABEL_MAX constant instead of a magic number.

Thanks,
Ethan Ferguson

Ethan Ferguson (3):
  ntfs3: transition magic number to shared constant
  ntfs3: add FS_IOC_GETFSLABEL ioctl
  ntfs3: add FS_IOC_SETFSLABEL ioctl

 fs/ntfs3/file.c    | 28 ++++++++++++++++++++++++++++
 fs/ntfs3/ntfs_fs.h |  2 +-
 2 files changed, 29 insertions(+), 1 deletion(-)


base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] ntfs3: transition magic number to shared constant
  2025-08-28 20:37 [PATCH 0/3] ntfs3: Add support for FS_IOC_{GET,SET}FSLABEL ioctl Ethan Ferguson
@ 2025-08-28 20:37 ` Ethan Ferguson
  2025-08-28 20:37 ` [PATCH 2/3] ntfs3: add FS_IOC_GETFSLABEL ioctl Ethan Ferguson
  2025-08-28 20:37 ` [PATCH 3/3] ntfs3: add FS_IOC_SETFSLABEL ioctl Ethan Ferguson
  2 siblings, 0 replies; 4+ messages in thread
From: Ethan Ferguson @ 2025-08-28 20:37 UTC (permalink / raw)
  To: almaz.alexandrovich; +Cc: ntfs3, linux-fsdevel, linux-kernel, Ethan Ferguson

Use the common FSLABEL_MAX constant instead of a hardcoded magic
constant of 256.

Signed-off-by: Ethan Ferguson <ethan.ferguson@zetier.com>

---
 fs/ntfs3/ntfs_fs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 1296e6fcc779..630128716ea7 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -280,7 +280,7 @@ struct ntfs_sb_info {
 		__le16 flags; // Cached current VOLUME_INFO::flags, VOLUME_FLAG_DIRTY.
 		u8 major_ver;
 		u8 minor_ver;
-		char label[256];
+		char label[FSLABEL_MAX];
 		bool real_dirty; // Real fs state.
 	} volume;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] ntfs3: add FS_IOC_GETFSLABEL ioctl
  2025-08-28 20:37 [PATCH 0/3] ntfs3: Add support for FS_IOC_{GET,SET}FSLABEL ioctl Ethan Ferguson
  2025-08-28 20:37 ` [PATCH 1/3] ntfs3: transition magic number to shared constant Ethan Ferguson
@ 2025-08-28 20:37 ` Ethan Ferguson
  2025-08-28 20:37 ` [PATCH 3/3] ntfs3: add FS_IOC_SETFSLABEL ioctl Ethan Ferguson
  2 siblings, 0 replies; 4+ messages in thread
From: Ethan Ferguson @ 2025-08-28 20:37 UTC (permalink / raw)
  To: almaz.alexandrovich; +Cc: ntfs3, linux-fsdevel, linux-kernel, Ethan Ferguson

Add support for the FS_IOC_GETFSLABEL ioctl.

Signed-off-by: Ethan Ferguson <ethan.ferguson@zetier.com>

---
 fs/ntfs3/file.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index c1ece707b195..0a1e9f16ffaf 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -49,6 +49,14 @@ static int ntfs_ioctl_fitrim(struct ntfs_sb_info *sbi, unsigned long arg)
 	return 0;
 }
 
+static int ntfs_ioctl_get_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf)
+{
+	if (copy_to_user(buf, sbi->volume.label, FSLABEL_MAX))
+		return -EFAULT;
+
+	return 0;
+}
+
 /*
  * ntfs_ioctl - file_operations::unlocked_ioctl
  */
@@ -64,6 +72,8 @@ long ntfs_ioctl(struct file *filp, u32 cmd, unsigned long arg)
 	switch (cmd) {
 	case FITRIM:
 		return ntfs_ioctl_fitrim(sbi, arg);
+	case FS_IOC_GETFSLABEL:
+		return ntfs_ioctl_get_volume_label(sbi, (u8 __user *)arg);
 	}
 	return -ENOTTY; /* Inappropriate ioctl for device. */
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] ntfs3: add FS_IOC_SETFSLABEL ioctl
  2025-08-28 20:37 [PATCH 0/3] ntfs3: Add support for FS_IOC_{GET,SET}FSLABEL ioctl Ethan Ferguson
  2025-08-28 20:37 ` [PATCH 1/3] ntfs3: transition magic number to shared constant Ethan Ferguson
  2025-08-28 20:37 ` [PATCH 2/3] ntfs3: add FS_IOC_GETFSLABEL ioctl Ethan Ferguson
@ 2025-08-28 20:37 ` Ethan Ferguson
  2 siblings, 0 replies; 4+ messages in thread
From: Ethan Ferguson @ 2025-08-28 20:37 UTC (permalink / raw)
  To: almaz.alexandrovich; +Cc: ntfs3, linux-fsdevel, linux-kernel, Ethan Ferguson

Add support for the FS_IOC_SETFSLABEL ioctl.

Signed-off-by: Ethan Ferguson <ethan.ferguson@zetier.com>

---
 fs/ntfs3/file.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 0a1e9f16ffaf..4c90ec2fa2ea 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -57,6 +57,22 @@ static int ntfs_ioctl_get_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf)
 	return 0;
 }
 
+static int ntfs_ioctl_set_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf)
+{
+	u8 user[FSLABEL_MAX] = {0};
+	int len;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	if (copy_from_user(user, buf, FSLABEL_MAX))
+		return -EFAULT;
+
+	len = strnlen(user, FSLABEL_MAX);
+
+	return ntfs_set_label(sbi, user, len);
+}
+
 /*
  * ntfs_ioctl - file_operations::unlocked_ioctl
  */
@@ -74,6 +90,8 @@ long ntfs_ioctl(struct file *filp, u32 cmd, unsigned long arg)
 		return ntfs_ioctl_fitrim(sbi, arg);
 	case FS_IOC_GETFSLABEL:
 		return ntfs_ioctl_get_volume_label(sbi, (u8 __user *)arg);
+	case FS_IOC_SETFSLABEL:
+		return ntfs_ioctl_set_volume_label(sbi, (u8 __user *)arg);
 	}
 	return -ENOTTY; /* Inappropriate ioctl for device. */
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-28 20:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-28 20:37 [PATCH 0/3] ntfs3: Add support for FS_IOC_{GET,SET}FSLABEL ioctl Ethan Ferguson
2025-08-28 20:37 ` [PATCH 1/3] ntfs3: transition magic number to shared constant Ethan Ferguson
2025-08-28 20:37 ` [PATCH 2/3] ntfs3: add FS_IOC_GETFSLABEL ioctl Ethan Ferguson
2025-08-28 20:37 ` [PATCH 3/3] ntfs3: add FS_IOC_SETFSLABEL ioctl Ethan Ferguson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).