strace/tests/xstatx.c
Eugene Syromyatnikov 13c467bf69 tests: fix "constant is too large" compilation warnings
alarm.c: In function 'main':
alarm.c:41: warning: integer constant is too large for 'long' type
aio.c: In function 'main':
aio.c:162: warning: integer constant is too large for 'long' type
btrfs.c: In function 'btrfs_test_sync_ioctls':
btrfs.c:202: warning: integer constant is too large for 'long' type
btrfs.c: In function 'btrfs_test_subvol_ioctls':
btrfs.c:289: warning: integer constant is too large for 'long' type
btrfs.c:290: warning: integer constant is too large for 'long' type
dup2.c: In function 'main':
dup2.c:12: warning: integer constant is too large for 'long' type
dup2.c:13: warning: integer constant is too large for 'long' type
dup3.c: In function 'main':
dup3.c:13: warning: integer constant is too large for 'long' type
dup3.c:14: warning: integer constant is too large for 'long' type
epoll_create.c: In function 'main':
epoll_create.c:12: warning: integer constant is too large for 'long' type
epoll_ctl.c: In function 'invoke_syscall':
epoll_ctl.c:14: warning: integer constant is too large for 'long' type
faccessat.c: In function 'main':
faccessat.c:13: warning: integer constant is too large for 'long' type
fchdir.c: In function 'main':
fchdir.c:12: warning: integer constant is too large for 'long' type
struct_flock.c: In function 'invoke_test_syscall':
struct_flock.c:48: warning: integer constant is too large for 'long' type
struct_flock.c: In function 'test_flock_einval':
struct_flock.c:58: warning: integer constant is too large for 'long' type
struct_flock.c:59: warning: integer constant is too large for 'long' type
fcntl64.c: In function 'test_flock64_einval':
fcntl64.c:44: warning: integer constant is too large for 'long' type
fcntl64.c:45: warning: integer constant is too large for 'long' type
fcntl.c: In function 'test_flock64_einval':
fcntl.c:44: warning: integer constant is too large for 'long' type
fcntl.c:45: warning: integer constant is too large for 'long' type
fdatasync.c: In function 'main':
fdatasync.c:12: warning: integer constant is too large for 'long' type
flock.c: In function 'main':
flock.c:13: warning: integer constant is too large for 'long' type
xstatx.c: In function 'main':
xstatx.c:255: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:290: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatx.c:294: warning: integer constant is too large for 'long' type
xstatfsx.c: In function 'main':
xstatfsx.c:113: warning: integer constant is too large for 'long' type
fsync.c: In function 'main':
fsync.c:12: warning: integer constant is too large for 'long' type
ftruncate64.c: In function 'main':
ftruncate64.c:39: warning: integer constant is too large for 'long' type
futimesat.c: In function 'main':
futimesat.c:52: warning: integer constant is too large for 'long' type
futimesat.c:59: warning: integer constant is too large for 'long' type
get_mempolicy.c: In function 'main':
get_mempolicy.c:83: warning: integer constant is too large for 'long' type
get_mempolicy.c:84: warning: integer constant is too large for 'long' type
get_mempolicy.c:85: warning: integer constant is too large for 'long' type
get_mempolicy.c:86: warning: integer constant is too large for 'long' type
getdents.c: In function 'main':
getdents.c:109: warning: integer constant is too large for 'long' type
getdents.c:110: warning: integer constant is too large for 'long' type
getdents.c:114: warning: integer constant is too large for 'long' type
getdents64.c: In function 'main':
getdents64.c:114: warning: integer constant is too large for 'long' type
getdents64.c:115: warning: integer constant is too large for 'long' type
getdents64.c:119: warning: integer constant is too large for 'long' type
xgetrlimit.c: In function 'main':
xgetrlimit.c:71: warning: integer constant is too large for 'long' type
ioctl_block.c:44: warning: integer constant is too large for 'long' type
ioctl_block.c: In function 'main':
ioctl_block.c:136: warning: integer constant is too large for 'long' type
ioctl_block.c:137: warning: integer constant is too large for 'long' type
ioctl_block.c:161: warning: integer constant is too large for 'long' type
ioctl_block.c:170: warning: integer constant is too large for 'long' type
ioctl_block.c:171: warning: integer constant is too large for 'long' type
ioctl_evdev.c:42: warning: integer constant is too large for 'long' type
ioctl_mtd.c:46: warning: integer constant is too large for 'long' type
ioctl_rtc.c:40: warning: integer constant is too large for 'long' type
ioperm.c: In function 'main':
ioperm.c:12: warning: integer constant is too large for 'long' type
ioctl_v4l2.c: In function 'main':
ioctl_v4l2.c:409: warning: integer constant is too large for 'long' type
ipc.c: In function 'ipc_call':
ipc.c:52: warning: integer constant is too large for 'long' type
kill.c: In function 'main':
kill.c:59: warning: integer constant is too large for 'long' type
kill.c:62: warning: integer constant is too large for 'long' type
kill.c:63: warning: integer constant is too large for 'long' type
kill.c:68: warning: integer constant is too large for 'long' type
linkat.c: In function 'main':
linkat.c:14: warning: integer constant is too large for 'long' type
linkat.c:15: warning: integer constant is too large for 'long' type
mbind.c: In function 'main':
mbind.c:41: warning: integer constant is too large for 'long' type
mbind.c:43: warning: integer constant is too large for 'long' type
mbind.c:44: warning: integer constant is too large for 'long' type
migrate_pages.c: In function 'main':
migrate_pages.c:41: warning: integer constant is too large for 'long' type
In file included from mkdirat.c:10:
umode_t.c: In function 'test_syscall':
umode_t.c:47: warning: integer constant is too large for 'long' type
mknod.c: In function 'call_mknod':
mknod.c:16: warning: integer constant is too large for 'long' type
mknod.c: In function 'main':
mknod.c:23: warning: integer constant is too large for 'long' type
mknod.c:49: warning: integer constant is too large for 'long' type
mknod.c:56: warning: integer constant is too large for 'long' type
mknodat.c:12: warning: integer constant is too large for 'long' type
mknodat.c: In function 'call_mknodat':
mknodat.c:17: warning: integer constant is too large for 'long' type
mknodat.c: In function 'main':
mknodat.c:24: warning: integer constant is too large for 'long' type
mknodat.c:50: warning: integer constant is too large for 'long' type
mknodat.c:57: warning: integer constant is too large for 'long' type
mmap.c: In function 'main':
mmap.c:51: warning: integer constant is too large for 'long' type
move_pages.c: In function 'print_stat_pages':
move_pages.c:139: warning: integer constant is too large for 'long' type
move_pages.c: In function 'print_move_pages':
move_pages.c:166: warning: integer constant is too large for 'long' type
move_pages.c: In function 'main':
move_pages.c:188: warning: integer constant is too large for 'long' type
mq_sendrecv.c: In function 'main':
mq_sendrecv.c:238: warning: integer constant is too large for 'long' type
mq_sendrecv.c:401: warning: integer constant is too large for 'long' type
mq_sendrecv.c:403: warning: integer constant is too large for 'long' type
nsyscalls.c: In function 'test_syscall':
nsyscalls.c:64: warning: integer constant is too large for 'long' type
nsyscalls.c:65: warning: integer constant is too large for 'long' type
nsyscalls.c:66: warning: integer constant is too large for 'long' type
nsyscalls.c:67: warning: integer constant is too large for 'long' type
nsyscalls.c:68: warning: integer constant is too large for 'long' type
nsyscalls.c:69: warning: integer constant is too large for 'long' type
preadv-pwritev.c: In function 'main':
preadv-pwritev.c:162: warning: comparison between signed and unsigned
prlimit64.c: In function 'main':
prlimit64.c:65: warning: integer constant is too large for 'long' type
prlimit64.c:70: warning: integer constant is too large for 'long' type
remap_file_pages.c: In function 'main':
remap_file_pages.c:42: warning: integer constant is too large for 'long' type
remap_file_pages.c:43: warning: integer constant is too large for 'long' type
remap_file_pages.c:45: warning: integer constant is too large for 'long' type
renameat.c: In function 'main':
renameat.c:15: warning: integer constant is too large for 'long' type
renameat.c:16: warning: integer constant is too large for 'long' type
rt_sigqueueinfo.c: In function 'main':
rt_sigqueueinfo.c:41: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c: In function 'k_tgsigqueueinfo':
rt_tgsigqueueinfo.c:45: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c:46: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c:47: warning: integer constant is too large for 'long' type
rt_tgsigqueueinfo.c: In function 'main':
rt_tgsigqueueinfo.c:67: warning: integer constant is too large for 'long' type
sendfile.c: In function 'main':
sendfile.c:110: warning: integer constant is too large for 'long' type
sendfile64.c: In function 'main':
sendfile64.c💯 warning: integer constant is too large for 'long' type
set_mempolicy.c: In function 'main':
set_mempolicy.c:129: warning: integer constant is too large for 'long' type
set_mempolicy.c:130: warning: integer constant is too large for 'long' type
setrlimit.c: In function 'main':
setrlimit.c:44: warning: integer constant is too large for 'long' type
socketcall.c: In function 'test_socketcall':
socketcall.c:58: warning: integer constant is too large for 'long' type
splice.c: In function 'main':
splice.c:41: warning: integer constant is too large for 'long' type
splice.c:42: warning: integer constant is too large for 'long' type
splice.c:45: warning: integer constant is too large for 'long' type
splice.c:46: warning: integer constant is too large for 'long' type
symlinkat.c: In function 'main':
symlinkat.c:12: warning: integer constant is too large for 'long' type
sync_file_range.c: In function 'main':
sync_file_range.c:42: warning: integer constant is too large for 'long' type
sync_file_range.c:43: warning: integer constant is too large for 'long' type
syslog.c: In function 'main':
syslog.c:14: warning: integer constant is too large for 'long' type
tee.c: In function 'main':
tee.c:41: warning: integer constant is too large for 'long' type
tee.c:42: warning: integer constant is too large for 'long' type
timer_create.c: In function 'main':
timer_create.c:52: warning: integer constant is too large for 'long' type
timer_create.c:84: warning: integer constant is too large for 'long' type
timer_create.c:85: warning: integer constant is too large for 'long' type
truncate64.c: In function 'main':
truncate64.c:41: warning: integer constant is too large for 'long' type
xgetrlimit.c: In function 'main':
xgetrlimit.c:71: warning: integer constant is too large for 'long' type
umode_t.c: In function 'test_syscall':
umode_t.c:46: warning: integer constant is too large for 'long' type
unlinkat.c: In function 'main':
unlinkat.c:13: warning: integer constant is too large for 'long' type
waitpid.c: In function 'main':
waitpid.c:43: warning: integer constant is too large for 'long' type
waitid.c: In function 'poison':
waitid.c:141: warning: integer constant is too large for 'long' type
xetpriority.c: In function 'main':
xetpriority.c:15: warning: integer constant is too large for 'long' type
xetpriority.c:19: warning: integer constant is too large for 'long' type
xetpriority.c:20: warning: integer constant is too large for 'long' type
xetpgid.c: In function 'main':
xetpgid.c:43: warning: integer constant is too large for 'long' type
xetpgid.c:47: warning: integer constant is too large for 'long' type
xetpgid.c:48: warning: integer constant is too large for 'long' type

(SLES 11SP4, i386)

* tests/alarm.c (main): Add proper suffix to integer constant.
* tests/aio.c (main): Likewise.
* tests/btrfs.c (btrfs_test_sync_ioctls, btrfs_test_subvol_ioctls): Likewise.
* tests/dup2.c (main): Likewise.
* tests/dup3.c (main): Likewise.
* tests/epoll_create.c (main): Likewise.
* tests/epoll_ctl.c (invoke_syscall): Likewise.
* tests/faccessat.c (main): Likewise.
* tests/fchdir.c (main): Likewise.
* tests/fcntl.c (test_flock64_einval): Likewise.
* tests/fcntl64.c (test_flock64_einval): Likewise.
* tests/fdatasync.c (main): Likewise.
* tests/flock.c (main): Likewise.
* tests/fstat64.c (SAMPLE_SIZE): Likewise.
* tests/fstat.c (SAMPLE_SIZE): Likewise.
* tests/fsync.c (main): Likewise.
* tests/ftruncate64.c (main): Likewise.
* tests/futimesat.c (main): Likewise.
* tests/get_mempolicy.c (main): Likewise.
* tests/getdents.c (main): Likewise.
* tests/getdents64.c (main): Likewise.
* tests/ioctl_block.c (lmagic, main): Likewise.
* tests/ioctl_evdev.c (lmagic): Likewise.
* tests/ioctl_mtd.c (lmagic): Likewise.
* tests/ioctl_rtc.c (lmagic): Likewise.
* tests/ioctl_v4l2.c (main): Likewise.
* tests/ioperm.c (main): Likewise.
* tests/ipc.c (ipc_call): Likewise.
* tests/kill.c (main): Likewise.
* tests/linkat.c (main): Likewise.
* tests/lstat64.c (SAMPLE_SIZE): Likewise.
* tests/lstat.c (SAMPLE_SIZE): Likewise.
* tests/mbind.c (main): Likewise.
* tests/migrate_pages.c (main): Likewise.
* tests/mkdirat.c (TEST_SYSCALL_PREFIX_ARGS): Likewise.
* tests/mknod.c (call_mknod, main): Likewise.
* tests/mknodat.c (fd, call_mknodat, main): Likewise.
* tests/mmap.c (main): Likewise.
* tests/move_pages.c (print_stat_pages, print_move_pages): Likewise.
* tests/mq_sendrecv.c (main): Likewise.
* tests/nsyscalls.c (test_syscall): Likewise.
* tests/prlimit64.c (main): Likewise.
* tests/remap_file_pages.c (main): Likewise.
* tests/renameat.c (main): Likewise.
* tests/rt_sigqueueinfo.c (main): Likewise.
* tests/rt_tgsigqueueinfo.c (k_tgsigqueueinfo, main): Likewise.
* tests/sendfile.c (main): Likewise.
* tests/sendfile64.c (main): Likewise.
* tests/set_mempolicy.c (main): Likewise.
* tests/setrlimit.c (main): Likewise.
* tests/socketcall.c (test_socketcall): Likewise.
* tests/splice.c (main): Likewise.
* tests/stat64.c (SAMPLE_SIZE): Likewise.
* tests/stat.c (SAMPLE_SIZE): Likewise.
* tests/struct_flock.c (invoke_test_syscall, test_flock_einval): Likewise.
* tests/symlinkat.c (main): Likewise.
* tests/sync_file_range.c (main): Likewise.
* tests/syslog.c (main): Likewise.
* tests/tee.c (main): Likewise.
* tests/timer_create.c (main): Likewise.
* tests/truncate64.c (main): Likewise.
* tests/umode_t.c (test_syscall): Likewise.
* tests/unlinkat.c (main): Likewise.
* tests/waitid.c (main): Likewise.
* tests/waitpid.c (main): Likewise.
* tests/xetpgid.c (main): Likewise.
* tests/xetpriority.c (main): Likewise.
* tests/xgetrlimit.c (main): Likewise.
* tests/xstatfsx.c (main) [CHECK_ODD_SIZE]: Likewise.
* tests/xstatx.c (main): Likewise.
2016-11-13 21:36:58 +00:00

361 lines
10 KiB
C

/*
* Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
* 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.
*/
#if defined HAVE_FTRUNCATE && defined HAVE_FUTIMENS
# ifndef TEST_SYSCALL_STR
# error TEST_SYSCALL_STR must be defined
# endif
# 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
# include <errno.h>
# include <stdio.h>
# include <stddef.h>
# include <time.h>
# include <unistd.h>
# include <sys/sysmacros.h>
static void
print_time(const time_t t)
{
if (!t) {
printf("0");
return;
}
struct tm *p = localtime(&t);
if (p)
printf("%02d/%02d/%02d-%02d:%02d:%02d",
p->tm_year + 1900, p->tm_mon + 1, p->tm_mday,
p->tm_hour, p->tm_min, p->tm_sec);
else
printf("%llu", zero_extend_signed_to_ull(t));
}
# ifndef STRUCT_STAT
# define STRUCT_STAT struct stat
# define STRUCT_STAT_STR "struct stat"
# define STRUCT_STAT_IS_STAT64 0
# endif
# ifndef SAMPLE_SIZE
# define SAMPLE_SIZE 43147718418ULL
# endif
typedef off_t libc_off_t;
# ifdef USE_ASM_STAT
# define stat libc_stat
# define stat64 libc_stat64
# endif
# include <fcntl.h>
# include <sys/stat.h>
# ifdef USE_ASM_STAT
# undef stat
# undef stat64
# endif
# ifdef USE_ASM_STAT
# undef st_atime
# undef st_mtime
# undef st_ctime
# include "asm_stat.h"
# if STRUCT_STAT_IS_STAT64
# undef HAVE_STRUCT_STAT_ST_MTIME_NSEC
# 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
# define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
# 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 */
# else /* !USE_ASM_STAT */
# undef HAVE_STRUCT_STAT_ST_MTIME_NSEC
# ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
# define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
# undef st_atime_nsec
# define st_atime_nsec st_atim.tv_nsec
# undef st_ctime_nsec
# define st_ctime_nsec st_ctim.tv_nsec
# undef st_mtime_nsec
# define st_mtime_nsec st_mtim.tv_nsec
# endif /* HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC */
# endif
# ifndef TEST_BOGUS_STRUCT_STAT
# define TEST_BOGUS_STRUCT_STAT 1
# endif
# ifndef IS_FSTAT
# define IS_STAT 0
# endif
# ifndef OLD_STAT
# define OLD_STAT 0
# endif
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);
}
static void
print_stat(const STRUCT_STAT *st)
{
printf("{st_dev=makedev(%u, %u)",
(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));
printf(", st_mode=");
print_ftype(st->st_mode);
printf("|");
print_perms(st->st_mode);
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));
# if OLD_STAT
printf(", st_blksize=0, st_blocks=0");
# else /* !OLD_STAT */
printf(", st_blksize=%llu", zero_extend_signed_to_ull(st->st_blksize));
printf(", st_blocks=%llu", zero_extend_signed_to_ull(st->st_blocks));
# endif /* OLD_STAT */
switch (st->st_mode & S_IFMT) {
case S_IFCHR: case S_IFBLK:
printf(", st_rdev=makedev(%u, %u)",
(unsigned int) major(zero_extend_signed_to_ull(st->st_rdev)),
(unsigned int) minor(zero_extend_signed_to_ull(st->st_rdev)));
break;
default:
printf(", st_size=%llu", zero_extend_signed_to_ull(st->st_size));
}
printf(", st_atime=");
print_time(sign_extend_unsigned_to_ll(st->st_atime));
# if defined(HAVE_STRUCT_STAT_ST_MTIME_NSEC) && !OLD_STAT
if (st->st_atime_nsec)
printf(".%09llu", zero_extend_signed_to_ull(st->st_atime_nsec));
# endif
printf(", st_mtime=");
print_time(sign_extend_unsigned_to_ll(st->st_mtime));
# if defined(HAVE_STRUCT_STAT_ST_MTIME_NSEC) && !OLD_STAT
if (st->st_mtime_nsec)
printf(".%09llu", zero_extend_signed_to_ull(st->st_mtime_nsec));
# endif
printf(", st_ctime=");
print_time(sign_extend_unsigned_to_ll(st->st_ctime));
# if defined(HAVE_STRUCT_STAT_ST_MTIME_NSEC) && !OLD_STAT
if (st->st_ctime_nsec)
printf(".%09llu", zero_extend_signed_to_ull(st->st_ctime_nsec));
# endif
printf("}");
}
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)
{
# if !IS_FSTAT
static const char full[] = "/dev/full";
# endif
static const char sample[] = TEST_SYSCALL_STR ".sample";
STRUCT_STAT st[2];
int rc;
rc = create_sample(sample, SAMPLE_SIZE);
if (rc) {
(void) unlink(sample);
return rc;
}
# 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
if ((rc = TEST_SYSCALL_INVOKE(sample, st))) {
# if OLD_STAT
if (errno != EOVERFLOW)
# endif
{
perror(TEST_SYSCALL_STR);
(void) unlink(sample);
return 77;
}
}
(void) unlink(sample);
if (!rc && zero_extend_signed_to_ull(SAMPLE_SIZE) !=
zero_extend_signed_to_ull(st[0].st_size)) {
fprintf(stderr, "Size mismatch: "
"requested size(%llu) != st_size(%llu)\n",
zero_extend_signed_to_ull(SAMPLE_SIZE),
zero_extend_signed_to_ull(st[0].st_size));
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);
fprintf(stderr, "offsetof(%s, st_dev) = %zu"
", sizeof(st_dev) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_dev),
sizeof(st[0].st_dev));
fprintf(stderr, "offsetof(%s, st_ino) = %zu"
", sizeof(st_ino) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_ino),
sizeof(st[0].st_ino));
fprintf(stderr, "offsetof(%s, st_mode) = %zu"
", sizeof(st_mode) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_mode),
sizeof(st[0].st_mode));
fprintf(stderr, "offsetof(%s, st_nlink) = %zu"
", sizeof(st_nlink) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_nlink),
sizeof(st[0].st_nlink));
fprintf(stderr, "offsetof(%s, st_uid) = %zu"
", sizeof(st_uid) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_uid),
sizeof(st[0].st_uid));
fprintf(stderr, "offsetof(%s, st_gid) = %zu"
", sizeof(st_gid) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_gid),
sizeof(st[0].st_gid));
fprintf(stderr, "offsetof(%s, st_rdev) = %zu"
", sizeof(st_rdev) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_rdev),
sizeof(st[0].st_rdev));
fprintf(stderr, "offsetof(%s, st_size) = %zu"
", sizeof(st_size) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_size),
sizeof(st[0].st_size));
# if !OLD_STAT
fprintf(stderr, "offsetof(%s, st_blksize) = %zu"
", sizeof(st_blksize) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_blksize),
sizeof(st[0].st_blksize));
fprintf(stderr, "offsetof(%s, st_blocks) = %zu"
", sizeof(st_blocks) = %zu\n",
STRUCT_STAT_STR, offsetof(STRUCT_STAT, st_blocks),
sizeof(st[0].st_blocks));
# endif /* !OLD_STAT */
return 77;
}
PRINT_SYSCALL_HEADER(sample);
if (rc)
printf("%p", st);
else
print_stat(st);
PRINT_SYSCALL_FOOTER(rc);
puts("+++ exited with 0 +++");
return 0;
}
#else
SKIP_MAIN_UNDEFINED("HAVE_FTRUNCATE && HAVE_FUTIMENS")
#endif