1999-02-19 03:21:36 +03:00
/*
* Copyright ( c ) 1991 , 1992 Paul Kranenburg < pk @ cs . few . eur . nl >
* Copyright ( c ) 1993 Branko Lankester < branko @ hacktic . nl >
* Copyright ( c ) 1993 , 1994 , 1995 , 1996 Rick Sladkey < jrs @ world . std . com >
1999-12-23 17:20:14 +03:00
* Copyright ( c ) 1996 - 1999 Wichert Akkerman < wichert @ cistron . nl >
1999-02-19 03:21:36 +03:00
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
* 1. Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
* 2. Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ` ` AS IS ' ' AND ANY EXPRESS OR
* IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED .
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT , INDIRECT ,
* INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT
* NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
* DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
*/
# include "defs.h"
2008-08-01 05:13:10 +04:00
2014-12-30 14:18:47 +03:00
# undef dev_t
# undef ino_t
# undef mode_t
# undef nlink_t
# undef uid_t
# undef gid_t
# undef off_t
# undef loff_t
# define dev_t __kernel_dev_t
# define ino_t __kernel_ino_t
# define mode_t __kernel_mode_t
# define nlink_t __kernel_nlink_t
# define uid_t __kernel_uid_t
# define gid_t __kernel_gid_t
# define off_t __kernel_off_t
# define loff_t __kernel_loff_t
2015-12-04 17:37:02 +03:00
# include "asm_stat.h"
2014-12-30 14:18:47 +03:00
# undef dev_t
# undef ino_t
# undef mode_t
# undef nlink_t
# undef uid_t
# undef gid_t
# undef off_t
# undef loff_t
# define dev_t dev_t
# define ino_t ino_t
# define mode_t mode_t
# define nlink_t nlink_t
# define uid_t uid_t
# define gid_t gid_t
# define off_t off_t
# define loff_t loff_t
/* for S_IFMT */
2012-02-25 05:38:52 +04:00
# define stat libc_stat
# define stat64 libc_stat64
# include <sys/stat.h>
# undef stat
# undef stat64
2012-03-16 15:02:22 +04:00
/* These might be macros. */
2012-02-25 05:38:52 +04:00
# undef st_atime
# undef st_mtime
# undef st_ctime
1999-04-19 03:30:29 +04:00
2014-12-30 14:18:47 +03:00
# if defined MAJOR_IN_SYSMACROS
2012-02-25 05:38:52 +04:00
# include <sys / sysmacros.h>
2014-12-30 14:18:47 +03:00
# elif defined MAJOR_IN_MKDEV
2012-02-25 05:38:52 +04:00
# include <sys / mkdev.h>
1999-02-19 03:21:36 +03:00
# endif
/* several stats */
2015-01-08 05:59:04 +03:00
# include "printstat.h"
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-08 15:12:13 +03:00
/* all locally defined structures provide these fields */
# undef HAVE_STRUCT_STAT_ST_ATIME_NSEC
# define HAVE_STRUCT_STAT_ST_ATIME_NSEC 1
# undef HAVE_STRUCT_STAT_ST_CTIME_NSEC
# define HAVE_STRUCT_STAT_ST_CTIME_NSEC 1
# undef HAVE_STRUCT_STAT_ST_MTIME_NSEC
# define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
2014-12-30 14:18:47 +03:00
# undef STAT32_PERSONALITY
# if SUPPORTED_PERSONALITIES > 1
# if defined AARCH64 || defined X86_64 || defined X32
struct stat32 {
unsigned int st_dev ;
unsigned int st_ino ;
unsigned short st_mode ;
unsigned short st_nlink ;
unsigned short st_uid ;
unsigned short st_gid ;
unsigned int st_rdev ;
unsigned int st_size ;
unsigned int st_blksize ;
unsigned int st_blocks ;
unsigned int st_atime ;
unsigned int st_atime_nsec ;
unsigned int st_mtime ;
unsigned int st_mtime_nsec ;
unsigned int st_ctime ;
unsigned int st_ctime_nsec ;
unsigned int __unused4 ;
unsigned int __unused5 ;
} ;
2015-12-09 03:43:39 +03:00
# define STAT32_PERSONALITY 1
2014-12-30 14:18:47 +03:00
# elif defined POWERPC64
struct stat32 {
2010-07-12 23:39:57 +04:00
unsigned int st_dev ;
unsigned int st_ino ;
unsigned int st_mode ;
unsigned short st_nlink ;
unsigned int st_uid ;
unsigned int st_gid ;
unsigned int st_rdev ;
unsigned int st_size ;
unsigned int st_blksize ;
unsigned int st_blocks ;
unsigned int st_atime ;
unsigned int st_atime_nsec ;
unsigned int st_mtime ;
unsigned int st_mtime_nsec ;
unsigned int st_ctime ;
unsigned int st_ctime_nsec ;
unsigned int __unused4 ;
unsigned int __unused5 ;
} ;
2014-12-30 14:18:47 +03:00
# define STAT32_PERSONALITY 1
# elif defined SPARC64
struct stat32 {
unsigned short st_dev ;
unsigned int st_ino ;
unsigned short st_mode ;
unsigned short st_nlink ;
unsigned short st_uid ;
unsigned short st_gid ;
unsigned short st_rdev ;
unsigned int st_size ;
unsigned int st_atime ;
unsigned int st_atime_nsec ;
unsigned int st_mtime ;
unsigned int st_mtime_nsec ;
unsigned int st_ctime ;
unsigned int st_ctime_nsec ;
unsigned int st_blksize ;
unsigned int st_blocks ;
unsigned int __unused4 [ 2 ] ;
} ;
# define STAT32_PERSONALITY 0
# elif defined SPARC
# /* no 64-bit personalities */
# elif defined TILE
# /* no 32-bit stat */
# else
# warning FIXME: check whether struct stat32 definition is needed for this architecture!
# endif /* X86_64 || X32 || POWERPC64 */
# endif /* SUPPORTED_PERSONALITIES > 1 */
# ifdef STAT32_PERSONALITY
2015-01-08 05:59:04 +03:00
# define DO_PRINTSTAT do_printstat32
2014-12-30 14:18:47 +03:00
# define STRUCT_STAT struct stat32
2015-01-08 05:59:04 +03:00
# undef HAVE_STRUCT_STAT_ST_FLAGS
# undef HAVE_STRUCT_STAT_ST_FSTYPE
# undef HAVE_STRUCT_STAT_ST_GEN
# include "printstat.h"
2014-12-30 14:18:47 +03:00
# endif /* STAT32_PERSONALITY */
2010-07-12 23:39:57 +04:00
2015-01-08 06:13:59 +03:00
# if defined(SPARC) || defined(SPARC64)
struct solstat {
unsigned st_dev ;
unsigned int st_pad1 [ 3 ] ; /* network id */
unsigned st_ino ;
unsigned st_mode ;
unsigned st_nlink ;
unsigned st_uid ;
unsigned st_gid ;
unsigned st_rdev ;
unsigned int st_pad2 [ 2 ] ;
unsigned int st_size ;
unsigned int st_pad3 ; /* st_size, off_t expansion */
unsigned int st_atime ;
unsigned int st_atime_nsec ;
unsigned int st_mtime ;
unsigned int st_mtime_nsec ;
unsigned int st_ctime ;
unsigned int st_ctime_nsec ;
unsigned int st_blksize ;
unsigned int st_blocks ;
char st_fstype [ 16 ] ;
unsigned int st_pad4 [ 8 ] ; /* expansion area */
} ;
# define DO_PRINTSTAT do_printstat_sol
# define STRUCT_STAT struct solstat
# define STAT_MAJOR(x) (((x) >> 18) & 0x3fff)
# define STAT_MINOR(x) ((x) & 0x3ffff)
# undef HAVE_STRUCT_STAT_ST_FLAGS
# undef HAVE_STRUCT_STAT_ST_FSTYPE
# undef HAVE_STRUCT_STAT_ST_GEN
# include "printstat.h"
# endif /* SPARC || SPARC64 */
1999-02-19 03:21:36 +03:00
static void
2009-04-14 16:51:00 +04:00
printstat ( struct tcb * tcp , long addr )
1999-02-19 03:21:36 +03:00
{
1999-04-16 04:21:26 +04:00
struct stat statbuf ;
1999-02-19 03:21:36 +03:00
2014-12-30 14:18:47 +03:00
# ifdef STAT32_PERSONALITY
if ( current_personality = = STAT32_PERSONALITY ) {
2015-07-20 15:09:44 +03:00
struct stat32 statbuf ;
if ( ! umove_or_printaddr ( tcp , addr , & statbuf ) )
do_printstat32 ( tcp , & statbuf ) ;
2009-02-27 23:32:52 +03:00
return ;
}
2014-12-30 14:18:47 +03:00
# endif
1999-02-19 03:21:36 +03:00
2014-12-30 14:18:47 +03:00
# if defined(SPARC) || defined(SPARC64)
2010-07-12 23:39:57 +04:00
if ( current_personality = = 1 ) {
2015-07-20 15:09:44 +03:00
struct solstat statbuf ;
2010-07-12 23:39:57 +04:00
2015-07-20 15:09:44 +03:00
if ( ! umove_or_printaddr ( tcp , addr , & statbuf ) )
do_printstat_sol ( tcp , & statbuf ) ;
1999-02-19 03:21:36 +03:00
return ;
}
2015-07-20 15:09:44 +03:00
# endif /* SPARC || SPARC64 */
1999-04-16 04:21:26 +04:00
2015-07-20 15:09:44 +03:00
if ( ! umove_or_printaddr ( tcp , addr , & statbuf ) )
do_printstat ( tcp , & statbuf ) ;
1999-04-16 04:21:26 +04:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( stat )
2015-01-08 04:14:53 +03:00
{
if ( entering ( tcp ) ) {
printpath ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
} else {
printstat ( tcp , tcp - > u_arg [ 1 ] ) ;
}
return 0 ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( fstat )
2015-01-08 04:14:53 +03:00
{
if ( entering ( tcp ) ) {
printfd ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
} else {
printstat ( tcp , tcp - > u_arg [ 1 ] ) ;
}
return 0 ;
}
2015-01-08 07:06:06 +03:00
# if defined STAT32_PERSONALITY && !defined HAVE_STRUCT_STAT64
2014-12-30 14:18:47 +03:00
# if defined AARCH64 || defined X86_64 || defined X32
2007-08-07 05:22:49 +04:00
/*
2014-12-28 19:41:24 +03:00
* Linux x86_64 and x32 have unified ` struct stat ' but their i386 personality
* needs ` struct stat64 ' .
* linux / arch / x86 / include / uapi / asm / stat . h defines ` struct stat64 ' only for i386 .
2014-04-04 04:50:14 +04:00
*
* Similarly , aarch64 has a unified ` struct stat ' but its arm personality
2014-12-28 19:41:24 +03:00
* needs ` struct stat64 ' ( unlike x86 , it shouldn ' t be packed ) .
2007-08-07 05:22:49 +04:00
*/
struct stat64 {
unsigned long long st_dev ;
unsigned char __pad0 [ 4 ] ;
unsigned int __st_ino ;
unsigned int st_mode ;
unsigned int st_nlink ;
unsigned int st_uid ;
unsigned int st_gid ;
unsigned long long st_rdev ;
unsigned char __pad3 [ 4 ] ;
long long st_size ;
unsigned int st_blksize ;
unsigned long long st_blocks ;
unsigned int st_atime ;
unsigned int st_atime_nsec ;
unsigned int st_mtime ;
unsigned int st_mtime_nsec ;
unsigned int st_ctime ;
unsigned int st_ctime_nsec ;
unsigned long long st_ino ;
2014-04-04 04:50:14 +04:00
}
2014-12-30 14:18:47 +03:00
# if defined X86_64 || defined X32
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 01:45:03 +03:00
ATTRIBUTE_PACKED
2014-12-30 14:18:47 +03:00
# define STAT64_SIZE 96
# else
# define STAT64_SIZE 104
# endif
2014-04-04 04:50:14 +04:00
;
2015-01-08 07:06:06 +03:00
# define HAVE_STRUCT_STAT64 1
2014-12-30 14:18:47 +03:00
# else /* !(AARCH64 || X86_64 || X32) */
# warning FIXME: check whether struct stat64 definition is needed for this architecture!
# endif
2015-01-08 07:06:06 +03:00
# endif /* STAT32_PERSONALITY && !HAVE_STRUCT_STAT64 */
2007-08-07 05:22:49 +04:00
2015-01-08 07:06:06 +03:00
# ifdef HAVE_STRUCT_STAT64
2014-12-28 21:56:23 +03:00
# define DO_PRINTSTAT do_printstat64
# define STRUCT_STAT struct stat64
# undef HAVE_STRUCT_STAT_ST_FLAGS
# undef HAVE_STRUCT_STAT_ST_FSTYPE
# undef HAVE_STRUCT_STAT_ST_GEN
# include "printstat.h"
1999-12-24 11:01:34 +03:00
static void
2009-04-14 16:51:00 +04:00
printstat64 ( struct tcb * tcp , long addr )
1999-12-24 11:01:34 +03:00
{
struct stat64 statbuf ;
2014-12-30 14:18:47 +03:00
# ifdef STAT64_SIZE
2007-08-07 05:22:49 +04:00
( void ) sizeof ( char [ sizeof statbuf = = STAT64_SIZE ? 1 : - 1 ] ) ;
2014-12-30 14:18:47 +03:00
# endif
2007-08-07 05:22:49 +04:00
2014-12-30 14:18:47 +03:00
# ifdef STAT32_PERSONALITY
if ( current_personality ! = STAT32_PERSONALITY ) {
2009-10-16 13:37:13 +04:00
printstat ( tcp , addr ) ;
return ;
}
2014-12-30 14:18:47 +03:00
# endif /* STAT32_PERSONALITY */
2009-10-21 17:43:57 +04:00
2015-07-20 15:09:44 +03:00
if ( ! umove_or_printaddr ( tcp , addr , & statbuf ) )
do_printstat64 ( tcp , & statbuf ) ;
1999-12-24 11:01:34 +03:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( stat64 )
1999-02-19 03:21:36 +03:00
{
if ( entering ( tcp ) ) {
printpath ( tcp , tcp - > u_arg [ 0 ] ) ;
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
1999-02-19 03:21:36 +03:00
} else {
2015-01-08 04:14:53 +03:00
printstat64 ( tcp , tcp - > u_arg [ 1 ] ) ;
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( fstat64 )
1999-12-24 11:01:34 +03:00
{
if ( entering ( tcp ) ) {
2015-01-08 04:14:53 +03:00
printfd ( tcp , tcp - > u_arg [ 0 ] ) ;
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
1999-12-24 11:01:34 +03:00
} else {
printstat64 ( tcp , tcp - > u_arg [ 1 ] ) ;
}
return 0 ;
2014-12-30 14:18:47 +03:00
}
1999-12-24 11:01:34 +03:00
# else
2014-12-30 14:18:47 +03:00
2015-04-07 04:36:50 +03:00
SYS_FUNC ( stat64 )
2014-12-30 14:18:47 +03:00
{
return sys_stat ( tcp ) ;
1999-12-24 11:01:34 +03:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( fstat64 )
2014-12-30 14:18:47 +03:00
{
return sys_fstat ( tcp ) ;
}
2015-01-08 07:06:06 +03:00
# endif /* HAVE_STRUCT_STAT64 */
2014-12-30 14:18:47 +03:00
2015-04-07 04:36:50 +03:00
SYS_FUNC ( newfstatat )
2006-10-13 Ulrich Drepper <drepper@redhat.com>
Bernhard Kaindl <bk@suse.de>
Dmitry V. Levin <ldv@altlinux.org>
Michael Holzheu <holzheu@de.ibm.com>
Add hooks for new syscalls. Add decoders for *at, inotify*,
pselect6, ppoll and unshare syscalls.
* defs.h: Declare print_sigset.
* desc.c (sys_pselect6): New function.
* file.c (decode_open, decode_access, decode_mkdir,
decode_readlink, decode_chmod, decode_utimes, decode_mknod):
New functions.
(sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod,
sys_utimes, sys_mknod): Use them.
[LINUX] (fstatatflags, unlinkatflags, inotify_modes): New
variables.
[LINUX] (print_dirfd, sys_openat, sys_faccessat,
sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat,
sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat,
sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch,
sys_inotify_rm_watch): New functions.
* process.c [LINUX] (sys_unshare): New function.
* signal.c (print_sigset): New function.
(sys_sigprocmask): Use it.
* stream.c (decode_poll): New function.
(sys_poll): Use it.
[LINUX] (sys_ppoll): New function.
* linux/syscall.h: Delcare new syscall handlers.
* linux/syscallent.h: Hook up new syscalls.
* linux/alpha/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
Fixes RH#178633.
2006-10-14 00:25:12 +04:00
{
if ( entering ( tcp ) ) {
Fix decoding of file descriptors
* defs.h (printfd): New function prototype.
* util.c (printfd): New function.
* file.c (print_dirfd): Update prototype to use printfd().
(sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat,
sys_unlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat,
sys_futimesat, sys_utimensat, sys_mknodat): Update use of print_dirfd().
(sys_lseek, sys_llseek, sys_readahead, sys_ftruncate, sys_ftruncate64,
sys_fstat, sys_fstat64, sys_oldfstat, sys_fstatfs, sys_fstatfs64,
sys_fchdir, sys_fchroot, sys_linkat, sys_fchown, sys_fchmod, sys_fsync,
sys_readdir, sys_getdents, sys_getdirentries, sys_fsetxattr,
sys_fgetxattr, sys_flistxattr, sys_fremovexattr, sys_fadvise64,
sys_fadvise64_64, sys_inotify_add_watch, sys_inotify_rm_watch,
sys_fallocate): Use printfd() for decoding of file descriptors.
* desc.c (sys_fcntl, sys_flock, sys_close, sys_dup, do_dup2,
decode_select, sys_epoll_ctl, epoll_wait_common): Use printfd() for
decoding of file descriptors.
* io.c (sys_read, sys_write, sys_readv, sys_writev, sys_pread,
sys_pwrite, sys_sendfile, sys_sendfile64, sys_pread64, sys_pwrite64,
sys_ioctl): Likewise.
* mem.c (print_mmap, sys_mmap64): Likewise.
* signal.c (do_signalfd): Likewise.
* stream.c (decode_poll): Likewise.
* time.c (sys_timerfd_settime, sys_timerfd_gettime): Likewise.
Based on patch from Grant Edwards <grant.b.edwards@gmail.com>.
2011-03-04 05:08:02 +03:00
print_dirfd ( tcp , tcp - > u_arg [ 0 ] ) ;
2006-10-13 Ulrich Drepper <drepper@redhat.com>
Bernhard Kaindl <bk@suse.de>
Dmitry V. Levin <ldv@altlinux.org>
Michael Holzheu <holzheu@de.ibm.com>
Add hooks for new syscalls. Add decoders for *at, inotify*,
pselect6, ppoll and unshare syscalls.
* defs.h: Declare print_sigset.
* desc.c (sys_pselect6): New function.
* file.c (decode_open, decode_access, decode_mkdir,
decode_readlink, decode_chmod, decode_utimes, decode_mknod):
New functions.
(sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod,
sys_utimes, sys_mknod): Use them.
[LINUX] (fstatatflags, unlinkatflags, inotify_modes): New
variables.
[LINUX] (print_dirfd, sys_openat, sys_faccessat,
sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat,
sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat,
sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch,
sys_inotify_rm_watch): New functions.
* process.c [LINUX] (sys_unshare): New function.
* signal.c (print_sigset): New function.
(sys_sigprocmask): Use it.
* stream.c (decode_poll): New function.
(sys_poll): Use it.
[LINUX] (sys_ppoll): New function.
* linux/syscall.h: Delcare new syscall handlers.
* linux/syscallent.h: Hook up new syscalls.
* linux/alpha/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
Fixes RH#178633.
2006-10-14 00:25:12 +04:00
printpath ( tcp , tcp - > u_arg [ 1 ] ) ;
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
2006-10-13 Ulrich Drepper <drepper@redhat.com>
Bernhard Kaindl <bk@suse.de>
Dmitry V. Levin <ldv@altlinux.org>
Michael Holzheu <holzheu@de.ibm.com>
Add hooks for new syscalls. Add decoders for *at, inotify*,
pselect6, ppoll and unshare syscalls.
* defs.h: Declare print_sigset.
* desc.c (sys_pselect6): New function.
* file.c (decode_open, decode_access, decode_mkdir,
decode_readlink, decode_chmod, decode_utimes, decode_mknod):
New functions.
(sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod,
sys_utimes, sys_mknod): Use them.
[LINUX] (fstatatflags, unlinkatflags, inotify_modes): New
variables.
[LINUX] (print_dirfd, sys_openat, sys_faccessat,
sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat,
sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat,
sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch,
sys_inotify_rm_watch): New functions.
* process.c [LINUX] (sys_unshare): New function.
* signal.c (print_sigset): New function.
(sys_sigprocmask): Use it.
* stream.c (decode_poll): New function.
(sys_poll): Use it.
[LINUX] (sys_ppoll): New function.
* linux/syscall.h: Delcare new syscall handlers.
* linux/syscallent.h: Hook up new syscalls.
* linux/alpha/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
Fixes RH#178633.
2006-10-14 00:25:12 +04:00
} else {
2014-12-30 14:18:47 +03:00
# if defined STAT32_PERSONALITY
if ( current_personality = = STAT32_PERSONALITY )
2010-07-12 23:39:57 +04:00
printstat64 ( tcp , tcp - > u_arg [ 2 ] ) ;
2014-12-30 14:18:47 +03:00
else
printstat ( tcp , tcp - > u_arg [ 2 ] ) ;
2015-01-08 07:06:06 +03:00
# elif defined HAVE_STRUCT_STAT64
2006-10-13 Ulrich Drepper <drepper@redhat.com>
Bernhard Kaindl <bk@suse.de>
Dmitry V. Levin <ldv@altlinux.org>
Michael Holzheu <holzheu@de.ibm.com>
Add hooks for new syscalls. Add decoders for *at, inotify*,
pselect6, ppoll and unshare syscalls.
* defs.h: Declare print_sigset.
* desc.c (sys_pselect6): New function.
* file.c (decode_open, decode_access, decode_mkdir,
decode_readlink, decode_chmod, decode_utimes, decode_mknod):
New functions.
(sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod,
sys_utimes, sys_mknod): Use them.
[LINUX] (fstatatflags, unlinkatflags, inotify_modes): New
variables.
[LINUX] (print_dirfd, sys_openat, sys_faccessat,
sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat,
sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat,
sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch,
sys_inotify_rm_watch): New functions.
* process.c [LINUX] (sys_unshare): New function.
* signal.c (print_sigset): New function.
(sys_sigprocmask): Use it.
* stream.c (decode_poll): New function.
(sys_poll): Use it.
[LINUX] (sys_ppoll): New function.
* linux/syscall.h: Delcare new syscall handlers.
* linux/syscallent.h: Hook up new syscalls.
* linux/alpha/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
Fixes RH#178633.
2006-10-14 00:25:12 +04:00
printstat64 ( tcp , tcp - > u_arg [ 2 ] ) ;
# else
printstat ( tcp , tcp - > u_arg [ 2 ] ) ;
2015-01-08 07:06:06 +03:00
# endif /* STAT32_PERSONALITY || HAVE_STRUCT_STAT64 */
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
2012-03-14 03:26:01 +04:00
printflags ( at_flags , tcp - > u_arg [ 3 ] , " AT_??? " ) ;
2006-10-13 Ulrich Drepper <drepper@redhat.com>
Bernhard Kaindl <bk@suse.de>
Dmitry V. Levin <ldv@altlinux.org>
Michael Holzheu <holzheu@de.ibm.com>
Add hooks for new syscalls. Add decoders for *at, inotify*,
pselect6, ppoll and unshare syscalls.
* defs.h: Declare print_sigset.
* desc.c (sys_pselect6): New function.
* file.c (decode_open, decode_access, decode_mkdir,
decode_readlink, decode_chmod, decode_utimes, decode_mknod):
New functions.
(sys_open, sys_access, sys_mkdir, sys_readlink, sys_chmod,
sys_utimes, sys_mknod): Use them.
[LINUX] (fstatatflags, unlinkatflags, inotify_modes): New
variables.
[LINUX] (print_dirfd, sys_openat, sys_faccessat,
sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat,
sys_symlinkat, sys_readlinkat, sys_renameat, sys_fchownat,
sys_fchmodat, sys_futimesat, sys_mknodat, sys_inotify_add_watch,
sys_inotify_rm_watch): New functions.
* process.c [LINUX] (sys_unshare): New function.
* signal.c (print_sigset): New function.
(sys_sigprocmask): Use it.
* stream.c (decode_poll): New function.
(sys_poll): Use it.
[LINUX] (sys_ppoll): New function.
* linux/syscall.h: Delcare new syscall handlers.
* linux/syscallent.h: Hook up new syscalls.
* linux/alpha/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
Fixes RH#178633.
2006-10-14 00:25:12 +04:00
}
return 0 ;
}
Remove code which supports systems with long long off_t.
While looking at mmap mess, did experimenting in order
to figure out what gets used when.
Tried building armv4tl, armv5l, armv6l, mips, mipsel, i686,
x86_64 and none of they have long long off_t,
which isn't suprprising: we aren't using glibc defines
which enable that.
Moreover, we SHOULD NOT use off_t in syscall decode!
Its size depends on libc, not on arch! I.e. it is essentially
unpredictable and can even in theory vary on the same arch
with different libc.
We should use longs or long longs, in a way which matches
architectural ABI for the given syscall. There are usually
*at most* two permutations, no need to add yet another variable
(sizeof(off_t)) to the mix.
This change removes almost all HAVE_LONG_LONG_OFF_T conditionals,
which will reveal further possible simplifications.
* mem.c: Remove code conditional on HAVE_LONG_LONG_OFF_T.
As a result, never remap sys_mmap64 to sys_mmap.
(print_mmap): Compile unconditionally.
(sys_old_mmap): Compile unconditionally.
(sys_mmap): Compile unconditionally.
* io.c (sys_sendfile): Add a FIXME comment.
* file.c: Remove code conditional on HAVE_LONG_LONG_OFF_T.
As a result, never remap sys_*stat64 to sys_*stat etc.
(sys_truncate): Compile unconditionally.
(realprintstat): Likewise.
(sys_stat): Likewise.
(sys_fstat): Likewise.
(sys_lstat): Likewise.
* desc.c (printflock): Likewise.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-18 18:47:57 +04:00
# if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
2014-12-28 22:10:58 +03:00
static void
convertoldstat ( const struct __old_kernel_stat * oldbuf , struct stat * newbuf )
{
memset ( newbuf , 0 , sizeof ( * newbuf ) ) ;
newbuf - > st_dev = oldbuf - > st_dev ;
newbuf - > st_ino = oldbuf - > st_ino ;
newbuf - > st_mode = oldbuf - > st_mode ;
newbuf - > st_nlink = oldbuf - > st_nlink ;
newbuf - > st_uid = oldbuf - > st_uid ;
newbuf - > st_gid = oldbuf - > st_gid ;
newbuf - > st_rdev = oldbuf - > st_rdev ;
newbuf - > st_size = oldbuf - > st_size ;
newbuf - > st_atime = oldbuf - > st_atime ;
newbuf - > st_mtime = oldbuf - > st_mtime ;
newbuf - > st_ctime = oldbuf - > st_ctime ;
}
static void
printoldstat ( struct tcb * tcp , long addr )
{
struct __old_kernel_stat statbuf ;
struct stat newstatbuf ;
# if defined(SPARC) || defined(SPARC64)
if ( current_personality = = 1 ) {
2015-07-20 15:09:44 +03:00
struct solstat statbuf ;
if ( ! umove_or_printaddr ( tcp , addr , & statbuf ) )
do_printstat_sol ( tcp , & statbuf ) ;
2014-12-28 22:10:58 +03:00
return ;
}
# endif
2015-07-20 15:09:44 +03:00
if ( ! umove_or_printaddr ( tcp , addr , & statbuf ) ) {
convertoldstat ( & statbuf , & newstatbuf ) ;
do_printstat ( tcp , & newstatbuf ) ;
2014-12-28 22:10:58 +03:00
}
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( oldstat )
2014-12-28 22:10:58 +03:00
{
if ( entering ( tcp ) ) {
printpath ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
} else {
printoldstat ( tcp , tcp - > u_arg [ 1 ] ) ;
}
return 0 ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( oldfstat )
1999-04-16 04:21:26 +04:00
{
Fix decoding of file descriptors
* defs.h (printfd): New function prototype.
* util.c (printfd): New function.
* file.c (print_dirfd): Update prototype to use printfd().
(sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat,
sys_unlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat,
sys_futimesat, sys_utimensat, sys_mknodat): Update use of print_dirfd().
(sys_lseek, sys_llseek, sys_readahead, sys_ftruncate, sys_ftruncate64,
sys_fstat, sys_fstat64, sys_oldfstat, sys_fstatfs, sys_fstatfs64,
sys_fchdir, sys_fchroot, sys_linkat, sys_fchown, sys_fchmod, sys_fsync,
sys_readdir, sys_getdents, sys_getdirentries, sys_fsetxattr,
sys_fgetxattr, sys_flistxattr, sys_fremovexattr, sys_fadvise64,
sys_fadvise64_64, sys_inotify_add_watch, sys_inotify_rm_watch,
sys_fallocate): Use printfd() for decoding of file descriptors.
* desc.c (sys_fcntl, sys_flock, sys_close, sys_dup, do_dup2,
decode_select, sys_epoll_ctl, epoll_wait_common): Use printfd() for
decoding of file descriptors.
* io.c (sys_read, sys_write, sys_readv, sys_writev, sys_pread,
sys_pwrite, sys_sendfile, sys_sendfile64, sys_pread64, sys_pwrite64,
sys_ioctl): Likewise.
* mem.c (print_mmap, sys_mmap64): Likewise.
* signal.c (do_signalfd): Likewise.
* stream.c (decode_poll): Likewise.
* time.c (sys_timerfd_settime, sys_timerfd_gettime): Likewise.
Based on patch from Grant Edwards <grant.b.edwards@gmail.com>.
2011-03-04 05:08:02 +03:00
if ( entering ( tcp ) ) {
printfd ( tcp , tcp - > u_arg [ 0 ] ) ;
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
Fix decoding of file descriptors
* defs.h (printfd): New function prototype.
* util.c (printfd): New function.
* file.c (print_dirfd): Update prototype to use printfd().
(sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat,
sys_unlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat,
sys_futimesat, sys_utimensat, sys_mknodat): Update use of print_dirfd().
(sys_lseek, sys_llseek, sys_readahead, sys_ftruncate, sys_ftruncate64,
sys_fstat, sys_fstat64, sys_oldfstat, sys_fstatfs, sys_fstatfs64,
sys_fchdir, sys_fchroot, sys_linkat, sys_fchown, sys_fchmod, sys_fsync,
sys_readdir, sys_getdents, sys_getdirentries, sys_fsetxattr,
sys_fgetxattr, sys_flistxattr, sys_fremovexattr, sys_fadvise64,
sys_fadvise64_64, sys_inotify_add_watch, sys_inotify_rm_watch,
sys_fallocate): Use printfd() for decoding of file descriptors.
* desc.c (sys_fcntl, sys_flock, sys_close, sys_dup, do_dup2,
decode_select, sys_epoll_ctl, epoll_wait_common): Use printfd() for
decoding of file descriptors.
* io.c (sys_read, sys_write, sys_readv, sys_writev, sys_pread,
sys_pwrite, sys_sendfile, sys_sendfile64, sys_pread64, sys_pwrite64,
sys_ioctl): Likewise.
* mem.c (print_mmap, sys_mmap64): Likewise.
* signal.c (do_signalfd): Likewise.
* stream.c (decode_poll): Likewise.
* time.c (sys_timerfd_settime, sys_timerfd_gettime): Likewise.
Based on patch from Grant Edwards <grant.b.edwards@gmail.com>.
2011-03-04 05:08:02 +03:00
} else {
1999-04-16 04:21:26 +04:00
printoldstat ( tcp , tcp - > u_arg [ 1 ] ) ;
}
return 0 ;
}
2014-12-28 22:10:58 +03:00
# endif /* HAVE_STRUCT___OLD_KERNEL_STAT */
1999-04-16 04:21:26 +04:00
2013-02-12 14:43:46 +04:00
# if defined(SPARC) || defined(SPARC64)
1999-02-19 03:21:36 +03:00
2015-04-07 04:36:50 +03:00
SYS_FUNC ( xstat )
1999-02-19 03:21:36 +03:00
{
if ( entering ( tcp ) ) {
tprintf ( " %ld, " , tcp - > u_arg [ 0 ] ) ;
printpath ( tcp , tcp - > u_arg [ 1 ] ) ;
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
1999-02-19 03:21:36 +03:00
} else {
printstat ( tcp , tcp - > u_arg [ 2 ] ) ;
}
return 0 ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( fxstat )
1999-02-19 03:21:36 +03:00
{
2014-12-29 06:15:42 +03:00
if ( entering ( tcp ) ) {
tprintf ( " %ld, " , tcp - > u_arg [ 0 ] ) ;
printfd ( tcp , tcp - > u_arg [ 1 ] ) ;
tprints ( " , " ) ;
} else {
1999-02-19 03:21:36 +03:00
printstat ( tcp , tcp - > u_arg [ 2 ] ) ;
}
return 0 ;
}
2014-12-06 06:53:16 +03:00
# endif /* SPARC || SPARC64 */