diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2018-05-07 08:40:02 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2018-06-06 15:10:37 +0000 |
commit | bdc6ca9e5665bf8543b45a11afcb2fa48fa5d07b (patch) | |
tree | 484bbf6859f2788b32e82892c09ca8e42603ba9c | |
parent | dbc5d26b29a15721884c53467fed16f30716e2f9 (diff) | |
download | strace-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.c | 26 | ||||
-rw-r--r-- | nlattr.h | 1 |
2 files changed, 27 insertions, 0 deletions
@@ -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, @@ -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); |