Commit Graph

244 Commits

Author SHA1 Message Date
c37173f76d aarch64: swap 64-bit and 32-bit personalities
Let native 64-bit personality be personality 0, and 32-bit personality
be personality 1, to follow the traditional layout used for other
architectures.

* defs.h [AARCH64]: Swap PERSONALITY0_WORDSIZE and
PERSONALITY1_WORDSIZE, remove DEFAULT_PERSONALITY.
[AARCH64 && HAVE_M32_MPERS]: Rename PERSONALITY1_* to PERSONALITY0_*.
* file.c [AARCH64 || defined X86_64 || defined X32]: Define
STAT32_PERSONALITY for AARCH64 as well.
* syscall.c (update_personality) [AARCH64]: Adjust PERSONALITY_NAMES.
* linux/aarch64/errnoent1.h: Adjust comment.
* linux/aarch64/get_error.c (get_error): Adjust tcp->currpers check.
* linux/aarch64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/arm/arch_sigreturn.c (arch_sigreturn) [AARCH64]: Likewise.
* linux/aarch64/get_scno.c (arch_get_scno): Adjust update_personality
invocations.
* linux/aarch64/ioctls_arch0.h: Swap with ...
* linux/aarch64/ioctls_arch1.h: ... this file.
* linux/aarch64/ioctls_inc0.h: Swap with ...
* linux/aarch64/ioctls_inc1.h: ... this file.
* linux/aarch64/syscallent.h: Swap with ...
* linux/aarch64/syscallent1.h: ... this file.
2015-12-09 01:09:11 +00:00
c31481fc68 Add a wrapper around <asm/stat.h>
* linux/asm_stat.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Use it.
2015-12-04 15:03:12 +00:00
525eed33fa Print nanoseconds along with seconds in stat family syscalls
* configure.ac (AC_CHECK_MEMBERS): Add stat.st_atim.tv_nsec,
stat.st_ctim.tv_nsec, stat.st_mtim.tv_nsec, stat.st_atime_nsec,
stat.st_atime_csec, and stat.st_mtime_nsec.
* file.c: Explicitly define HAVE_STRUCT_STAT_ST_ATIME_NSEC,
HAVE_STRUCT_STAT_ST_CTIME_NSEC and HAVE_STRUCT_STAT_ST_MTIME_NSEC
for locally defined types.
* printstat.h (DO_PRINTSTAT): Print st_atime_nsec, st_ctime_nsec,
and st_mtime_nsec members.
* tests/stat.c [_FILE_OFFSET_BITS == 64]: Use st_atime_nsec,
st_ctime_nsec, and st_mtime_nsec via st_atim.tv_nsec, st_ctim.tv_nsec,
and st_mtim.tv_nsec.
(main): Print st_atime_nsec, st_ctime_nsec, and st_mtime_nsec members.

This fixes Fedora bug #1251176.
2015-08-09 09:19:55 +00:00
b6d80ffe02 file.c: use umove_or_printaddr
* file.c (printstat32, printstatsol): Remove.
(printstat, printstat64, printoldstat): Use umove_or_printaddr.
2015-07-20 22:03:07 +00:00
a0bd3749fc Declare syscall parsers using SYS_FUNC macro
Introduce SYS_FUNC macro to declare and define all syscall parsers.

* Makefile.am (BUILT_SOURCES, CLEANFILES): Add sys_func.h.
(sys_func.h): New rule.
* defs.h (SYS_FUNC_NAME, SYS_FUNC): New macros.
* linux/syscall.h: Include "sys_func.h".
[NEED_UID16_PARSERS]: Use SYS_FUNC to declare uid16 syscall parsers.
Remove other declarations.
* linux/alpha/syscallent.h (160, 161): Add sys_ prefix to osf_statfs
and osf_fstatfs syscall parsers.
* *.c: Use SYS_FUNC to define syscall parsers.
2015-04-07 11:22:49 +00:00
5647cf86fc Use macros for gcc attributes
* defs.h (error_msg, perror_msg, error_msg_and_die, perror_msg_and_die,
die_out_of_memory, printllval, printnum_int, printnum_long, tprintf):
Use ATTRIBUTE_* macros for gcc attributes.
* file.c (struct stat64): Likewise.
* statfs.c (struct compat_statfs64): Likewise.
* strace.c (die, exec_or_die, init): Likewise.
* linux/sparc/arch_sigreturn.c: Likewise.
* linux/ubi-user.h: Likewise.
2015-03-30 00:33:06 +00:00
7b9bc44e63 Use AC_CHECK_TYPES to check for struct stat64
* m4/stat.m4: Remove.
* configure.ac (AC_STAT64): Remove.
(AC_CHECK_TYPES): Add struct stat64.
* file.c: Replace HAVE_STAT64 with HAVE_STRUCT_STAT64.
2015-01-08 04:06:06 +00:00
f19836be02 file.c: fix 32-bit stat decoding on 64-bit architectures
* file.c [SPARC || SPARC64] (struct stat): Remove, use generic
definition from <asm/stat.h>.
[SPARC64] (struct stat_sparc64, printstat_sparc64): Remove.
[AARCH64 || X86_64 || X32 || POWERPC64 || SPARC64] (struct stat32,
STAT32_PERSONALITY): Define.
[STAT32_PERSONALITY] (struct stat_powerpc32): Rename to struct stat32.
[STAT32_PERSONALITY] (printstat_powerpc32): Rename to printstat32.
(printstat) [STAT32_PERSONALITY]: Call printstat32 when
current_personality == STAT32_PERSONALITY.
[HAVE_STAT64] (printstat64) [STAT32_PERSONALITY]: Call printstat when
current_personality != STAT32_PERSONALITY.
[!HAVE_STAT64] (sys_stat64): Fallback to sys_stat.
[!HAVE_STAT64] (sys_fstat64): Fallback to sys_fstat.
2015-01-08 03:34:04 +00:00
e6e475c60e sparc: reuse struct stat parser code for struct solstat decoding
* printstat.h: Parametrize major() and minor().
* file.c [SPARC || SPARC64]: Define do_printstat_sol by instantiating
printstat.h template.
[SPARC || SPARC64] (printstatsol): Use do_printstat_sol.
2015-01-08 03:17:53 +00:00
721de7887a ppc64: reuse struct stat parser code for struct stat_powerpc32 decoding
* file.c [POWERPC64]: Define do_printstat32 by instantiating printstat.h
template.
[POWERPC64] (printstat_powerpc32): Use do_printstat32.
2015-01-08 03:17:28 +00:00
c6ee0ecb5a file.c: group related parsers together
* file.c (sys_stat, sys_fstat): Collect in one place right before
the definition of printstat64.
(sys_stat64, sys_fstat64): Collect in one place right after the
definition of printstat64.
2015-01-08 01:14:53 +00:00
1fb1c13910 file.c: collect scattered __old_kernel_stat related code
* file.c [HAVE_STRUCT___OLD_KERNEL_STAT] (convertoldstat, printoldstat,
sys_oldstat, sys_oldfstat): Collect functions in one place.
2015-01-08 01:14:53 +00:00
b8ad393cec Use the same source code for struct stat/stat64 decoding
* file.c: Define do_printstat64 by instantiating printstat.h template.
(printstat64): Use do_printstat64.
2015-01-08 01:14:53 +00:00
553d8a2ae6 x32: use generic printstat/printstat64 parsers
* file.c (printstat) [X32]: Define.
(printstat64) [X32]: Use "struct stat64" instead of "struct stat".
Use printstat for x32 personality processes.
(printstat64_x32): Remove.
(sys_stat64, sys_fstat64) [X32]: Use printstat64 instead of
printstat64_x32.
2015-01-08 01:14:53 +00:00
8d411080ed x32: remove redundant definitions
* file.c [X32]: Do not define "struct stat" and "struct
__old_kernel_stat" locally, use definitions provided by <asm/stat.h>.
Do not define "struct stat64" exclusively, reuse another definition
added earlier for X86_64.
2015-01-08 01:14:53 +00:00
ab21a9489f Convert do_printstat to a template function
* printstat.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Include "printstat.h".
(do_printstat): Move to printstat.h, parametrize its name
and struct stat.
2015-01-08 01:14:53 +00:00
d01f0a85bc file.c: prepare realprintstat for parametrization
* file.c (realprintstat): Adjust format strings so that all 64-bit
integer fields are printed with %llu format, and %u format is used for
all the rest.  Rename to do_printstat.
(printstat, printoldstat): Update callers.
2015-01-08 01:14:53 +00:00
2928afe3b4 Cleanup struct stat.st_flags decoding
There are no symbolic constants defined for struct stat.st_flags,
so decode this rare field as unsigned int.

* xlat/fileflags.in: Remove.
* file.c (realprintstat, printstat64) [HAVE_STRUCT_STAT_ST_FLAGS]:
Decode struct stat.st_flags as unsigned int.
2015-01-07 22:05:38 +00:00
65ea0d0647 Drop struct stat.st_aclcnt and stat.st_level support
Remove the code that supports struct stat.st_aclcnt and stat.st_level
decoding -- these fields are not defined in system headers.

* configure.ac (AC_CHECK_MEMBERS): Remove struct stat.st_aclcnt and
struct stat.st_level.
* file.c (realprintstat, printstat64)
[HAVE_STRUCT_STAT_ST_ACLCNT || HAVE_STRUCT_STAT_ST_LEVEL]: Remove.
2015-01-07 22:05:38 +00:00
e00a9571d4 sparc: fix fxstat decoding
* file.c [SPARC || SPARC64] (sys_fxstat): Print file descriptor
using printfd.
2014-12-29 03:18:36 +00:00
e6219fbdb1 sparc: drop _STAT64_VER support
Starting with commit v4.6-240-g5afdf12, nobody compiles this
non-Linux code.

* file.c [SPARC || SPARC64] (sys_xstat, sys_fxstat): Remove
_STAT64_VER code.
2014-12-29 03:08:53 +00:00
55ba9b30f0 sparc: remove redundant sys_lxstat
* file.c [SPARC || SPARC64] (sys_lxstat): Remove.
* linux/sparc/dummy2.h (solaris_lxstat): Alias to sys_xstat.
* linux/sparc64/dummy2.h (solaris_lxstat): Likewise.
2014-12-29 03:04:11 +00:00
ea77892aaa file.c: do not include unused headers
* file.c: Do not include <fcntl.h>.
2014-12-28 15:24:21 +00:00
964d80a0f7 file.c: move open, openat, and creat parsers to a separate file
* open.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_open, sys_openat, sys_creat, and related code
to open.c.
2014-12-11 21:40:20 +00:00
304cd81e46 file.c: move access and faccessat parsers to a separate file
* access.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_access, sys_faccessat and related code to access.c.
2014-12-11 21:40:17 +00:00
d590f3cdd8 file.c: move umask parser to a separate file
* umask.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_umask): Move to umask.c.
2014-12-11 21:40:15 +00:00
b5d25ec2f9 file.c: move lseek and llseek parsers to a separate file
* lseek.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_lseek, sys_llseek, and related code to lseek.c.
2014-12-11 21:40:11 +00:00
9e9ceab3b1 file.c: move readahead parser to a separate file
* readahead.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_readahead): Move to readahead.c.
2014-12-11 21:40:08 +00:00
6934182f16 file.c: move truncate, truncate64, ftruncate, and ftruncate64 parsers to a separate file
* truncate.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_truncate, sys_truncate64, sys_ftruncate, sys_ftruncate64):
Move to truncate.c.
2014-12-11 21:40:04 +00:00
9b2f674adb file.c: move chdir parser to a separate file
* chdir.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_chdir): Move to chdir.c.
2014-12-11 21:39:59 +00:00
231b19fca0 file.c: move link, linkat, unlinkat, and symlinkat parsers to a separate file
* link.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_link, sys_linkat, sys_unlinkat, sys_symlinkat, and
related code to link.c.
2014-12-11 21:39:44 +00:00
46245b3541 file.c: move readlink and readlinkat parsers to a separate file
* readlink.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (decode_readlink, sys_readlink, sys_readlinkat): Move
to readlink.c.
2014-12-11 21:39:35 +00:00
6d20a0b9a3 file.c: move renameat and renameat2 parsers to a separate file
* renameat.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_renameat, sys_renameat2, and related code
to renameat.c.
2014-12-11 21:39:30 +00:00
2b7a53bff5 file.c: move chown, fchown, and fchownat parsers to a separate file
* chown.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_chown, sys_fchownat, sys_fchown): Move to chown.c.
2014-12-11 21:39:28 +00:00
ad5cf1e5ae file.c: move chmod, fchmod, and fchmodat parsers to a separate file
* chmod.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_chmod, sys_fchmodat, sys_fchmod): Move to chmod.c.
2014-12-11 21:39:25 +00:00
481e067836 file.c: move utimes, futimesat, utimensat, and osf_utimes parsers to a separate file
* utimes.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (decode_utimes, sys_utimes, sys_futimesat, sys_utimensat,
sys_osf_utimes): Move to utimes.c.
2014-12-11 21:39:21 +00:00
fb470f350e file.c: move utime parser to a separate file
* utime.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_utime): Move to utime.c.
2014-12-11 21:39:16 +00:00
b1a01b8d42 Export sprinttime
* defs.h (sprinttime): New prototype.
* file.c (sprinttime): Make global and move to util.c.
2014-12-11 21:39:16 +00:00
db23b3414c file.c: move mknod, mknodat, and xmknod parsers to a separate file
* mknod.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_mknod, sys_mknodat, sys_xmknod, and related code
to mknod.c.
2014-12-11 21:39:12 +00:00
9514ac73c7 file.c: export sprintmode and move it to a separate file
* printmode.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (sprintmode): New prototype.
* file.c (sprintmode): Make global and move to printmode.c.
2014-12-11 21:39:02 +00:00
a836430dbb file.c: move getcwd parser to a separate file
* getcwd.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_getcwd): Move to getcwd.c.
2014-12-11 21:38:59 +00:00
769ffe9797 file.c: move *xattr parsers to a separate file
* xattr.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_setxattr, sys_fsetxattr, sys_getxattr, sys_fgetxattr,
sys_listxattr, sys_flistxattr, sys_removexattr, sys_fremovexattr,
and related code to xattr.c.
2014-12-11 21:38:51 +00:00
63f28dd197 file.c: move fadvise64 and fadvise64_64 parsers to a separate file
* fadvise.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_fadvise64, sys_fadvise64_64, and related code
to fadvise.c.
2014-12-11 21:38:43 +00:00
710b3ae4a2 file.c: move sync_file_range and sync_file_range2 parsers to a separate file
* sync_file_range.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_sync_file_range, sys_sync_file_range2, and related
code to sync_file_range.c.
2014-12-11 21:38:32 +00:00
2795a5f7ac file.c: move fallocate parser to a separate file
* fallocate.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_fallocate): Move to fallocate.c.
2014-12-11 21:38:25 +00:00
85a364a4ac file.c: move swapon parser to a separate file
* swapon.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Move sys_swapon and related code to swapon.c.
2014-12-11 21:37:52 +00:00
6355a1f867 Alias sys_mkdir and sys_mkdirat to sys_chmod and sys_fchmodat
Special parsers for mkdir and mkdirat are redundant because
sys_chmod and sys_fchmodat implement the same decoding.

* file.c (decode_mkdir, sys_mkdir, sys_mkdirat): Remove.
* linux/dummy.h (sys_mkdir): Alias to sys_chmod.
(sys_mkdirat): Alias to sys_fchmodat.
* linux/syscall.h (sys_mkdir, sys_mkdirat): Remove.
* pathtrace.c (pathtrace_match): Do not check for sys_mkdirat.
2014-12-01 19:52:26 +00:00
681452b0f8 Remove unused <sys/acl.h> based code
Starting with commit v4.6-240-g5afdf12, nobody compiles this
non-Linux code.

* configure.ac (AC_CHECK_HEADERS): Remove sys/acl.h.
* file.c [HAVE_SYS_ACL_H]: Remove.
* xlat/aclcmds.in: Remove.
2014-12-01 19:45:24 +00:00
c62d49ed0e Remove unused <sys/asynch.h> based code
Starting with commit v4.6-240-g5afdf12, nobody compiles this
non-Linux code.

* configure.ac (AC_CHECK_HEADERS): Remove sys/asynch.h.
* file.c [HAVE_SYS_ASYNCH_H]: Remove.
2014-12-01 19:45:24 +00:00
Elliott Hughes
22e34b9857 Don't risk truncating open flags by using mode_t
On Android, 32-bit arm and x86 use __kernel_mode_t (an unsigned short)
as their mode_t.  The open(2) flags are actually an int, so high ones
like O_CLOEXEC get truncated if you coerce them to mode_t.

* defs.h (tprint_open_modes, sprint_open_modes): Change argument type
from mode_t to int.
* file.c (tprint_open_modes, sprint_open_modes): Likewise.

Signed-off-by: Elliott Hughes <enh@google.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2014-10-03 22:01:37 +00:00