2015-12-05 00:01:56 +00:00
/*
2016-01-05 22:37:42 +00:00
* Copyright ( c ) 2015 - 2016 Dmitry V . Levin < ldv @ altlinux . org >
2017-05-22 19:14:52 +02:00
* Copyright ( c ) 2015 - 2017 The strace developers .
2015-12-05 00:01:56 +00: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 .
*/
2016-01-05 22:37:42 +00:00
# if defined HAVE_FTRUNCATE && defined HAVE_FUTIMENS
2015-12-05 00:01:56 +00:00
tests: fix TEST_SYSCALL_{NR,STR} and STRUCT_STAT_STR macros for musl
The contents of TEST_SYSCALL_NAME and STRUCT_STAT macros was subject
to macro expansion when used in definitions of TEST_SYSCALL_NR,
TEST_SYSCALL_STR, and STRUCT_STAT_STR macros.
As some libcs, e.g. musl libc, define lfs64 names as macros
(stat64 as stat, lstat64 as lstat, etc.), this might result to incorrect
expansion of TEST_SYSCALL_NR, TEST_SYSCALL_STR, and STRUCT_STAT_STR
macros. To avoid this problem, define these macros directly and remove
TEST_SYSCALL_NAME macro.
* tests/_newselect.c (TEST_SYSCALL_NAME): Remove.
(TEST_SYSCALL_NR, TEST_SYSCALL_STR): New macros.
* tests/fcntl.c: Likewise.
* tests/fcntl64.c: Likewise.
* tests/fstat.c: Likewise.
* tests/fstatat64.c: Likewise.
* tests/lstat.c: Likewise.
* tests/newfstatat.c: Likewise.
* tests/select.c: Likewise.
* tests/stat.c: Likewise.
* tests/fstat64.c (TEST_SYSCALL_NAME): Remove.
(TEST_SYSCALL_NR, TEST_SYSCALL_STR, STRUCT_STAT_STR): New macros.
* tests/lstat64.c: Likewise.
* tests/stat64.c: Likewise.
* tests/fstatx.c (TEST_SYSCALL_NR, nrify, nrify_): Remove.
* tests/lstatx.c: Likewise.
* tests/struct_flock.c (TEST_SYSCALL_NR, TEST_SYSCALL_STR, nrify,
nrify_, stringify, stringify_): Remove.
* tests/xselect.c: Likewise.
* tests/xstatx.c: Check TEST_SYSCALL_STR instead of TEST_SYSCALL_NAME.
(STRUCT_STAT_STR, TEST_SYSCALL_STR, stringify, stringify_): Remove.
[!STRUCT_STAT] (STRUCT_STAT_STR): New macro.
2016-01-12 00:03:41 +00:00
# ifndef TEST_SYSCALL_STR
# error TEST_SYSCALL_STR must be defined
2016-01-05 22:37:42 +00:00
# endif
2015-12-05 00:01:56 +00:00
# ifndef TEST_SYSCALL_INVOKE
# error TEST_SYSCALL_INVOKE must be defined
# endif
# ifndef PRINT_SYSCALL_HEADER
# error PRINT_SYSCALL_HEADER must be defined
# endif
# ifndef PRINT_SYSCALL_FOOTER
# error PRINT_SYSCALL_FOOTER must be defined
# endif
2016-10-19 11:11:41 +03:00
# include <errno.h>
2015-12-05 00:01:56 +00:00
# include <stdio.h>
# include <stddef.h>
# include <time.h>
# include <unistd.h>
2016-08-26 21:32:53 +00:00
# include <sys / sysmacros.h>
2015-12-05 00:01:56 +00:00
2017-07-01 13:14:49 +00:00
# include "print_fields.h"
2017-03-18 18:19:07 +03:00
# include "statx.h"
2016-08-11 22:31:08 +00:00
# ifndef STRUCT_STAT
# define STRUCT_STAT struct stat
# define STRUCT_STAT_STR "struct stat"
# define STRUCT_STAT_IS_STAT64 0
# endif
# ifndef SAMPLE_SIZE
2017-01-13 19:31:30 +00:00
# define SAMPLE_SIZE ((libc_off_t) 43147718418ULL)
2016-08-11 22:31:08 +00:00
# endif
2015-12-05 00:01:56 +00:00
typedef off_t libc_off_t ;
2017-01-13 20:07:09 +00:00
# define stat libc_stat
# define stat64 libc_stat64
2015-12-05 00:01:56 +00:00
# include <fcntl.h>
# include <sys / stat.h>
2017-01-13 20:07:09 +00:00
# undef stat
# undef stat64
2015-12-05 00:01:56 +00:00
2017-01-13 20:07:09 +00:00
# undef st_atime
# undef st_mtime
# undef st_ctime
# include "asm_stat.h"
2016-08-30 12:43:09 +00:00
2017-01-13 20:07:09 +00:00
# if STRUCT_STAT_IS_STAT64
2015-12-05 00:01:56 +00:00
# undef HAVE_STRUCT_STAT_ST_MTIME_NSEC
2017-01-13 20:07:09 +00:00
# if defined MPERS_IS_m32
# ifdef HAVE_M32_STRUCT_STAT64_ST_MTIME_NSEC
# define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
# endif
# elif defined MPERS_IS_mx32
# ifdef HAVE_MX32_STRUCT_STAT64_ST_MTIME_NSEC
# define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
# endif
# elif defined HAVE_STRUCT_STAT64_ST_MTIME_NSEC
2015-12-05 00:01:56 +00:00
# define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
2017-01-13 20:07:09 +00:00
# endif /* MPERS_IS_m32 || MPERS_IS_mx32 || HAVE_STRUCT_STAT64_ST_MTIME_NSEC */
# else /* !STRUCT_STAT_IS_STAT64 */
# if defined MPERS_IS_m32
# undef HAVE_STRUCT_STAT_ST_MTIME_NSEC
# ifdef HAVE_M32_STRUCT_STAT_ST_MTIME_NSEC
# define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
# endif
# elif defined MPERS_IS_mx32
# undef HAVE_STRUCT_STAT_ST_MTIME_NSEC
# ifdef HAVE_MX32_STRUCT_STAT_ST_MTIME_NSEC
# define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
# endif
# endif /* MPERS_IS_m32 || MPERS_IS_mx32 */
# endif /* STRUCT_STAT_IS_STAT64 */
2015-12-05 00:01:56 +00:00
2016-10-19 11:11:41 +03:00
# ifndef TEST_BOGUS_STRUCT_STAT
# define TEST_BOGUS_STRUCT_STAT 1
# endif
# ifndef IS_FSTAT
2017-01-12 22:52:17 +00:00
# define IS_FSTAT 0
2016-10-19 11:11:41 +03:00
# endif
2016-10-24 04:50:36 +03:00
# ifndef OLD_STAT
# define OLD_STAT 0
# endif
2017-03-18 18:19:07 +03:00
# ifndef IS_STATX
# define IS_STATX 0
# endif
2015-12-05 00:01:56 +00:00
static void
print_ftype ( const unsigned int mode )
{
if ( S_ISREG ( mode ) )
printf ( " S_IFREG " ) ;
else if ( S_ISDIR ( mode ) )
printf ( " S_IFDIR " ) ;
else if ( S_ISCHR ( mode ) )
printf ( " S_IFCHR " ) ;
else if ( S_ISBLK ( mode ) )
printf ( " S_IFBLK " ) ;
else
printf ( " %#o " , mode & S_IFMT ) ;
}
static void
print_perms ( const unsigned int mode )
{
printf ( " %#o " , mode & ~ S_IFMT ) ;
}
2017-03-18 18:19:07 +03:00
# if !IS_STATX
2015-12-05 00:01:56 +00:00
static void
print_stat ( const STRUCT_STAT * st )
{
printf ( " {st_dev=makedev(%u, %u) " ,
2016-08-31 16:31:53 +00:00
( unsigned int ) major ( zero_extend_signed_to_ull ( st - > st_dev ) ) ,
( unsigned int ) minor ( zero_extend_signed_to_ull ( st - > st_dev ) ) ) ;
printf ( " , st_ino=%llu " , zero_extend_signed_to_ull ( st - > st_ino ) ) ;
2015-12-05 00:01:56 +00:00
printf ( " , st_mode= " ) ;
print_ftype ( st - > st_mode ) ;
printf ( " | " ) ;
print_perms ( st - > st_mode ) ;
2016-08-31 16:31:53 +00:00
printf ( " , st_nlink=%llu " , zero_extend_signed_to_ull ( st - > st_nlink ) ) ;
printf ( " , st_uid=%llu " , zero_extend_signed_to_ull ( st - > st_uid ) ) ;
printf ( " , st_gid=%llu " , zero_extend_signed_to_ull ( st - > st_gid ) ) ;
2017-03-18 18:19:07 +03:00
# if OLD_STAT
2016-10-24 04:50:36 +03:00
printf ( " , st_blksize=0, st_blocks=0 " ) ;
2017-03-18 18:19:07 +03:00
# else /* !OLD_STAT */
2016-08-31 16:31:53 +00:00
printf ( " , st_blksize=%llu " , zero_extend_signed_to_ull ( st - > st_blksize ) ) ;
printf ( " , st_blocks=%llu " , zero_extend_signed_to_ull ( st - > st_blocks ) ) ;
2017-03-18 18:19:07 +03:00
# endif /* OLD_STAT */
2015-12-05 00:01:56 +00:00
switch ( st - > st_mode & S_IFMT ) {
case S_IFCHR : case S_IFBLK :
printf ( " , st_rdev=makedev(%u, %u) " ,
2016-08-31 16:31:53 +00:00
( unsigned int ) major ( zero_extend_signed_to_ull ( st - > st_rdev ) ) ,
( unsigned int ) minor ( zero_extend_signed_to_ull ( st - > st_rdev ) ) ) ;
2015-12-05 00:01:56 +00:00
break ;
default :
2016-08-31 16:31:53 +00:00
printf ( " , st_size=%llu " , zero_extend_signed_to_ull ( st - > st_size ) ) ;
2015-12-05 00:01:56 +00:00
}
2017-03-18 18:19:07 +03:00
# if defined(HAVE_STRUCT_STAT_ST_MTIME_NSEC) && !OLD_STAT
# define TIME_NSEC(val) zero_extend_signed_to_ull(val)
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 05:16:12 +02:00
# define HAVE_NSEC 1
2017-03-18 18:19:07 +03:00
# else
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 05:16:12 +02:00
# define TIME_NSEC(val) 0ULL
# define HAVE_NSEC 0
2017-03-18 18:19:07 +03:00
# endif
2017-02-26 19:14:34 +00:00
2017-06-17 21:47:57 +00:00
# define PRINT_ST_TIME(field) \
do { \
printf ( " , st_ " # field " =%lld " , \
sign_extend_unsigned_to_ll ( st - > st_ # # field ) ) ; \
print_time_t_nsec ( sign_extend_unsigned_to_ll ( st - > st_ # # field ) , \
TIME_NSEC ( st - > st_ # # field # # _nsec ) , 1 ) ; \
if ( HAVE_NSEC ) \
printf ( " , st_ " # field " _nsec=%llu " , \
TIME_NSEC ( st - > st_ # # field # # _nsec ) ) ; \
} while ( 0 )
2017-02-26 19:14:34 +00:00
PRINT_ST_TIME ( atime ) ;
PRINT_ST_TIME ( mtime ) ;
PRINT_ST_TIME ( ctime ) ;
2015-12-05 00:01:56 +00:00
printf ( " } " ) ;
}
2017-03-18 18:19:07 +03:00
# else /* !IS_STATX */
static void
print_stat ( const STRUCT_STAT * st )
{
2017-06-17 21:47:57 +00:00
# define PRINT_FIELD_U32_UID(field) \
do { \
if ( st - > field = = ( uint32_t ) - 1 ) \
printf ( " , %s=-1 " , # field ) ; \
else \
printf ( " , %s=%llu " , # field , \
( unsigned long long ) st - > field ) ; \
} while ( 0 )
# define PRINT_FIELD_TIME(field) \
do { \
printf ( " , %s={tv_sec=%lld, tv_nsec=%u} " , \
# field, (long long) st->field.tv_sec, \
( unsigned ) st - > field . tv_nsec ) ; \
print_time_t_nsec ( st - > field . tv_sec , \
zero_extend_signed_to_ull ( st - > field . tv_nsec ) , \
1 ) ; \
} while ( 0 )
2017-03-18 18:19:07 +03:00
printf ( " {stx_mask= " ) ;
printflags ( statx_masks , st - > stx_mask , " STATX_??? " ) ;
2017-07-01 13:14:49 +00:00
PRINT_FIELD_U ( " , " , * st , stx_blksize ) ;
2017-03-18 18:19:07 +03:00
printf ( " , stx_attributes= " ) ;
printflags ( statx_attrs , st - > stx_attributes , " STATX_ATTR_??? " ) ;
2017-07-01 13:14:49 +00:00
PRINT_FIELD_U ( " , " , * st , stx_nlink ) ;
2017-03-18 18:19:07 +03:00
PRINT_FIELD_U32_UID ( stx_uid ) ;
PRINT_FIELD_U32_UID ( stx_gid ) ;
printf ( " , stx_mode= " ) ;
print_ftype ( st - > stx_mode ) ;
printf ( " | " ) ;
print_perms ( st - > stx_mode ) ;
2017-07-01 13:14:49 +00:00
PRINT_FIELD_U ( " , " , * st , stx_ino ) ;
PRINT_FIELD_U ( " , " , * st , stx_size ) ;
PRINT_FIELD_U ( " , " , * st , stx_blocks ) ;
2017-04-15 11:43:12 +03:00
printf ( " , stx_attributes_mask= " ) ;
printflags ( statx_attrs , st - > stx_attributes_mask , " STATX_ATTR_??? " ) ;
2017-03-18 18:19:07 +03:00
PRINT_FIELD_TIME ( stx_atime ) ;
PRINT_FIELD_TIME ( stx_btime ) ;
PRINT_FIELD_TIME ( stx_ctime ) ;
PRINT_FIELD_TIME ( stx_mtime ) ;
2017-07-01 13:14:49 +00:00
PRINT_FIELD_U ( " , " , * st , stx_rdev_major ) ;
PRINT_FIELD_U ( " , " , * st , stx_rdev_minor ) ;
PRINT_FIELD_U ( " , " , * st , stx_dev_major ) ;
PRINT_FIELD_U ( " , " , * st , stx_dev_minor ) ;
2017-03-18 18:19:07 +03:00
printf ( " } " ) ;
}
# endif /* !IS_STATX */
2015-12-05 00:01:56 +00:00
static int
create_sample ( const char * fname , const libc_off_t size )
{
static const struct timespec ts [ ] = {
{ - 10843 , 135 } , { - 10841 , 246 }
} ;
( void ) close ( 0 ) ;
if ( open ( fname , O_RDWR | O_CREAT | O_TRUNC , 0640 ) ) {
perror ( fname ) ;
return 77 ;
}
if ( ftruncate ( 0 , size ) ) {
perror ( " ftruncate " ) ;
return 77 ;
}
if ( futimens ( 0 , ts ) ) {
perror ( " futimens " ) ;
return 77 ;
}
return 0 ;
}
int
main ( void )
{
2017-04-19 02:16:31 +00:00
# if IS_FSTAT
skip_if_unavailable ( " /proc/self/fd/ " ) ;
# else
2016-10-19 11:11:41 +03:00
static const char full [ ] = " /dev/full " ;
# endif
2017-04-20 01:01:29 +02:00
static const char sample [ ] = " stat.sample " ;
2017-03-17 20:15:20 +00:00
TAIL_ALLOC_OBJECT_CONST_PTR ( STRUCT_STAT , st ) ;
2015-12-05 00:01:56 +00:00
2016-10-19 11:11:41 +03:00
int rc ;
rc = create_sample ( sample , SAMPLE_SIZE ) ;
2017-04-20 03:04:50 +02:00
if ( rc )
2015-12-05 00:01:56 +00:00
return rc ;
2016-10-19 11:11:41 +03:00
# if TEST_BOGUS_STRUCT_STAT
STRUCT_STAT * st_cut = tail_alloc ( sizeof ( long ) * 4 ) ;
rc = TEST_SYSCALL_INVOKE ( sample , st_cut ) ;
PRINT_SYSCALL_HEADER ( sample ) ;
printf ( " %p " , st_cut ) ;
PRINT_SYSCALL_FOOTER ( rc ) ;
# endif
# if !IS_FSTAT
rc = TEST_SYSCALL_INVOKE ( full , st ) ;
PRINT_SYSCALL_HEADER ( full ) ;
if ( rc )
printf ( " %p " , st ) ;
else
print_stat ( st ) ;
PRINT_SYSCALL_FOOTER ( rc ) ;
# endif
2016-10-19 11:11:41 +03:00
if ( ( rc = TEST_SYSCALL_INVOKE ( sample , st ) ) ) {
2017-03-17 20:15:20 +00:00
if ( errno ! = EOVERFLOW ) {
rc = ( errno = = ENOSYS ) ? 77 : 1 ;
2016-10-24 04:50:36 +03:00
perror ( TEST_SYSCALL_STR ) ;
2017-03-17 20:15:20 +00:00
return rc ;
2016-10-24 04:50:36 +03:00
}
2015-12-05 00:01:56 +00:00
}
2017-03-18 18:19:07 +03:00
# if IS_STATX
# define ST_SIZE_FIELD stx_size
# else
# define ST_SIZE_FIELD st_size
# endif
2016-10-24 04:50:36 +03:00
if ( ! rc & & zero_extend_signed_to_ull ( SAMPLE_SIZE ) ! =
2017-03-18 18:19:07 +03:00
zero_extend_signed_to_ull ( st - > ST_SIZE_FIELD ) ) {
2015-12-05 00:01:56 +00:00
fprintf ( stderr , " Size mismatch: "
2015-12-16 00:07:16 +00:00
" requested size(%llu) != st_size(%llu) \n " ,
2016-08-31 16:31:53 +00:00
zero_extend_signed_to_ull ( SAMPLE_SIZE ) ,
2017-03-18 18:19:07 +03:00
zero_extend_signed_to_ull ( st - > ST_SIZE_FIELD ) ) ;
2015-12-05 00:01:56 +00:00
fprintf ( stderr , " The most likely reason for this is incorrect "
" definition of %s. \n "
" Here is some diagnostics that might help: \n " ,
STRUCT_STAT_STR ) ;
2017-01-12 23:01:32 +00:00
2017-03-18 18:19:07 +03:00
# define LOG_STAT_OFFSETOF_SIZEOF(object, member) \
2017-01-12 23:01:32 +00:00
fprintf ( stderr , " offsetof(%s, %s) = %zu " \
" , sizeof(%s) = %zu \n " , \
STRUCT_STAT_STR , # member , \
offsetof ( STRUCT_STAT , member ) , \
# member, sizeof((object).member))
2017-03-18 18:19:07 +03:00
# if IS_STATX
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_mask ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_blksize ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_attributes ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_nlink ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_uid ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_gid ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_mode ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_ino ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_size ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_blocks ) ;
2017-04-15 11:43:12 +03:00
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_attributes_mask ) ;
2017-03-18 18:19:07 +03:00
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_atime ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_btime ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_ctime ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_mtime ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_rdev_major ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_rdev_minor ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_dev_major ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , stx_dev_minor ) ;
# else
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_dev ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_ino ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_mode ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_nlink ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_uid ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_gid ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_rdev ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_size ) ;
# if !OLD_STAT
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_blksize ) ;
LOG_STAT_OFFSETOF_SIZEOF ( * st , st_blocks ) ;
# endif /* !OLD_STAT */
# endif /* IS_STATX */
2017-01-12 23:01:32 +00:00
2017-01-13 01:14:51 +00:00
return 1 ;
2015-12-05 00:01:56 +00:00
}
PRINT_SYSCALL_HEADER ( sample ) ;
2016-10-24 04:50:36 +03:00
if ( rc )
printf ( " %p " , st ) ;
else
print_stat ( st ) ;
2016-10-19 11:11:41 +03:00
PRINT_SYSCALL_FOOTER ( rc ) ;
2015-12-05 00:01:56 +00:00
2017-03-18 18:19:07 +03:00
# if IS_STATX
2017-06-17 21:47:57 +00:00
# define INVOKE() \
do { \
rc = TEST_SYSCALL_INVOKE ( sample , st ) ; \
PRINT_SYSCALL_HEADER ( sample ) ; \
if ( rc ) \
printf ( " %p " , st ) ; \
else \
print_stat ( st ) ; \
PRINT_SYSCALL_FOOTER ( rc ) ; \
} while ( 0 )
# define SET_FLAGS_INVOKE(flags, flags_str) \
do { \
TEST_SYSCALL_STATX_FLAGS = flags ; \
TEST_SYSCALL_STATX_FLAGS_STR = flags_str ; \
INVOKE ( ) ; \
} while ( 0 )
# define SET_MASK_INVOKE(mask, mask_str) \
do { \
TEST_SYSCALL_STATX_MASK = mask ; \
TEST_SYSCALL_STATX_MASK_STR = mask_str ; \
INVOKE ( ) ; \
} while ( 0 )
2017-03-18 18:19:07 +03:00
unsigned old_flags = TEST_SYSCALL_STATX_FLAGS ;
const char * old_flags_str = TEST_SYSCALL_STATX_FLAGS_STR ;
unsigned old_mask = TEST_SYSCALL_STATX_MASK ;
const char * old_mask_str = TEST_SYSCALL_STATX_MASK_STR ;
SET_FLAGS_INVOKE ( AT_SYMLINK_FOLLOW | 0xffff0000U ,
" AT_STATX_SYNC_AS_STAT|AT_SYMLINK_FOLLOW|0xffff0000 " ) ;
SET_FLAGS_INVOKE ( AT_STATX_SYNC_TYPE ,
" AT_STATX_FORCE_SYNC|AT_STATX_DONT_SYNC " ) ;
SET_FLAGS_INVOKE ( 0xffffff ,
" AT_STATX_FORCE_SYNC|AT_STATX_DONT_SYNC|AT_SYMLINK_NOFOLLOW| "
" AT_REMOVEDIR|AT_SYMLINK_FOLLOW|AT_NO_AUTOMOUNT|AT_EMPTY_PATH| "
" 0xff80ff " ) ;
/* We're done playing with flags. */
TEST_SYSCALL_STATX_FLAGS = old_flags ;
TEST_SYSCALL_STATX_FLAGS_STR = old_flags_str ;
SET_MASK_INVOKE ( 0 , " 0 " ) ;
SET_MASK_INVOKE ( 0xfffff000U , " 0xfffff000 /* STATX_??? */ " ) ;
SET_MASK_INVOKE ( 0xfffffffbU ,
" STATX_TYPE|STATX_MODE|STATX_UID|STATX_GID|STATX_ATIME| "
" STATX_MTIME|STATX_CTIME|STATX_INO|STATX_SIZE|STATX_BLOCKS| "
" STATX_BTIME|0xfffff000 " ) ;
SET_MASK_INVOKE ( STATX_UID , " STATX_UID " ) ;
/* ...and with mask. */
TEST_SYSCALL_STATX_MASK = old_mask ;
TEST_SYSCALL_STATX_MASK_STR = old_mask_str ;
# endif /* IS_STATX */
2015-12-05 00:01:56 +00:00
puts ( " +++ exited with 0 +++ " ) ;
return 0 ;
}
# else
2016-01-05 22:37:42 +00:00
SKIP_MAIN_UNDEFINED ( " HAVE_FTRUNCATE && HAVE_FUTIMENS " )
2015-12-05 00:01:56 +00:00
# endif