summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2018-05-07 08:40:02 +0200
committerDmitry V. Levin <ldv@altlinux.org>2018-06-06 15:10:37 +0000
commitbdc6ca9e5665bf8543b45a11afcb2fa48fa5d07b (patch)
tree484bbf6859f2788b32e82892c09ca8e42603ba9c
parentdbc5d26b29a15721884c53467fed16f30716e2f9 (diff)
downloadstrace-bdc6ca9e5665bf8543b45a11afcb2fa48fa5d07b.tar.gz
nlattr: introduce decode_nla_flags
Similar to decode_nla_xval. * nlattr.c (decode_nla_flags): New function. * nlattr.h: (DECL_NLA(flags)): New declaration.
-rw-r--r--nlattr.c26
-rw-r--r--nlattr.h1
2 files changed, 27 insertions, 0 deletions
diff --git a/nlattr.c b/nlattr.c
index f65d9cf6a..835cf25e5 100644
--- a/nlattr.c
+++ b/nlattr.c
@@ -296,6 +296,32 @@ decode_nla_ip_proto(struct tcb *const tcp,
}
bool
+decode_nla_flags(struct tcb *const tcp,
+ const kernel_ulong_t addr,
+ const unsigned int len,
+ const void *const opaque_data)
+{
+ const struct decode_nla_xlat_opts * const opts = opaque_data;
+ union {
+ uint64_t flags;
+ uint8_t bytes[sizeof(uint64_t)];
+ } data = { .flags = 0 };
+ const size_t bytes_offs = is_bigendian ? sizeof(data) - len : 0;
+
+ if (opts->xt == XT_INDEXED)
+ error_func_msg("indexed xlats are currently incompatible with "
+ "printflags");
+
+ if (len > sizeof(data))
+ return false;
+ else if (!umoven_or_printaddr(tcp, addr, len, data.bytes + bytes_offs))
+ printflags_ex(data.flags, opts->dflt, opts->style, opts->xlat,
+ NULL);
+
+ return true;
+}
+
+bool
decode_nla_be16(struct tcb *const tcp,
const kernel_ulong_t addr,
const unsigned int len,
diff --git a/nlattr.h b/nlattr.h
index 765aba823..fc7a67d92 100644
--- a/nlattr.h
+++ b/nlattr.h
@@ -75,6 +75,7 @@ DECL_NLA(s64);
DECL_NLA(be16);
DECL_NLA(be64);
DECL_NLA(xval);
+DECL_NLA(flags);
DECL_NLA(str);
DECL_NLA(strn);
DECL_NLA(fd);