Commit Graph

6 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
9d095c7860 Add copyright headers 2017-05-22 17:33:51 +00:00
Eugene Syromyatnikov
3277a2370a 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-24 23:14:57 +00:00
889012d4b5 print_struct_stat.c: macroize printing of atime, mtime, and ctime fields
Introduce a macro for printing similar time related fields.

* print_struct_stat.c (PRINT_ST_TIME): New macro.
(print_struct_stat): Use it.
2017-02-26 19:14:34 +00:00
Eugene Syromyatnikov
32e813144c Move device number printing code into a separate routine
* print_dev_t.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (print_dev_t): New prototype.
* dm.c: Do not include <sys/sysmacros.h>.
(dm_decode_device, dm_print_dev, dm_decode_dm_name_list): Use
print_dev_t function for printing device numbers.
* mknod.c: Do not include <sys/sysmacros.h>.
(decode_mknod): Use print_dev_t function for printing device number.
* print_struct_stat.c: Do not include <sys/sysmacros.h>.
(print_struct_stat): Use print_dev_t function for printing device
numbers.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2016-12-29 00:11:24 +00:00
50608a4098 Do not use AC_HEADER_MAJOR, include <sys/sysmacros.h> unconditionally
glibc, starting with commit glibc-2.24-28-gdbab657, has deprecated
inclusion of <sys/sysmacros.h> by <sys/types.h>.  The method used
for deprecation breaks AC_HEADER_MAJOR: this autoconf macro no longer
defines MAJOR_IN_SYSMACROS, which consequently breaks build.

Let's assume that all systems supported by strace provide major, minor,
and makedev macros via <sys/sysmacros.h>.

* configure.ac (AC_HEADER_MAJOR): Remove.
* mknod.c [MAJOR_IN_SYSMACROS, MAJOR_IN_MKDEV]: Remove.
Include <sys/sysmacros.h> unconditionally.
* print_struct_stat.c: Likewise.
* tests/mknod.c: Likewise.
* tests/mknodat.c: Likewise.
* tests/xstatx.c: Likewise.
2016-08-29 15:36:02 +00:00
a7c4ee41ff Mpersify parsers of struct stat and struct stat64
On many architectures that support multiple personalities,
struct stat differ between personalities.  While old code could handle
these differences, there are some architectures, e.g. sparc64, that also
have different struct stat64.  Rewrite parsers using mpers functionality
to fix these issues.

* fetch_struct_stat.c: New file.
* fetch_struct_stat64.c: Likewise.
* print_struct_stat.c: Likewise.
* oldstat.c: Likewise.
* stat.c: Likewise.
* stat.h: Likewise.
* stat64.c: Likewise.
* file.c: Remove.
* printstat.h: Likewise.
* linux/aarch64/stat32.h: Likewise.
* linux/powerpc64/stat32.h: Likewise.
* linux/riscv/stat32.h: Likewise.
* linux/sparc64/stat32.h: Likewise.
* linux/tile/stat32.h: Likewise.
* linux/x32/stat32.h: Likewise.
* linux/x86_64/stat32.h: Likewise.
* Makefile.am (strace_SOURCES): Add fetch_struct_stat.c,
fetch_struct_stat64.c, print_struct_stat.c, oldstat.c, stat.c, stat.h,
and stat64.c.  Remove file.c, printstat.h, linux/aarch64/stat32.h,
linux/powerpc64/stat32.h, linux/riscv/stat32.h, linux/sparc64/stat32.h,
linux/tile/stat32.h, linux/x32/stat32.h, and linux/x86_64/stat32.h.
* configure.ac (AC_CHECK_MEMBERS): Add struct stat64.st_mtime_nsec.
* defs.h (struct strace_stat): New declaration.
(print_struct_stat): New prototype.
* linux/dummy.h (sys_fstatat64): Remove.
2016-08-24 15:32:10 +00:00