From: David Howells <dhowells@redhat.com>
To: viro@zeniv.linux.org.uk
Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 5/6] vfs: Adjust fsinfo sample output
Date: Tue, 21 Aug 2018 10:55:30 +0100 [thread overview]
Message-ID: <153484533075.1183.12355648565791228863.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk>
Adjust the output of the test-fsinfo sample program to:
(1) Print server addresses if of AF_INET or AF_INET6 family.
(2) Not print parameter descriptions (the test-fs-query sample program can
be used for that).
(3) Only print non-blank parameter values so that parameters that just
encode defaults don't clutter up the output.
Signed-off-by: David Howells <dhowells@redhat.com>
---
samples/statx/test-fsinfo.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/samples/statx/test-fsinfo.c b/samples/statx/test-fsinfo.c
index 21714ef7ef5b..c08978acf08b 100644
--- a/samples/statx/test-fsinfo.c
+++ b/samples/statx/test-fsinfo.c
@@ -26,6 +26,7 @@
#include <linux/fsinfo.h>
#include <linux/socket.h>
#include <sys/stat.h>
+#include <arpa/inet.h>
static bool debug = 0;
@@ -304,6 +305,24 @@ static void dump_attr_VOLUME_UUID(union reply *r, int size)
static void dump_attr_SERVER_ADDRESS(union reply *r, int size)
{
struct fsinfo_server_address *f = &r->srv_addr;
+ struct sockaddr_in6 *sin6;
+ struct sockaddr_in *sin;
+ char buf[1024];
+
+ switch (f->address.ss_family) {
+ case AF_INET:
+ sin = (struct sockaddr_in *)&f->address;
+ if (!inet_ntop(AF_INET, &sin->sin_addr, buf, sizeof(buf)))
+ break;
+ printf("IPv4: %s\n", buf);
+ return;
+ case AF_INET6:
+ sin6 = (struct sockaddr_in6 *)&f->address;
+ if (!inet_ntop(AF_INET6, &sin6->sin6_addr, buf, sizeof(buf)))
+ break;
+ printf("IPv6: %s\n", buf);
+ return;
+ }
printf("family=%u\n", f->address.ss_family);
}
@@ -426,6 +445,17 @@ static int try_one(const char *file, struct fsinfo_params *params, bool raw)
return 0;
}
+ switch (params->request) {
+ case FSINFO_ATTR_PARAM_DESCRIPTION:
+ case FSINFO_ATTR_PARAM_SPECIFICATION:
+ case FSINFO_ATTR_PARAM_NAME:
+ case FSINFO_ATTR_PARAM_ENUM:
+ return 0;
+ case FSINFO_ATTR_PARAMETER:
+ if (ret == 0)
+ return 0;
+ }
+
switch (about & 0xc000) {
case 0x0000:
printf("\e[33m%s\e[m: ",
next prev parent reply other threads:[~2018-08-21 9:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-21 9:54 vfs: Fixes/adjustments for mount API stuff David Howells
2018-08-21 9:55 ` [PATCH 1/6] vfs: Fix vfs_dup_fs_context() David Howells
2018-08-21 9:55 ` [PATCH 2/6] vfs: Fix fs_context logging when there's no log David Howells
2018-08-21 9:55 ` [PATCH 3/6] afs: Move the source fs parameter to the first position David Howells
2018-08-21 9:55 ` [PATCH 4/6] vfs: Pass path info fsinfo and rename get_fsinfo sb op to fsinfo David Howells
2018-08-21 9:55 ` David Howells [this message]
2018-08-21 9:55 ` [PATCH 6/6] proc: Set correct userns for new proc super created by a new pid_namespace David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=153484533075.1183.12355648565791228863.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).