[PATCH 5/5] samples: extend test-fsinfo to access error_state

From: Jeff Layton
Date: Mon Jun 04 2018 - 14:03:21 EST


From: Jeff Layton <jlayton@xxxxxxxxxx>

Add support for error_state struct to test-fsinfo sample program.

Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
samples/statx/test-fsinfo.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/samples/statx/test-fsinfo.c b/samples/statx/test-fsinfo.c
index 9d70c422da11..b383a6ec81a0 100644
--- a/samples/statx/test-fsinfo.c
+++ b/samples/statx/test-fsinfo.c
@@ -60,6 +60,7 @@ static const __u8 fsinfo_buffer_sizes[fsinfo_attr__nr] = {
FSINFO_STRING (name_encoding),
FSINFO_STRING (name_codepage),
FSINFO_STRUCT (io_size),
+ FSINFO_STRUCT (error_state),
};

#define FSINFO_NAME(N) [fsinfo_attr_##N] = #N
@@ -84,6 +85,7 @@ static const char *fsinfo_attr_names[fsinfo_attr__nr] = {
FSINFO_NAME(name_encoding),
FSINFO_NAME(name_codepage),
FSINFO_NAME(io_size),
+ FSINFO_NAME(error_state),
};

union reply {
@@ -98,6 +100,7 @@ union reply {
struct fsinfo_volume_uuid uuid;
struct fsinfo_server_address srv_addr;
struct fsinfo_io_size io_size;
+ struct fsinfo_error_state error_state;
};

static void dump_hex(unsigned int *data, int from, int to)
@@ -303,6 +306,15 @@ static void dump_attr_io_size(union reply *r, int size)
printf("bs=%u\n", f->block_size);
}

+static void dump_attr_error_state(union reply *r, int size)
+{
+ struct fsinfo_error_state *f = &r->error_state;
+
+ printf("err_cookie=0x%x err_last=%u\n",
+ f->wb_error_cookie,
+ f->wb_error_last);
+}
+
/*
*
*/
@@ -320,6 +332,7 @@ static const dumper_t fsinfo_attr_dumper[fsinfo_attr__nr] = {
FSINFO_DUMPER(volume_uuid),
FSINFO_DUMPER(server_address),
FSINFO_DUMPER(io_size),
+ FSINFO_DUMPER(error_state),
};

static void dump_fsinfo(enum fsinfo_attribute attr, __u8 about,
--
2.17.0