[PATCH v1] ntfs: support FS_IOC_GETFSUUID

From: Baolin Liu

Date: Tue Oct 13 2026 - 19:44:01 EST


From: Baolin Liu <liubaolin@xxxxxxxxxx>

NTFS reads the 64-bit volume serial number from the boot sector but leaves
the superblock UUID unset. As a result, the generic FS_IOC_GETFSUUID
handler returns ENOTTY for files and directories on an NTFS volume.

Register the on-disk little-endian serial number as an eight-byte
filesystem identifier with super_set_uuid(). The generic VFS handler can
then expose the existing volume identifier.

Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
---
Tested in QEMU with file and directory descriptors, comparing the returned
bytes with the boot sector. Queries remain consistent after read-only
and read-write remounts, unmount/mount and a fresh boot. An invalid output
buffer returns EFAULT.

fs/ntfs/super.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 242fb19ced2b..950d305ab695 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -997,6 +997,8 @@ static bool parse_ntfs_boot_sector(struct ntfs_volume *vol,
vol->mft_record_size_bits;
ntfs_debug("vol->mftmirr_size = %i", vol->mftmirr_size);
vol->serial_no = le64_to_cpu(b->volume_serial_number);
+ super_set_uuid(vol->sb, (const u8 *)&b->volume_serial_number,
+ sizeof(b->volume_serial_number));
ntfs_debug("vol->serial_no = 0x%llx", vol->serial_no);

vol->sparse_compression_unit = 4;
--
2.51.0