From: "Dr. David Alan Gilbert" <linux@xxxxxxxxxxx> 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") Signed-off-by: Dr. David Alan Gilbert <linux@xxxxxxxxxxx> --- man/man2/ioctl_xfs_getparents.2 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/man/man2/ioctl_xfs_getparents.2 b/man/man2/ioctl_xfs_getparents.2 index 5bb9b96a..63926016 100644 --- a/man/man2/ioctl_xfs_getparents.2 +++ b/man/man2/ioctl_xfs_getparents.2 @@ -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; } -- 2.50.1