diff mbox series

[1/3] vfs: create ioctls to query and set the filesystem uuids

Message ID 158283922171.904118.10312419179350062263.stgit@magnolia
State New
Headers show
Series fs: online filesystem uuid operations | expand

Commit Message

Darrick Wong Feb. 27, 2020, 9:33 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Define a pair of ioctls to get and set the filesystem uuid.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_fs.h  |    2 ++
 include/uapi/linux/fs.h |   28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
index 558a396c74b3..c968eaf56ec3 100644
--- a/fs/xfs/libxfs/xfs_fs.h
+++ b/fs/xfs/libxfs/xfs_fs.h
@@ -814,6 +814,8 @@  struct xfs_scrub_metadata {
 #define XFS_IOC_FSGEOMETRY	     _IOR ('X', 126, struct xfs_fsop_geom)
 #define XFS_IOC_BULKSTAT	     _IOR ('X', 127, struct xfs_bulkstat_req)
 #define XFS_IOC_INUMBERS	     _IOR ('X', 128, struct xfs_inumbers_req)
+/*	FS_IOC_GETFSUUID ----------- uses 129 */
+/*	FS_IOC_SETFSUUID ----------- uses 130 */
 /*	XFS_IOC_GETFSUUID ---------- deprecated 140	 */
 
 
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 379a612f8f1d..a5423d540ecd 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -142,6 +142,32 @@  struct fsxattr {
 #define FS_XFLAG_COWEXTSIZE	0x00010000	/* CoW extent size allocator hint */
 #define FS_XFLAG_HASATTR	0x80000000	/* no DIFLAG for this	*/
 
+/* Get and set filesystem UUID. */
+struct ioc_fsuuid {
+	uint32_t	fu_flags;
+	uint16_t	fu_length;
+	uint16_t	fu_reserved;
+	uint64_t	fu_reserved1;
+};
+
+/*
+ * Set the UUID even if that would require setting of an incompat or rocompat
+ * feature flag.  This will make the filesystem unmountable on older kernels.
+ */
+#define FS_IOC_SETFSUUID_FORCE_INCOMPAT	(1 << 0)
+
+#define FS_IOC_SETFSUUID_ALL	(FS_IOC_SETFSUUID_FORCE_INCOMPAT)
+
+static inline size_t ioc_fsuuid_sizeof(size_t payload_len)
+{
+	return sizeof(struct ioc_fsuuid) + payload_len;
+}
+
+static inline char *ioc_fsuuid_payload(struct ioc_fsuuid *fu)
+{
+	return (char *)(fu + 1);
+}
+
 /* the read-only stuff doesn't really belong here, but any other place is
    probably as bad and I don't want to create yet another include file. */
 
@@ -214,6 +240,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('X', 129, struct ioc_fsuuid)
+#define FS_IOC_SETFSUUID		_IOW('X', 130, struct ioc_fsuuid)
 
 /*
  * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)