@@ -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;
}
@@ -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,
@@ -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);
@@ -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];
}
/*
@@ -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);