[PATCH 1/3] xfs: rename xfs_pptr_info to xfs_getparents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Rename the head structure of the parent pointer ioctl to match the name
of the ioctl (XFS_IOC_GETPARENTS).

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 io/parent.c       |    4 ++--
 libfrog/pptrs.c   |   28 ++++++++++++++--------------
 libfrog/pptrs.h   |    2 +-
 libxfs/xfs_fs.h   |   51 ++++++++++++++++++++++++++-------------------------
 man/man3/xfsctl.3 |   16 ++++++++--------
 5 files changed, 51 insertions(+), 50 deletions(-)


diff --git a/io/parent.c b/io/parent.c
index 36522f26..1c1453f2 100644
--- a/io/parent.c
+++ b/io/parent.c
@@ -24,14 +24,14 @@ struct pptr_args {
 
 static int
 pptr_print(
-	struct xfs_pptr_info	*pi,
+	struct xfs_getparents	*pi,
 	struct xfs_parent_ptr	*pptr,
 	void			*arg)
 {
 	struct pptr_args	*args = arg;
 	unsigned int		namelen;
 
-	if (pi->pi_flags & XFS_PPTR_OFLAG_ROOT) {
+	if (pi->gp_flags & XFS_GETPARENTS_OFLAG_ROOT) {
 		printf(_("Root directory.\n"));
 		return 0;
 	}
diff --git a/libfrog/pptrs.c b/libfrog/pptrs.c
index 61fd1fb9..3bb441f0 100644
--- a/libfrog/pptrs.c
+++ b/libfrog/pptrs.c
@@ -12,17 +12,17 @@
 #include "libfrog/pptrs.h"
 
 /* Allocate a buffer large enough for some parent pointer records. */
-static inline struct xfs_pptr_info *
+static inline struct xfs_getparents *
 alloc_pptr_buf(
 	size_t			nr_ptrs)
 {
-	struct xfs_pptr_info	*pi;
+	struct xfs_getparents	*pi;
 
-	pi = malloc(xfs_pptr_info_sizeof(nr_ptrs));
+	pi = malloc(xfs_getparents_sizeof(nr_ptrs));
 	if (!pi)
 		return NULL;
-	memset(pi, 0, sizeof(struct xfs_pptr_info));
-	pi->pi_ptrs_size = nr_ptrs;
+	memset(pi, 0, sizeof(struct xfs_getparents));
+	pi->gp_ptrs_size = nr_ptrs;
 	return pi;
 }
 
@@ -37,7 +37,7 @@ handle_walk_parents(
 	walk_pptr_fn		fn,
 	void			*arg)
 {
-	struct xfs_pptr_info	*pi;
+	struct xfs_getparents	*pi;
 	struct xfs_parent_ptr	*p;
 	unsigned int		i;
 	ssize_t			ret = -1;
@@ -47,25 +47,25 @@ handle_walk_parents(
 		return errno;
 
 	if (handle) {
-		memcpy(&pi->pi_handle, handle, sizeof(struct xfs_handle));
-		pi->pi_flags = XFS_PPTR_IFLAG_HANDLE;
+		memcpy(&pi->gp_handle, handle, sizeof(struct xfs_handle));
+		pi->gp_flags = XFS_GETPARENTS_IFLAG_HANDLE;
 	}
 
 	ret = ioctl(fd, XFS_IOC_GETPARENTS, pi);
 	while (!ret) {
-		if (pi->pi_flags & XFS_PPTR_OFLAG_ROOT) {
+		if (pi->gp_flags & XFS_GETPARENTS_OFLAG_ROOT) {
 			ret = fn(pi, NULL, arg);
 			goto out_pi;
 		}
 
-		for (i = 0; i < pi->pi_ptrs_used; i++) {
-			p = xfs_ppinfo_to_pp(pi, i);
+		for (i = 0; i < pi->gp_ptrs_used; i++) {
+			p = xfs_getparents_rec(pi, i);
 			ret = fn(pi, p, arg);
 			if (ret)
 				goto out_pi;
 		}
 
-		if (pi->pi_flags & XFS_PPTR_OFLAG_DONE)
+		if (pi->gp_flags & XFS_GETPARENTS_OFLAG_DONE)
 			break;
 
 		ret = ioctl(fd, XFS_IOC_GETPARENTS, pi);
@@ -128,7 +128,7 @@ static int handle_walk_parent_paths(struct walk_ppaths_info *wpi,
 
 static int
 handle_walk_parent_path_ptr(
-	struct xfs_pptr_info		*pi,
+	struct xfs_getparents		*pi,
 	struct xfs_parent_ptr		*p,
 	void				*arg)
 {
@@ -136,7 +136,7 @@ handle_walk_parent_path_ptr(
 	struct walk_ppaths_info		*wpi = wpli->wpi;
 	int				ret = 0;
 
-	if (pi->pi_flags & XFS_PPTR_OFLAG_ROOT)
+	if (pi->gp_flags & XFS_GETPARENTS_OFLAG_ROOT)
 		return wpi->fn(wpi->mntpt, wpi->path, wpi->arg);
 
 	ret = path_component_change(wpli->pc, p->xpp_name,
diff --git a/libfrog/pptrs.h b/libfrog/pptrs.h
index 1666de06..ab1d0f2f 100644
--- a/libfrog/pptrs.h
+++ b/libfrog/pptrs.h
@@ -8,7 +8,7 @@
 
 struct path_list;
 
-typedef int (*walk_pptr_fn)(struct xfs_pptr_info *pi,
+typedef int (*walk_pptr_fn)(struct xfs_getparents *pi,
 		struct xfs_parent_ptr *pptr, void *arg);
 typedef int (*walk_ppath_fn)(const char *mntpt, struct path_list *path,
 		void *arg);
diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h
index c65345d2..2a23c010 100644
--- a/libxfs/xfs_fs.h
+++ b/libxfs/xfs_fs.h
@@ -752,19 +752,20 @@ struct xfs_scrub_metadata {
 				 XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED)
 #define XFS_SCRUB_FLAGS_ALL	(XFS_SCRUB_FLAGS_IN | XFS_SCRUB_FLAGS_OUT)
 
-#define XFS_PPTR_MAXNAMELEN				256
+#define XFS_GETPARENTS_MAXNAMELEN	256
 
 /* return parents of the handle, not the open fd */
-#define XFS_PPTR_IFLAG_HANDLE  (1U << 0)
+#define XFS_GETPARENTS_IFLAG_HANDLE	(1U << 0)
 
 /* target was the root directory */
-#define XFS_PPTR_OFLAG_ROOT    (1U << 1)
+#define XFS_GETPARENTS_OFLAG_ROOT	(1U << 1)
 
 /* Cursor is done iterating pptrs */
-#define XFS_PPTR_OFLAG_DONE    (1U << 2)
+#define XFS_GETPARENTS_OFLAG_DONE	(1U << 2)
 
- #define XFS_PPTR_FLAG_ALL     (XFS_PPTR_IFLAG_HANDLE | XFS_PPTR_OFLAG_ROOT | \
-				XFS_PPTR_OFLAG_DONE)
+#define XFS_GETPARENTS_FLAG_ALL		(XFS_GETPARENTS_IFLAG_HANDLE | \
+					 XFS_GETPARENTS_OFLAG_ROOT | \
+					 XFS_GETPARENTS_OFLAG_DONE)
 
 /* Get an inode parent pointer through ioctl */
 struct xfs_parent_ptr {
@@ -772,57 +773,57 @@ struct xfs_parent_ptr {
 	__u32		xpp_gen;			/* Inode generation */
 	__u32		xpp_rsvd;			/* Reserved */
 	__u64		xpp_rsvd2;			/* Reserved */
-	__u8		xpp_name[XFS_PPTR_MAXNAMELEN];	/* File name */
+	__u8		xpp_name[XFS_GETPARENTS_MAXNAMELEN];	/* File name */
 };
 
 /* Iterate through an inodes parent pointers */
-struct xfs_pptr_info {
-	/* File handle, if XFS_PPTR_IFLAG_HANDLE is set */
-	struct xfs_handle		pi_handle;
+struct xfs_getparents {
+	/* File handle, if XFS_GETPARENTS_IFLAG_HANDLE is set */
+	struct xfs_handle		gp_handle;
 
 	/*
 	 * Structure to track progress in iterating the parent pointers.
 	 * Must be initialized to zeroes before the first ioctl call, and
 	 * not touched by callers after that.
 	 */
-	struct xfs_attrlist_cursor	pi_cursor;
+	struct xfs_attrlist_cursor	gp_cursor;
 
-	/* Operational flags: XFS_PPTR_*FLAG* */
-	__u32				pi_flags;
+	/* Operational flags: XFS_GETPARENTS_*FLAG* */
+	__u32				gp_flags;
 
 	/* Must be set to zero */
-	__u32				pi_reserved;
+	__u32				gp_reserved;
 
 	/* # of entries in array */
-	__u32				pi_ptrs_size;
+	__u32				gp_ptrs_size;
 
 	/* # of entries filled in (output) */
-	__u32				pi_ptrs_used;
+	__u32				gp_ptrs_used;
 
 	/* Must be set to zero */
-	__u64				pi_reserved2[6];
+	__u64				gp_reserved2[6];
 
 	/*
 	 * An array of struct xfs_parent_ptr follows the header
-	 * information. Use xfs_ppinfo_to_pp() to access the
+	 * information. Use xfs_getparents_rec() to access the
 	 * parent pointer array entries.
 	 */
-	struct xfs_parent_ptr		pi_parents[];
+	struct xfs_parent_ptr		gp_parents[];
 };
 
 static inline size_t
-xfs_pptr_info_sizeof(int nr_ptrs)
+xfs_getparents_sizeof(int nr_ptrs)
 {
-	return sizeof(struct xfs_pptr_info) +
+	return sizeof(struct xfs_getparents) +
 	       (nr_ptrs * sizeof(struct xfs_parent_ptr));
 }
 
 static inline struct xfs_parent_ptr*
-xfs_ppinfo_to_pp(
-	struct xfs_pptr_info	*info,
-	int			idx)
+xfs_getparents_rec(
+	struct xfs_getparents	*info,
+	unsigned int		idx)
 {
-	return &info->pi_parents[idx];
+	return &info->gp_parents[idx];
 }
 
 /*
diff --git a/man/man3/xfsctl.3 b/man/man3/xfsctl.3
index 42ba3bba..0bcf8886 100644
--- a/man/man3/xfsctl.3
+++ b/man/man3/xfsctl.3
@@ -326,12 +326,12 @@ XFS_IOC_FSSETDM_BY_HANDLE is not supported as of Linux 5.5.
 .B XFS_IOC_GETPARENTS
 This command is used to get a files parent pointers.  Parent pointers are
 file attributes used to store meta data information about an inodes parent.
-This command takes a xfs_pptr_info structure with trailing array of
+This command takes a xfs_getparents structure with trailing array of
 struct xfs_parent_ptr as an input to store an inodes parents. The
-xfs_pptr_info_sizeof() and xfs_ppinfo_to_pp() routines are provided to
+xfs_getparents_sizeof() and xfs_getparents_rec() routines are provided to
 create and iterate through these structures.  The number of pointers stored
-in the array is indicated by the xfs_pptr_info.used field, and the
-XFS_PPTR_OFLAG_DONE flag will be set in xfs_pptr_info.flags when there are
+in the array is indicated by the xfs_getparents.used field, and the
+XFS_PPTR_OFLAG_DONE flag will be set in xfs_getparents.flags when there are
 no more parent pointers to be read.  The below code is an example
 of XFS_IOC_GETPARENTS usage:
 
@@ -345,13 +345,13 @@ of XFS_IOC_GETPARENTS usage:
 #include<xfs/xfs_fs.h>
 
 int main() {
-	struct xfs_pptr_info	*pi;
+	struct xfs_getparents	*pi;
 	struct xfs_parent_ptr	*p;
 	int			i, error, fd, nr_ptrs = 4;
 
-	unsigned char buffer[xfs_pptr_info_sizeof(nr_ptrs)];
+	unsigned char buffer[xfs_getparents_sizeof(nr_ptrs)];
 	memset(buffer, 0, sizeof(buffer));
-	pi = (struct xfs_pptr_info *)&buffer;
+	pi = (struct xfs_getparents *)&buffer;
 	pi->pi_ptrs_size = nr_ptrs;
 
 	fd = open("/mnt/test/foo.txt", O_RDONLY | O_CREAT);
@@ -364,7 +364,7 @@ int main() {
 			return error;
 
 		for (i = 0; i < pi->pi_ptrs_used; i++) {
-			p = xfs_ppinfo_to_pp(pi, i);
+			p = xfs_getparents_rec(pi, i);
 			printf("inode		= %llu\\n", (unsigned long long)p->xpp_ino);
 			printf("generation	= %u\\n", (unsigned int)p->xpp_gen);
 			printf("name		= \\"%s\\"\\n\\n", (char *)p->xpp_name);




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux