[PATCH] msghdr: print SCM_TIMESTAMP* control messages
Dmitry V. Levin
ldv at altlinux.org
Thu Jun 15 08:43:37 UTC 2017
On Thu, Jun 15, 2017 at 10:06:47AM +0200, Miroslav Lichvar wrote:
> On Wed, Jun 14, 2017 at 07:05:07PM +0300, Dmitry V. Levin wrote:
> > On Wed, Jun 14, 2017 at 04:23:31PM +0200, Miroslav Lichvar wrote:
> > > @@ -191,7 +224,10 @@ static const struct {
> > > } cmsg_socket_printers[] = {
> > > [SCM_RIGHTS] = { print_scm_rights, sizeof(int) },
> > > [SCM_CREDENTIALS] = { print_scm_creds, sizeof(struct ucred) },
> > > - [SCM_SECURITY] = { print_scm_security, 1 }
> > > + [SCM_SECURITY] = { print_scm_security, 1 },
> > > + [SCM_TIMESTAMP] = { print_scm_timestamp, sizeof(struct timeval) },
> > > + [SCM_TIMESTAMPNS] = { print_scm_timestampns, sizeof(struct timespec) },
> > > + [SCM_TIMESTAMPING] = { print_scm_timestamping, 3 * sizeof(struct timespec) }
> >
> > As these sizes vary between personalities, I'm afraid this is not correct.
> > In fact, your own test fails for x86 personality on x86_64, you can see
> > this if you build strace in a system with -m32 runtime support (configure
> > output should contain "checking for -m32 runtime support... yes").
>
> Ok. I guess I need to add new printing functions and check the length
> there, but I'm not sure how to name them. Would the following work?
>
> MPERS_PRINTER_DECL(void, print_timeval_data,
> const void *arg, const size_t size)
> MPERS_PRINTER_DECL(void, print_timespec_data,
> const void *arg, const size_t size)
> MPERS_PRINTER_DECL(void, print_timespec_array, const void *arg,
> const unsigned int nmemb, const size_t size)
If they were regular pure printers, nowadays they would be called
- print_struct_timeval,
- print_struct_timespec,
- print_struct_timespec_array
In fact, print_struct_timeval already exists and does exactly that.
If you are going to add modifications of these functions that also accept
data length along with data pointer, ideally this should be reflected
in their name, e.g. print_struct_timeval_data_size.
What do you think these functions should print in case the data size
is smaller than necessary?
A side note: new SCM_* constants are arch-specific.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170615/a9456dcf/attachment.bin>
More information about the Strace-devel
mailing list