mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-30 13:56:45 -04:00
unix: add Statx on Linux
statx(2) allows to get enhanced file status information (not currently available through the existing stat syscalls), lightweight stat, heavyweight stat. The Statx_t type used by Statx has consistent field sizes on all arches (with year-2038-capable timestamps) and is closer to the BSD implementation of Stat_t. See http://man7.org/linux/man-pages/man2/statx.2.html for details. The syscall was added in Linux kernel 4.11. See https://github.com/tklauser/statx for an example of how this function and types can be used to report stat(1)-like file status information. Change-Id: I9e9642b5b42a393f94fd532453888ce9ba4f0003 Reviewed-on: https://go-review.googlesource.com/87555 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
52ba35ddf9
commit
fff93fa7cd
+30
-4
@@ -47,11 +47,12 @@ package unix
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/wait.h>
|
||||
#include <linux/filter.h>
|
||||
#include <linux/icmpv6.h>
|
||||
#include <linux/keyctl.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/icmpv6.h>
|
||||
#include <linux/stat.h>
|
||||
#include <asm/termbits.h>
|
||||
#include <asm/ptrace.h>
|
||||
#include <time.h>
|
||||
@@ -116,6 +117,21 @@ struct stat {
|
||||
|
||||
#endif
|
||||
|
||||
// These are defined in linux/fcntl.h, but including it globally causes
|
||||
// conflicts with fcntl.h
|
||||
#ifndef AT_STATX_SYNC_TYPE
|
||||
# define AT_STATX_SYNC_TYPE 0x6000 // Type of synchronisation required from statx()
|
||||
#endif
|
||||
#ifndef AT_STATX_SYNC_AS_STAT
|
||||
# define AT_STATX_SYNC_AS_STAT 0x0000 // - Do whatever stat() does
|
||||
#endif
|
||||
#ifndef AT_STATX_FORCE_SYNC
|
||||
# define AT_STATX_FORCE_SYNC 0x2000 // - Force the attributes to be sync'd with the server
|
||||
#endif
|
||||
#ifndef AT_STATX_DONT_SYNC
|
||||
# define AT_STATX_DONT_SYNC 0x4000 // - Don't sync attributes with the server
|
||||
#endif
|
||||
|
||||
#ifdef TCSETS2
|
||||
// On systems that have "struct termios2" use this as type Termios.
|
||||
typedef struct termios2 termios_t;
|
||||
@@ -249,6 +265,10 @@ type Stat_t C.struct_stat
|
||||
|
||||
type Statfs_t C.struct_statfs
|
||||
|
||||
type StatxTimestamp C.struct_statx_timestamp
|
||||
|
||||
type Statx_t C.struct_statx
|
||||
|
||||
type Dirent C.struct_dirent
|
||||
|
||||
type Fsid C.fsid_t
|
||||
@@ -513,9 +533,15 @@ type Ustat_t C.struct_ustat
|
||||
type EpollEvent C.struct_my_epoll_event
|
||||
|
||||
const (
|
||||
AT_FDCWD = C.AT_FDCWD
|
||||
AT_NO_AUTOMOUNT = C.AT_NO_AUTOMOUNT
|
||||
AT_REMOVEDIR = C.AT_REMOVEDIR
|
||||
AT_EMPTY_PATH = C.AT_EMPTY_PATH
|
||||
AT_FDCWD = C.AT_FDCWD
|
||||
AT_NO_AUTOMOUNT = C.AT_NO_AUTOMOUNT
|
||||
AT_REMOVEDIR = C.AT_REMOVEDIR
|
||||
|
||||
AT_STATX_SYNC_AS_STAT = C.AT_STATX_SYNC_AS_STAT
|
||||
AT_STATX_FORCE_SYNC = C.AT_STATX_FORCE_SYNC
|
||||
AT_STATX_DONT_SYNC = C.AT_STATX_DONT_SYNC
|
||||
|
||||
AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
|
||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user