Skip to contentSkip to conversation

porting the GETFSUUID ioctl to xfs

PATCH Superseded Catherine Hoang 3 participants 9 messages Nov 9, 2022 – Nov 11, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover porting the GETFSUUID ioctl to xfs

Hi all,

This patch aims to hoist the ext4 get/set ioctls to the VFS so we have a common interface for tools such as coreutils. The second patch adds support for FS_IOC_GETFSUUID in xfs (with FS_IOC_SETFSUUID planned for future patches). In addition, the new xfs_spaceman fsuuid command uses this ioctl to retrieve the UUID of a mounted filesystem.

Comments and feedback appreciated!

Catherine

Catherine Hoang (2):
fs: hoist get/set UUID ioctls
xfs: add FS_IOC_GETFSUUID ioctl

 fs/ext4/ext4.h          | 13 ++-----------
 fs/xfs/xfs_ioctl.c      | 32 ++++++++++++++++++++++++++++++++
 include/uapi/linux/fs.h | 11 +++++++++++
 3 files changed, 45 insertions(+), 11 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 fs: hoist get/set UUID ioctls

Hoist the EXT4_IOC_[GS]ETFSUUID ioctls so that they can be used by all filesystems. This allows us to have a common interface for tools such as coreutils.

---
 fs/ext4/ext4.h          | 13 ++-----------
 include/uapi/linux/fs.h | 11 +++++++++++
 2 files changed, 13 insertions(+), 11 deletions(-)
fs/ext4/ext4.h +2 -11
index 8d5453852f98..b200302a3732 100644
@@ -722,8 +722,8 @@ enum {
 #define EXT4_IOC_GETSTATE		_IOW('f', 41, __u32)
 #define EXT4_IOC_GET_ES_CACHE		_IOWR('f', 42, struct fiemap)
 #define EXT4_IOC_CHECKPOINT		_IOW('f', 43, __u32)
-#define EXT4_IOC_GETFSUUID		_IOR('f', 44, struct fsuuid)
-#define EXT4_IOC_SETFSUUID		_IOW('f', 44, struct fsuuid)
+#define EXT4_IOC_GETFSUUID		FS_IOC_GETFSUUID
+#define EXT4_IOC_SETFSUUID		FS_IOC_SETFSUUID
 
 #define EXT4_IOC_SHUTDOWN _IOR ('X', 125, __u32)
 
@@ -753,15 +753,6 @@ enum {
 						EXT4_IOC_CHECKPOINT_FLAG_ZEROOUT | \
 						EXT4_IOC_CHECKPOINT_FLAG_DRY_RUN)
 
-/*
- * Structure for EXT4_IOC_GETFSUUID/EXT4_IOC_SETFSUUID
- */
-struct fsuuid {
-	__u32       fsu_len;
-	__u32       fsu_flags;
-	__u8        fsu_uuid[];
-};
-
 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /*
  * ioctl commands in 32 bit emulation
include/uapi/linux/fs.h +11 -0
index b7b56871029c..63b925444592 100644
@@ -121,6 +121,15 @@ struct fsxattr {
 	unsigned char	fsx_pad[8];
 };
 
+/*
+ * Structure for FS_IOC_GETFSUUID/FS_IOC_SETFSUUID
+ */
+struct fsuuid {
+	__u32       fsu_len;
+	__u32       fsu_flags;
+	__u8        fsu_uuid[];
+};
+
 /*
  * Flags for the fsx_xflags field
  */
@@ -215,6 +224,8 @@ struct fsxattr {
 #define FS_IOC_FSSETXATTR		_IOW('X', 32, struct fsxattr)
 #define FS_IOC_GETFSLABEL		_IOR(0x94, 49, char[FSLABEL_MAX])
 #define FS_IOC_SETFSLABEL		_IOW(0x94, 50, char[FSLABEL_MAX])
+#define FS_IOC_GETFSUUID		_IOR('f', 44, struct fsuuid)
+#define FS_IOC_SETFSUUID		_IOW('f', 44, struct fsuuid)
 
 /*
  * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
Signature · 1 line
2.25.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] fs: hoist get/set UUID ioctls

Quoted 5 lines · Catherine Hoang

Hoist the EXT4_IOC_[GS]ETFSUUID ioctls so that they can be used by all filesystems. This allows us to have a common interface for tools such as coreutils.

Looks good,

Also, for the inevitable v2 patchset after we sort out some weird bugs in the ext4 implementation of this, can you please cc [email protected]?

--D

Quoted 68 lines
---
 fs/ext4/ext4.h          | 13 ++-----------
 include/uapi/linux/fs.h | 11 +++++++++++
 2 files changed, 13 insertions(+), 11 deletions(-)
fs/ext4/ext4.h +2 -11
index 8d5453852f98..b200302a3732 100644
@@ -722,8 +722,8 @@ enum {
 #define EXT4_IOC_GETSTATE		_IOW('f', 41, __u32)
 #define EXT4_IOC_GET_ES_CACHE		_IOWR('f', 42, struct fiemap)
 #define EXT4_IOC_CHECKPOINT		_IOW('f', 43, __u32)
-#define EXT4_IOC_GETFSUUID		_IOR('f', 44, struct fsuuid)
-#define EXT4_IOC_SETFSUUID		_IOW('f', 44, struct fsuuid)
+#define EXT4_IOC_GETFSUUID		FS_IOC_GETFSUUID
+#define EXT4_IOC_SETFSUUID		FS_IOC_SETFSUUID
 
 #define EXT4_IOC_SHUTDOWN _IOR ('X', 125, __u32)
 
@@ -753,15 +753,6 @@ enum {
 						EXT4_IOC_CHECKPOINT_FLAG_ZEROOUT | \
 						EXT4_IOC_CHECKPOINT_FLAG_DRY_RUN)
 
-/*
- * Structure for EXT4_IOC_GETFSUUID/EXT4_IOC_SETFSUUID
- */
-struct fsuuid {
-	__u32       fsu_len;
-	__u32       fsu_flags;
-	__u8        fsu_uuid[];
-};
-
 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /*
  * ioctl commands in 32 bit emulation
include/uapi/linux/fs.h +11 -0
index b7b56871029c..63b925444592 100644
@@ -121,6 +121,15 @@ struct fsxattr {
 	unsigned char	fsx_pad[8];
 };
 
+/*
+ * Structure for FS_IOC_GETFSUUID/FS_IOC_SETFSUUID
+ */
+struct fsuuid {
+	__u32       fsu_len;
+	__u32       fsu_flags;
+	__u8        fsu_uuid[];
+};
+
 /*
  * Flags for the fsx_xflags field
  */
@@ -215,6 +224,8 @@ struct fsxattr {
 #define FS_IOC_FSSETXATTR		_IOW('X', 32, struct fsxattr)
 #define FS_IOC_GETFSLABEL		_IOR(0x94, 49, char[FSLABEL_MAX])
 #define FS_IOC_SETFSLABEL		_IOW(0x94, 50, char[FSLABEL_MAX])
+#define FS_IOC_GETFSUUID		_IOR('f', 44, struct fsuuid)
+#define FS_IOC_SETFSUUID		_IOW('f', 44, struct fsuuid)
 
 /*
  * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH v1 1/2] fs: hoist get/set UUID ioctls

Quoted 7 lines · Darrick J. Wong
Quoted 4 lines · Catherine Hoang

Hoist the EXT4_IOC_[GS]ETFSUUID ioctls so that they can be used by all filesystems. This allows us to have a common interface for tools such as coreutils.

Quoted 8 lines
Quoted 1 line

Looks good,

Also, for the inevitable v2 patchset after we sort out some weird bugs in the ext4 implementation of this, can you please cc [email protected]?

Thanks for reviewing! And sure, I’ll cc them in the next version

Quoted 71 lines

--D

Quoted 68 lines

---
fs/ext4/ext4.h | 13 ++-----------
include/uapi/linux/fs.h | 11 +++++++++++

2 files changed, 13 insertions(+), 11 deletions(-)
fs/ext4/ext4.h +2 -11
index 8d5453852f98..b200302a3732 100644
@@ -722,8 +722,8 @@ enum {
 #define EXT4_IOC_GETSTATE		_IOW('f', 41, __u32)
 #define EXT4_IOC_GET_ES_CACHE		_IOWR('f', 42, struct fiemap)
 #define EXT4_IOC_CHECKPOINT		_IOW('f', 43, __u32)
-#define EXT4_IOC_GETFSUUID		_IOR('f', 44, struct fsuuid)
-#define EXT4_IOC_SETFSUUID		_IOW('f', 44, struct fsuuid)
+#define EXT4_IOC_GETFSUUID		FS_IOC_GETFSUUID
+#define EXT4_IOC_SETFSUUID		FS_IOC_SETFSUUID
 
 #define EXT4_IOC_SHUTDOWN _IOR ('X', 125, __u32)
 
@@ -753,15 +753,6 @@ enum {
 						EXT4_IOC_CHECKPOINT_FLAG_ZEROOUT | \
 						EXT4_IOC_CHECKPOINT_FLAG_DRY_RUN)
 
-/*
- * Structure for EXT4_IOC_GETFSUUID/EXT4_IOC_SETFSUUID
- */
-struct fsuuid {
-	__u32       fsu_len;
-	__u32       fsu_flags;
-	__u8        fsu_uuid[];
-};
-
 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /*
 * ioctl commands in 32 bit emulation
include/uapi/linux/fs.h +11 -0
index b7b56871029c..63b925444592 100644
@@ -121,6 +121,15 @@ struct fsxattr {
 	unsigned char	fsx_pad[8];
 };
 
+/*
+ * Structure for FS_IOC_GETFSUUID/FS_IOC_SETFSUUID
+ */
+struct fsuuid {
+	__u32       fsu_len;
+	__u32       fsu_flags;
+	__u8        fsu_uuid[];
+};
+
 /*
 * Flags for the fsx_xflags field
 */
@@ -215,6 +224,8 @@ struct fsxattr {
 #define FS_IOC_FSSETXATTR		_IOW('X', 32, struct fsxattr)
 #define FS_IOC_GETFSLABEL		_IOR(0x94, 49, char[FSLABEL_MAX])
 #define FS_IOC_SETFSLABEL		_IOW(0x94, 50, char[FSLABEL_MAX])
+#define FS_IOC_GETFSUUID		_IOR('f', 44, struct fsuuid)
+#define FS_IOC_SETFSUUID		_IOW('f', 44, struct fsuuid)
 
 /*
 * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
Signature · 1 line
2.25.1
Reviewed-by on v1 1/2
#4 lore raw

Re: [PATCH v1 1/2] fs: hoist get/set UUID ioctls

In reply to Catherine Hoang
Quoted 7 lines · Catherine Hoang

Hoist the EXT4_IOC_[GS]ETFSUUID ioctls so that they can be used by all
filesystems. This allows us to have a common interface for tools such as
coreutils.

Looks straight forward to me

Quoted 69 lines

---
 fs/ext4/ext4.h          | 13 ++-----------
 include/uapi/linux/fs.h | 11 +++++++++++

 2 files changed, 13 insertions(+), 11 deletions(-)
fs/ext4/ext4.h +2 -2
index 8d5453852f98..b200302a3732 100644
@@ -722,8 +722,8 @@ enum {
  #define EXT4_IOC_GETSTATE              _IOW('f', 41, __u32)
  #define EXT4_IOC_GET_ES_CACHE          _IOWR('f', 42, struct fiemap)
  #define EXT4_IOC_CHECKPOINT            _IOW('f', 43, __u32)
-#define EXT4_IOC_GETFSUUID             _IOR('f', 44, struct fsuuid)
-#define EXT4_IOC_SETFSUUID             _IOW('f', 44, struct fsuuid)
+#define EXT4_IOC_GETFSUUID             FS_IOC_GETFSUUID
+#define EXT4_IOC_SETFSUUID             FS_IOC_SETFSUUID


 #define EXT4_IOC_SHUTDOWN _IOR ('X', 125, __u32)

fs/ext4/ext4.h +0 -0
@@ -753,15 +753,6 @@ enum {

                                                EXT4_IOC_CHECKPOINT_F LAG_ZEROOUT | \
                                                EXT4_IOC_CHECKPOINT_F LAG_DRY_RUN)

fs/ext4/ext4.h +0 -9
-/*
- * Structure for EXT4_IOC_GETFSUUID/EXT4_IOC_SETFSUUID
- */
-struct fsuuid {
-       __u32       fsu_len;
-       __u32       fsu_flags;
-       __u8        fsu_uuid[];
-};
-

 #if defined(__KERNEL__) && defined(CONFIG_COMPAT) /*
  * ioctl commands in 32 bit emulation

include/uapi/linux/fs.h +0 -0
index b7b56871029c..63b925444592 100644
@@ -121,6 +121,15 @@ struct fsxattr {
         unsigned char   fsx_pad[8];
  };

include/uapi/linux/fs.h +9 -0
+/*
+ * Structure for FS_IOC_GETFSUUID/FS_IOC_SETFSUUID
+ */
+struct fsuuid {
+       __u32       fsu_len;
+       __u32       fsu_flags;
+       __u8        fsu_uuid[];
+};
+

 /*
  * Flags for the fsx_xflags field
  */

include/uapi/linux/fs.h +2 -0
@@ -215,6 +224,8 @@ struct fsxattr {
  #define FS_IOC_FSSETXATTR              _IOW('X', 32, struct fsxattr)
  #define FS_IOC_GETFSLABEL              _IOR(0x94, 49,
 char[FSLABEL_MAX])
  #define FS_IOC_SETFSLABEL              _IOW(0x94, 50,
 char[FSLABEL_MAX])
+#define FS_IOC_GETFSUUID               _IOR('f', 44, struct fsuuid)
+#define FS_IOC_SETFSUUID               _IOW('f', 44, struct fsuuid)


 /*
  * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)

#5 lore raw

PATCH 2/2 xfs: add FS_IOC_GETFSUUID ioctl

In reply to Catherine Hoang

Add a new ioctl to retrieve the UUID of a mounted xfs filesystem.

---
 fs/xfs/xfs_ioctl.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
fs/xfs/xfs_ioctl.c +32 -0
index 1f783e979629..657fe058dfba 100644
@@ -1865,6 +1865,35 @@ xfs_fs_eofblocks_from_user(
 	return 0;
 }
 
+static int xfs_ioctl_getuuid(
+	struct xfs_mount	*mp,
+	struct fsuuid __user	*ufsuuid)
+{
+	struct fsuuid		fsuuid;
+	__u8			uuid[UUID_SIZE];
+
+	if (copy_from_user(&fsuuid, ufsuuid, sizeof(fsuuid)))
+		return -EFAULT;
+
+	if (fsuuid.fsu_len == 0) {
+		fsuuid.fsu_len = UUID_SIZE;
+		if (copy_to_user(ufsuuid, &fsuuid, sizeof(fsuuid.fsu_len)))
+			return -EFAULT;
+		return -EINVAL;
+	}
+
+	if (fsuuid.fsu_len != UUID_SIZE || fsuuid.fsu_flags != 0)
+		return -EINVAL;
+
+	spin_lock(&mp->m_sb_lock);
+	memcpy(uuid, &mp->m_sb.sb_uuid, UUID_SIZE);
+	spin_unlock(&mp->m_sb_lock);
+
+	if (copy_to_user(&ufsuuid->fsu_uuid[0], uuid, UUID_SIZE))
+		return -EFAULT;
+	return 0;
+}
+
 /*
  * These long-unused ioctls were removed from the official ioctl API in 5.17,
  * but retain these definitions so that we can log warnings about them.
@@ -2153,6 +2182,9 @@ xfs_file_ioctl(
 		return error;
 	}
 
+	case FS_IOC_GETFSUUID:
+		return xfs_ioctl_getuuid(mp, arg);
+
 	default:
 		return -ENOTTY;
 	}
Signature · 1 line
2.25.1
#6 lore raw

Re: [PATCH v1 2/2] xfs: add FS_IOC_GETFSUUID ioctl

Quoted 1 line · Catherine Hoang

Add a new ioctl to retrieve the UUID of a mounted xfs filesystem.

I think it's worth mentioning that this is the precursor to trying to implement SETFSUUID... but that's something for a future series, since changing the uuid will upset the log, and we have to figure out how to deal with that gracefully.

Quoted 10 lines
---
 fs/xfs/xfs_ioctl.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
fs/xfs/xfs_ioctl.c +0 -0
index 1f783e979629..657fe058dfba 100644

fs/xfs/xfs_ioctl.c xfs_fs_eofblocks_from_user( · line 1868

Quoted 4 lines
fs/xfs/xfs_ioctl.c +1 -0
@@ -1865,6 +1865,35 @@ xfs_fs_eofblocks_from_user(
 	return 0;
 }
 
+static int xfs_ioctl_getuuid(

Nit: function names should start on a new line.

Quoted 4 lines
fs/xfs/xfs_ioctl.c +4 -0
+	struct xfs_mount	*mp,
+	struct fsuuid __user	*ufsuuid)
+{
+	struct fsuuid		fsuuid;

fs/xfs/xfs_ioctl.c xfs_fs_eofblocks_from_user( · line 1882

Quoted 10 lines
fs/xfs/xfs_ioctl.c +10 -0
+	__u8			uuid[UUID_SIZE];
+
+	if (copy_from_user(&fsuuid, ufsuuid, sizeof(fsuuid)))
+		return -EFAULT;
+
+	if (fsuuid.fsu_len == 0) {
+		fsuuid.fsu_len = UUID_SIZE;
+		if (copy_to_user(ufsuuid, &fsuuid, sizeof(fsuuid.fsu_len)))
+			return -EFAULT;
+		return -EINVAL;

Ted and I were looking through the ext4_ioctl_getuuid function on this morning's ext4 concall, and we decided that copying the desired uuid buffer length out to userspace shouldn't result in an EINVAL return here...

fs/xfs/xfs_ioctl.c xfs_fs_eofblocks_from_user( · line 1885

Quoted 3 lines
fs/xfs/xfs_ioctl.c +3 -0
+	}
+
+	if (fsuuid.fsu_len != UUID_SIZE || fsuuid.fsu_flags != 0)

...and that we shouldn't reject the case where fsu_len > UUID_SIZE. Instead, we should copy the uuid and update the caller's fsu_len to reflect however many bytes we copied out. I'll send patches to do that shortly.

fs/xfs/xfs_ioctl.c xfs_fs_eofblocks_from_user( · line 1893

Quoted 8 lines
fs/xfs/xfs_ioctl.c +8 -0
+		return -EINVAL;
+
+	spin_lock(&mp->m_sb_lock);
+	memcpy(uuid, &mp->m_sb.sb_uuid, UUID_SIZE);
+	spin_unlock(&mp->m_sb_lock);
+
+	if (copy_to_user(&ufsuuid->fsu_uuid[0], uuid, UUID_SIZE))
+		return -EFAULT;

The rest of this logic looks correct to me. Thanks for getting this out there.

--D

Quoted 19 lines
fs/xfs/xfs_ioctl.c +6 -0
+	return 0;
+}
+
 /*
  * These long-unused ioctls were removed from the official ioctl API in 5.17,
  * but retain these definitions so that we can log warnings about them.
@@ -2153,6 +2182,9 @@ xfs_file_ioctl(
 		return error;
 	}
 
+	case FS_IOC_GETFSUUID:
+		return xfs_ioctl_getuuid(mp, arg);
+
 	default:
 		return -ENOTTY;
 	}
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH v1 2/2] xfs: add FS_IOC_GETFSUUID ioctl

Quoted 23 lines · Darrick J. Wong
Quoted 1 line · Catherine Hoang

Add a new ioctl to retrieve the UUID of a mounted xfs filesystem.

I think it's worth mentioning that this is the precursor to trying to implement SETFSUUID... but that's something for a future series, since changing the uuid will upset the log, and we have to figure out how to deal with that gracefully.

Quoted 13 lines

---
fs/xfs/xfs_ioctl.c | 32 ++++++++++++++++++++++++++++++++

1 file changed, 32 insertions(+)
fs/xfs/xfs_ioctl.c +0 -0
index 1f783e979629..657fe058dfba 100644
@@ -1865,6 +1865,35 @@ xfs_fs_eofblocks_from_user(
 	return 0;
 }
 
Quoted 4 lines

fs/xfs/xfs_ioctl.c xfs_fs_eofblocks_from_user( · line 1868

Quoted 1 line
fs/xfs/xfs_ioctl.c +1 -0
+static int xfs_ioctl_getuuid(

Nit: function names should start on a new line.

Ok, will fix that

Quoted 20 lines
Quoted 4 lines
fs/xfs/xfs_ioctl.c +4 -0
+	struct xfs_mount	*mp,
+	struct fsuuid __user	*ufsuuid)
+{
+	struct fsuuid		fsuuid;

fs/xfs/xfs_ioctl.c xfs_fs_eofblocks_from_user( · line 1882

Quoted 10 lines
fs/xfs/xfs_ioctl.c +10 -0
+	__u8			uuid[UUID_SIZE];
+
+	if (copy_from_user(&fsuuid, ufsuuid, sizeof(fsuuid)))
+		return -EFAULT;
+
+	if (fsuuid.fsu_len == 0) {
+		fsuuid.fsu_len = UUID_SIZE;
+		if (copy_to_user(ufsuuid, &fsuuid, sizeof(fsuuid.fsu_len)))
+			return -EFAULT;
+		return -EINVAL;

Ted and I were looking through the ext4_ioctl_getuuid function on this morning's ext4 concall, and we decided that copying the desired uuid buffer length out to userspace shouldn't result in an EINVAL return here...

Quoted 8 lines

fs/xfs/xfs_ioctl.c xfs_fs_eofblocks_from_user( · line 1885

Quoted 3 lines
fs/xfs/xfs_ioctl.c +3 -0
+	}
+
+	if (fsuuid.fsu_len != UUID_SIZE || fsuuid.fsu_flags != 0)

...and that we shouldn't reject the case where fsu_len > UUID_SIZE. Instead, we should copy the uuid and update the caller's fsu_len to reflect however many bytes we copied out. I'll send patches to do that shortly.

Ok, that makes sense. I’ll apply those changes over to xfs. Thanks!

Quoted 33 lines

fs/xfs/xfs_ioctl.c xfs_fs_eofblocks_from_user( · line 1893

Quoted 9 lines
fs/xfs/xfs_ioctl.c +8 -0
+		return -EINVAL;
+
+	spin_lock(&mp->m_sb_lock);
+	memcpy(uuid, &mp->m_sb.sb_uuid, UUID_SIZE);
+	spin_unlock(&mp->m_sb_lock);
+
+	if (copy_to_user(&ufsuuid->fsu_uuid[0], uuid, UUID_SIZE))
+		return -EFAULT;

The rest of this logic looks correct to me. Thanks for getting this out there.

--D

Quoted 18 lines
fs/xfs/xfs_ioctl.c +6 -0
+	return 0;
+}
+
 /*
 * These long-unused ioctls were removed from the official ioctl API in 5.17,
 * but retain these definitions so that we can log warnings about them.
@@ -2153,6 +2182,9 @@ xfs_file_ioctl(
 		return error;
 	}
 
+	case FS_IOC_GETFSUUID:
+		return xfs_ioctl_getuuid(mp, arg);
+
 	default:
 		return -ENOTTY;
 	}
Signature · 1 line
2.25.1
Reviewed-by on v1 2/2
#8 lore raw

Re: [PATCH v1 2/2] xfs: add FS_IOC_GETFSUUID ioctl

In reply to Catherine Hoang
Quoted 3 lines · Catherine Hoang

Add a new ioctl to retrieve the UUID of a mounted xfs filesystem.

With Darricks commentary addressed, I think this one looks good

Quoted 57 lines

---
 fs/xfs/xfs_ioctl.c | 32 ++++++++++++++++++++++++++++++++

 1 file changed, 32 insertions(+)
fs/xfs/xfs_ioctl.c +0 -0
index 1f783e979629..657fe058dfba 100644
@@ -1865,6 +1865,35 @@ xfs_fs_eofblocks_from_user(
         return 0;
  }

fs/xfs/xfs_ioctl.c +13 -0
+static int xfs_ioctl_getuuid(
+       struct xfs_mount        *mp,
+       struct fsuuid __user    *ufsuuid)
+{
+       struct fsuuid           fsuuid;
+       __u8                    uuid[UUID_SIZE];
+
+       if (copy_from_user(&fsuuid, ufsuuid, sizeof(fsuuid)))
+               return -EFAULT;
+
+       if (fsuuid.fsu_len == 0) {
+               fsuuid.fsu_len = UUID_SIZE;
+               if (copy_to_user(ufsuuid, &fsuuid,

sizeof(fsuuid.fsu_len)))
+                       return -EFAULT;
+               return -EINVAL;
+       }

fs/xfs/xfs_ioctl.c +13 -0
+
+       if (fsuuid.fsu_len != UUID_SIZE || fsuuid.fsu_flags != 0)
+               return -EINVAL;
+
+       spin_lock(&mp->m_sb_lock);
+       memcpy(uuid, &mp->m_sb.sb_uuid, UUID_SIZE);
+       spin_unlock(&mp->m_sb_lock);
+
+       if (copy_to_user(&ufsuuid->fsu_uuid[0], uuid, UUID_SIZE))
+               return -EFAULT;
+       return 0;
+}
+

 /*
  * These long-unused ioctls were removed from the official ioctl API in 5.17,
  * but retain these definitions so that we can log warnings about them.

fs/xfs/xfs_ioctl.c +0 -0
@@ -2153,6 +2182,9 @@ xfs_file_ioctl(
                 return error;
         }


+       case FS_IOC_GETFSUUID:
+               return xfs_ioctl_getuuid(mp, arg); +
        default:
                return -ENOTTY;
        }