From 8fa209cf0a39037a923448a9e09a66c657314e9d Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Thu, 22 Feb 2018 00:24:16 +0100
Subject: [PATCH] btrfs: print struct btrfs_ioctl_logical_ino_args.reserved if
 non-zero

* btrfs.c (btrfs_ioctl) <case BTRFS_IOC_LOGICAL_INO>: Print
struct btrfs_ioctl_logical_ino_args.reserved field if it is not zero.
* tests/btrfs.c (btrfs_test_ino_path_ioctls): Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
---
 btrfs.c       |  9 +++++++++
 tests/btrfs.c | 13 +++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/btrfs.c b/btrfs.c
index c236a05c..ff10d69a 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -955,6 +955,15 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl,
 			tprintf("logical=%" PRI__u64 ", size=%" PRI__u64,
 				args.logical, args.size);
 
+			if (!IS_ARRAY_ZERO(args.reserved)) {
+				tprints(", reserved=[");
+				for (size_t i = 0; i < 3; ++i)
+					tprintf("%s%#" PRI__x64,
+						i ? ", " : "",
+						args.reserved[i]);
+				tprints("]");
+			}
+
 			tprintf(", flags=");
 			printflags64(btrfs_logical_ino_args_flags,
 #ifdef HAVE_STRUCT_BTRFS_IOCTL_LOGICAL_INO_ARGS_FLAGS
diff --git a/tests/btrfs.c b/tests/btrfs.c
index 1ff5eecd..16a1ebf5 100644
--- a/tests/btrfs.c
+++ b/tests/btrfs.c
@@ -1160,6 +1160,11 @@ btrfs_test_ino_path_ioctls(void)
 	struct btrfs_ioctl_ino_path_args args = {
 		.inum = 256,
 		.size = sizeof(buf),
+		.reserved = {
+			0xdeadc0defacefeebULL,
+			0xdeadc0defacefeecULL,
+			0xdeadc0defacefeedULL,
+		},
 		.fspath = 0,
 	};
 
@@ -1193,12 +1198,15 @@ btrfs_test_ino_path_ioctls(void)
 	args.fspath = 0;
 	ioctl(-1, BTRFS_IOC_LOGICAL_INO, &args);
 	printf("ioctl(-1, BTRFS_IOC_LOGICAL_INO, {logical=%" PRI__u64
-	       ", size=%" PRI__u64
+	       ", size=%" PRI__u64 ", reserved=[0xdeadc0defacefeeb"
+	       ", 0xdeadc0defacefeec, 0xdeadc0defacefeed]"
 	       ", flags=0xdeadc0defacefeee /* BTRFS_LOGICAL_INO_ARGS_??? */"
 	       ", inodes=NULL}) = -1 EBADF (%m)\n",
 	       args.inum, args.size);
 
 	args.fspath = (uintptr_t) buf;
+	args.reserved[0] = 0;
+	args.reserved[2] = 0;
 #ifdef HAVE_BTRFS_IOCTL_LOGICAL_INO_ARGS
 	args.flags =
 #else
@@ -1208,11 +1216,12 @@ btrfs_test_ino_path_ioctls(void)
 
 	ioctl(-1, BTRFS_IOC_LOGICAL_INO, &args);
 	printf("ioctl(-1, BTRFS_IOC_LOGICAL_INO, {logical=%" PRI__u64
-	       ", size=%" PRI__u64
+	       ", size=%" PRI__u64 ", reserved=[0, 0xdeadc0defacefeec, 0]"
 	       ", flags=BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET"
 	       ", inodes=0x%" PRI__x64 "}) = -1 EBADF (%m)\n",
 	       args.inum, args.size, args.fspath);
 
+	args.reserved[1] = 0;
 #ifdef HAVE_BTRFS_IOCTL_LOGICAL_INO_ARGS
 	args.flags =
 #else