/memcheck/tests/linux/stack_changes
/memcheck/tests/linux/stack_switch
/memcheck/tests/linux/syscalls-2007
+/memcheck/tests/linux/sys-statx
/memcheck/tests/linux/syslog-syscall
/memcheck/tests/linux/timerfd-syscall
/memcheck/tests/linux/proc-auxv
DECL_TEMPLATE(linux, sys_membarrier);
+// Linux-specific (new in Linux 4.11)
+DECL_TEMPLATE(linux, sys_statx);
+
/* ---------------------------------------------------------------------
Wrappers for sockets and ipc-ery. These are split into standalone
procedures because x86-linux hides them inside multiplexors
LINXY(__NR_memfd_create, sys_memfd_create), // 319
// LIN__(__NR_kexec_file_load, sys_ni_syscall), // 320
-// LIN__(__NR_bpf, sys_ni_syscall) // 321
+// LIN__(__NR_bpf, sys_ni_syscall), // 321
+
+
+ LINXY(__NR_statx, sys_statx), // 332
LINX_(__NR_membarrier, sys_membarrier), // 324
};
LINX_(__NR_renameat2, sys_renameat2), // 382
LINXY(__NR_getrandom, sys_getrandom), // 384
- LINXY(__NR_memfd_create, sys_memfd_create) // 385
+ LINXY(__NR_memfd_create, sys_memfd_create), // 385
+
+ LINXY(__NR_statx, sys_statx), // 397
};
// (__NR_pkey_mprotect, sys_ni_syscall), // 288
// (__NR_pkey_alloc, sys_ni_syscall), // 289
// (__NR_pkey_free, sys_ni_syscall), // 290
+
+ LINXY(__NR_statx, sys_statx), // 397
};
PRE_REG_READ1(long, "syncfs", unsigned int, fd);
}
+PRE(sys_statx)
+{
+ FUSE_COMPATIBLE_MAY_BLOCK();
+ PRINT("sys_statx ( %ld, %#" FMT_REGWORD "x(%s), %ld, %ld, %#" FMT_REGWORD "x )",
+ ARG1,ARG2,(char*)(Addr)ARG2,ARG3,ARG4,ARG5);
+ PRE_REG_READ5(long, "statx",
+ int, dirfd, char *, file_name, int, flags,
+ unsigned int, mask, struct statx *, buf);
+ PRE_MEM_RASCIIZ( "statx(file_name)", ARG2 );
+ PRE_MEM_WRITE( "statx(buf)", ARG5, sizeof(struct vki_statx) );
+}
+POST(sys_statx)
+{
+ POST_MEM_WRITE( ARG5, sizeof(struct vki_statx) );
+}
+
/* ---------------------------------------------------------------------
utime wrapper
------------------------------------------------------------------ */
LINXY(__NR_memfd_create, sys_memfd_create), // 354
//..
LINX_(__NR_membarrier, sys_membarrier), // 358
+ //..
+ LINXY(__NR_statx, sys_statx) // 366
};
SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
LINX_(__NR_process_vm_writev, sys_process_vm_writev),// 352
LINXY(__NR_getrandom, sys_getrandom), // 359
- LINXY(__NR_memfd_create, sys_memfd_create) // 360
+ LINXY(__NR_memfd_create, sys_memfd_create), // 360
+
+ LINXY(__NR_statx, sys_statx), // 383
};
SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
LINX_(__NR_renameat2, sys_renameat2), // 357
LINXY(__NR_getrandom, sys_getrandom), // 359
- LINXY(__NR_memfd_create, sys_memfd_create) // 360
+ LINXY(__NR_memfd_create, sys_memfd_create), // 360
+
+ LINXY(__NR_statx, sys_statx), // 383
};
SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
LINXY(__NR_recvmsg, sys_recvmsg), // 372
LINX_(__NR_shutdown, sys_shutdown), // 373
+ LINXY(__NR_statx, sys_statx), // 383
+
/* Explicitly not supported on i386 yet. */
GENX_(__NR_arch_prctl, sys_ni_syscall) // 384
};
#define VKI_S_IWOTH 00002
#define VKI_S_IXOTH 00001
+struct vki_statx_timestamp {
+ __vki_s64 tv_sec;
+ __vki_u32 tv_nsec;
+ __vki_s32 __reserved;
+};
+
+struct vki_statx {
+ /* 0x00 */
+ __vki_u32 stx_mask; /* What results were written [uncond] */
+ __vki_u32 stx_blksize; /* Preferred general I/O size [uncond] */
+ __vki_u64 stx_attributes; /* Flags conveying information about the file [uncond] */
+ /* 0x10 */
+ __vki_u32 stx_nlink; /* Number of hard links */
+ __vki_u32 stx_uid; /* User ID of owner */
+ __vki_u32 stx_gid; /* Group ID of owner */
+ __vki_u16 stx_mode; /* File mode */
+ __vki_u16 __spare0[1];
+ /* 0x20 */
+ __vki_u64 stx_ino; /* Inode number */
+ __vki_u64 stx_size; /* File size */
+ __vki_u64 stx_blocks; /* Number of 512-byte blocks allocated */
+ __vki_u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */
+ /* 0x40 */
+ struct vki_statx_timestamp stx_atime; /* Last access time */
+ struct vki_statx_timestamp stx_btime; /* File creation time */
+ struct vki_statx_timestamp stx_ctime; /* Last attribute change time */
+ struct vki_statx_timestamp stx_mtime; /* Last data modification time */
+ /* 0x80 */
+ __vki_u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
+ __vki_u32 stx_rdev_minor;
+ __vki_u32 stx_dev_major; /* ID of device containing file [uncond] */
+ __vki_u32 stx_dev_minor;
+ /* 0x90 */
+ __vki_u64 __spare2[14]; /* Spare space for future expansion */
+ /* 0x100 */
+};
+
+
//----------------------------------------------------------------------
// From linux-2.6.8.1/include/linux/dirent.h
//----------------------------------------------------------------------
syscalls-2007.vgtest syscalls-2007.stderr.exp \
syslog-syscall.vgtest syslog-syscall.stderr.exp \
sys-openat.vgtest sys-openat.stderr.exp sys-openat.stdout.exp \
+ sys-statx.vgtest sys-statx.stderr.exp \
timerfd-syscall.vgtest timerfd-syscall.stderr.exp \
with-space.stderr.exp with-space.stdout.exp with-space.vgtest \
proc-auxv.vgtest proc-auxv.stderr.exp getregset.vgtest \
stack_switch \
syscalls-2007 \
syslog-syscall \
+ sys-statx \
timerfd-syscall \
proc-auxv
--- /dev/null
+/* Test (somewhat) stats and stat. */
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <string.h>
+#include <sys/syscall.h>
+#include <linux/stat.h>
+#include <errno.h>
+
+int check_stat2;
+
+#define field(fieldname,s) s->st_##fieldname
+#if defined(__NR_statx)
+#define checkfield(fieldname) \
+ assert(!check_stat2 || stat1.st_##fieldname == stat2.stx_##fieldname)
+#else
+#define checkfield(fieldname) \
+ assert(!check_stat2 || stat1.st_##fieldname == stat2.st_##fieldname)
+#endif
+
+int main (void)
+{
+ struct stat stat1;
+
+ memset(&stat1, 0x55, sizeof(stat1));
+
+ assert (stat ("/tmp", &stat1) == 0);
+#if defined(__NR_statx)
+ struct statx stat2;
+ memset(&stat2, 0x22, sizeof(stat2));
+ if (syscall (__NR_statx, 0, "/tmp", 0, STATX_ALL, &stat2) == 0)
+ check_stat2 = 1;
+ else {
+ if (errno == ENOSYS)
+ check_stat2 = 0; // Defined but not provided by kernel.
+ else
+ check_stat2 = 1; // Probably better fail ...
+ }
+#else
+ struct stat stat2;
+ check_stat2 = 1;
+ memset(&stat2, 0x22, sizeof(stat2));
+ assert (stat ("/tmp", &stat2) == 0);
+#endif
+
+ checkfield(nlink);
+ checkfield(uid);
+ checkfield(gid);
+ checkfield(mode);
+ checkfield(ino);
+
+ return 0;
+}
--- /dev/null
+
+
+HEAP SUMMARY:
+ in use at exit: 0 bytes in 0 blocks
+ total heap usage: 0 allocs, 0 frees, 0 bytes allocated
+
+For a detailed leak analysis, rerun with: --leak-check=full
+
+For counts of detected and suppressed errors, rerun with: -v
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--- /dev/null
+prog: sys-statx