Skip to contentSkip to conversation

ext4: create an ioctl report fs geometry

PATCH New Darrick J. Wong 1 participant 1 message Mar 2, 2017 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ext4: create an ioctl report fs geometry

Add an ioctl to report the geometry of a mounted filesystem. The structure is designed to be close enough to XFS's that we'll be able to leverage the new GETFSMAP functionality in xfsprogs.

---
 fs/ext4/ext4.h  |   33 +++++++++++++++++++++++++++++++++
 fs/ext4/ioctl.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)
fs/ext4/ext4.h +33 -0
index 2163c1e..9e93aba 100644
@@ -614,6 +614,38 @@ enum {
 #define EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER	0x0010
 #define EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER	0x0020
 
+/* ext4 fs geometry. */
+struct ext4_fsop_geom {
+	__u32		efg_blocksize;	/* filesystem (data) block size */
+	__u32		efg_bgblocks;	/* fsblocks in a block group	*/
+	__u32		efg_bgcount;	/* number of block groups	*/
+	__u32		efg_logblocks;	/* fsblocks in the log		*/
+	__u32		efg_resvblocks;	/* number of reserved blocks	*/
+	__u32		efg_inodesize;	/* inode size in bytes		*/
+	__u32		efg_bg_iblocks;	/* inode blocks per block group	*/
+	__u32		efg_flags;	/* superblock feature flags	*/
+	__u64		efg_inodecount;	/* inode count			*/
+	__u64		efg_blockcount;	/* fsblocks in filesystem	*/
+	unsigned char	efg_uuid[16];	/* unique id of the filesystem	*/
+	__u32		efg_sunit;	/* stripe unit, fsblocks	*/
+	__u32		efg_swidth;	/* stripe width, fsblocks	*/
+	__u32		efg_clustersize;/* fs cluster size		*/
+	__u32		efg_flexbgsize;	/* number of bg's in a flexbg	*/
+	__u64		efg_resv[6];
+};
+
+#define EXT4_FSOP_GEOM_FLAGS_ATTR	0x00001	/* extended attrs in use */
+#define EXT4_FSOP_GEOM_FLAGS_NLINK	0x00002	/* 32-bit nlink values	 */
+#define EXT4_FSOP_GEOM_FLAGS_QUOTA	0x00004	/* quotas enabled	 */
+#define EXT4_FSOP_GEOM_FLAGS_PROJQ	0x00008	/* project quotas	 */
+#define EXT4_FSOP_GEOM_FLAGS_META_CSUM	0x00010	/* metadata checksums	 */
+#define EXT4_FSOP_GEOM_FLAGS_FTYPE	0x00020	/* inode directory types */
+#define EXT4_FSOP_GEOM_FLAGS_64BIT	0x00040	/* 64-bit support	 */
+#define EXT4_FSOP_GEOM_FLAGS_INLINEDATA	0x00080	/* inline data		 */
+#define EXT4_FSOP_GEOM_FLAGS_ENCRYPT	0x00100	/* encrypted files	 */
+#define EXT4_FSOP_GEOM_FLAGS_LARGEDIR	0x00200	/* large directories	 */
+#define EXT4_FSOP_GEOM_FLAGS_EXTENTS	0x00400	/* extents		 */
+
 /*
  * ioctl commands
  */
@@ -638,6 +670,7 @@ enum {
 #define EXT4_IOC_SET_ENCRYPTION_POLICY	FS_IOC_SET_ENCRYPTION_POLICY
 #define EXT4_IOC_GET_ENCRYPTION_PWSALT	FS_IOC_GET_ENCRYPTION_PWSALT
 #define EXT4_IOC_GET_ENCRYPTION_POLICY	FS_IOC_GET_ENCRYPTION_POLICY
+#define EXT4_IOC_FSGEOMETRY		_IOR ('f', 19, struct ext4_fsop_geom)
 
 #ifndef FS_IOC_FSGETXATTR
 /* Until the uapi changes get merged for project quota... */
fs/ext4/ioctl.c +53 -0

65 lines not on this page · raw message