[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <158283922171.904118.10312419179350062263.stgit@magnolia>
Date: Thu, 27 Feb 2020 13:33:41 -0800
From: "Darrick J. Wong" <darrick.wong@...cle.com>
To: darrick.wong@...cle.com
Cc: linux-xfs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-ext4@...r.kernel.org
Subject: [PATCH 1/3] vfs: create ioctls to query and set the filesystem uuids
From: Darrick J. Wong <darrick.wong@...cle.com>
Define a pair of ioctls to get and set the filesystem uuid.
Signed-off-by: Darrick J. Wong <darrick.wong@...cle.com>
---
fs/xfs/libxfs/xfs_fs.h | 2 ++
include/uapi/linux/fs.h | 28 ++++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
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)
Powered by blists - more mailing lists