strace/utime.c

27 lines
492 B
C
Raw Normal View History

#include "defs.h"
#include DEF_MPERS_TYPE(utimbuf_t)
#include <utime.h>
typedef struct utimbuf utimbuf_t;
#include MPERS_DEFS
SYS_FUNC(utime)
{
utimbuf_t u;
printpath(tcp, tcp->u_arg[0]);
tprints(", ");
if (!umove_or_printaddr(tcp, tcp->u_arg[1], &u)) {
Always print raw values of time data fields Refactor sprinttime: implement sprinttime_nsec and sprinttime_usec that handle nanoseconds and microseconds, respectively. Always print raw values of time data fields, format string representations of time as comments. * defs.h (sprinttime): Change argument type from time_t to long long. (sprinttime_nsec, sprinttime_usec): New prototypes. * util.c (sprinttime_ex, sprinttime_nsec, sprinttime_usec): New functions. (sprinttime): Turn into a thin wrapper around sprinttime_ex. * stat.h (struct strace_stat): Add has_nsec field. * fetch_struct_stat.c (HAVE_NSEC): New macro. (fetch_struct_stat): Initialize has_nsec field with HAVE_NSEC. * fetch_struct_stat64.c (HAVE_NSEC): New macro. (fetch_struct_stat64): Initialize has_nsec field with HAVE_NSEC. * print_struct_stat.c (print_struct_stat) <PRINT_ST_TIME>: Print raw values of time fields, use sprinttime_nsec to format a string representation of time, use tprints_comment to print it as a comment. * statx.c (SYS_FUNC(statx)) <PRINT_FIELD_TIME>: Likewise. * utime.c (SYS_FUNC(utime)): Print raw values of struct utimbuf.actime and struct utimbuf.modtime fields, use sprinttime to format a string representation of time, use tprints_comment to print it as a comment. * tests/tests.h (print_time_t_nsec): Add int argument. * tests/print_time.c (print_time_t_ex): New function. (print_time_t_nsec): Add int argument, turn into a thin wrapper around print_time_t_ex. * tests/utime.c (main): Update expected output. * tests/xstatx.c [!IS_STATX] (HAVE_NSEC): New macro. [!IS_STATX] (PRINT_ST_TIME), [IS_STATX] (PRINT_FIELD_TIME): Update expected output. * NEWS: Mention this timestamps representation improvement. Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-04-21 06:16:12 +03:00
tprintf("{actime=%lld", (long long) u.actime);
tprints_comment(sprinttime(u.actime));
tprintf(", modtime=%lld", (long long) u.modtime);
tprints_comment(sprinttime(u.modtime));
tprints("}");
}
return RVAL_DECODED;
}