Skip to contentSkip to conversation

man: Fix XFS_IOC_GETPARENTS ioctl example

PATCH In review [email protected] 2 participants 2 messages Aug 16, 2025 – Aug 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 man: Fix XFS_IOC_GETPARENTS ioctl example

From: "Dr. David Alan Gilbert" <[email protected]>

Fix various typos that stopped the example building. Add perror calls everywhere so it doesn't fail silently and mysteriously.

Now builds cleanly with -Wpedantic.

Fixes a24294c2 ("man: document the XFS_IOC_GETPARENTS ioctl")
---
 man/man2/ioctl_xfs_getparents.2 | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
man/man2/ioctl_xfs_getparents.2 +11 -7
index 5bb9b96a..63926016 100644
@@ -119,7 +119,7 @@ If the name is a zero-length string, the file queried has no parents.
 Calling programs should allocate a large memory buffer, initialize the head
 structure to zeroes, set gp_bufsize to the size of the buffer, and call the
 ioctl.
-The XFS_GETPARENTS_OFLAG_DONE flag will be set in gp_flags when there are no
+The XFS_GETPARENTS_OFLAG_DONE flag will be set in gp_oflags when there are no
 more parent pointers to be read.
 The below code is an example of XFS_IOC_GETPARENTS usage:
 
@@ -142,16 +142,20 @@ int main() {
 		perror("malloc");
 		return 1;
 	}
-	gp->gp_bufsize = 65536;
+	gp.gp_bufsize = 65536;
 
-	fd = open("/mnt/test/foo.txt", O_RDONLY | O_CREAT);
-	if (fd  == -1)
+	fd = open("/mnt/test/foo.txt", O_RDONLY | O_CREAT, 0666);
+	if (fd  == -1) {
+    perror("open");
 		return errno;
+  }
 
 	do {
-		error = ioctl(fd, XFS_IOC_GETPARENTS, gp);
-		if (error)
+		error = ioctl(fd, XFS_IOC_GETPARENTS, &gp);
+		if (error) {
+      perror("ioctl");
 			return error;
+    }
 
 		for (gpr = xfs_getparents_first_rec(&gp);
 		     gpr != NULL;
@@ -166,7 +170,7 @@ int main() {
 			printf("name		= \\"%s\\"\\n\\n",
 					gpr->gpr_name);
 		}
-	} while (!(gp.gp_flags & XFS_GETPARENTS_OFLAG_DONE));
+	} while (!(gp.gp_oflags & XFS_GETPARENTS_OFLAG_DONE));
 
 	return 0;
 }
Signature · 1 line
2.50.1
#1 lore raw
Quoted 31 lines · On Sat, Aug 16, 2025 at 01:28:42AM +0100, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

Fix various typos that stopped the example building. Add perror calls everywhere so it doesn't fail silently and mysteriously.

Now builds cleanly with -Wpedantic.

Fixes a24294c2 ("man: document the XFS_IOC_GETPARENTS ioctl")
---
 man/man2/ioctl_xfs_getparents.2 | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
man/man2/ioctl_xfs_getparents.2 +1 -1
index 5bb9b96a..63926016 100644
@@ -119,7 +119,7 @@ If the name is a zero-length string, the file queried has no parents.
 Calling programs should allocate a large memory buffer, initialize the head
 structure to zeroes, set gp_bufsize to the size of the buffer, and call the
 ioctl.
-The XFS_GETPARENTS_OFLAG_DONE flag will be set in gp_flags when there are no
+The XFS_GETPARENTS_OFLAG_DONE flag will be set in gp_oflags when there are no
 more parent pointers to be read.
 The below code is an example of XFS_IOC_GETPARENTS usage:
 
@@ -142,16 +142,20 @@ int main() {
 		perror("malloc");
 		return 1;
 	}

man/man2/ioctl_xfs_getparents.2 int main() { · line 151

Quoted 10 lines
man/man2/ioctl_xfs_getparents.2 +5 -3
-	gp->gp_bufsize = 65536;
+	gp.gp_bufsize = 65536;
 
-	fd = open("/mnt/test/foo.txt", O_RDONLY | O_CREAT);
-	if (fd  == -1)
+	fd = open("/mnt/test/foo.txt", O_RDONLY | O_CREAT, 0666);
+	if (fd  == -1) {
+    perror("open");
 		return errno;
+  }

Formatting looks really weird here, probably because of a mix of tabs and space an different tabstop settings for the original version of the code and your edits.

The technical changes look good to me.