summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-05-22 08:44:25 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2019-06-26 13:01:56 -0700
commita077630dba26c4edbd534dd1d9e3ad2b97201bb4 (patch)
tree7ea6dee6f6304498bc49cbd9bb327294325451ee
parent4b4f3ae674e1bf79ff47f0b3ddd8e5b101d894bb (diff)
xfs: allow bulkstat_single of special inodesbulkstat-v5_2019-06-26
Create a new ireq flag (for single bulkstats) that enables userspace to ask us for a special inode number instead of interpreting @ino as a literal inode number. This enables us to query the root inode easily. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Allison Collins <allison.henderson@oracle.com>
-rw-r--r--fs/xfs/libxfs/xfs_fs.h11
-rw-r--r--fs/xfs/xfs_ioctl.c10
2 files changed, 20 insertions, 1 deletions
diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
index 77c06850ac52..1489bce07d66 100644
--- a/fs/xfs/libxfs/xfs_fs.h
+++ b/fs/xfs/libxfs/xfs_fs.h
@@ -482,7 +482,16 @@ struct xfs_ireq {
uint64_t reserved[2]; /* must be zero */
};
-#define XFS_IREQ_FLAGS_ALL (0)
+/*
+ * The @ino value is a special value, not a literal inode number. See the
+ * XFS_IREQ_SPECIAL_* values below.
+ */
+#define XFS_IREQ_SPECIAL (1 << 0)
+
+#define XFS_IREQ_FLAGS_ALL (XFS_IREQ_SPECIAL)
+
+/* Operate on the root directory inode. */
+#define XFS_IREQ_SPECIAL_ROOT (1)
/*
* ioctl structures for v5 bulkstat and inumbers requests
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index f71341cd8340..3bb5f980fabf 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -961,6 +961,16 @@ xfs_ireq_setup(
memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved)))
return -EINVAL;
+ if (hdr->flags & XFS_IREQ_SPECIAL) {
+ switch (hdr->ino) {
+ case XFS_IREQ_SPECIAL_ROOT:
+ hdr->ino = mp->m_sb.sb_rootino;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
if (XFS_INO_TO_AGNO(mp, hdr->ino) >= mp->m_sb.sb_agcount)
return -EINVAL;