30#ifndef XROOTD_XRDSYSSTATX_HH
31#define XROOTD_XRDSYSSTATX_HH
38#if defined(__linux__) || defined(__GNU__)
39#include <sys/sysmacros.h>
48#define STATX_BASIC_STATS 0x0000003f
49#define STATX_ALL 0x0000013f
50#define STATX_BTIME 0x00000100
58class XrdSysStatxHelpers {
79 static void StatxT2StatT(
const statx_timestamp & stx_T,
struct timespec & sta_T);
86 static void StatT2StatxT(
const struct timespec & sta_T,
statx_timestamp & stx_T);
96 return buf.
statx.st_size;
101inline void XrdSysStatxHelpers::StatxT2StatT(
const statx_timestamp & stx_T,
struct timespec & sta_T) {
102 sta_T.tv_sec = stx_T.tv_sec;
103 sta_T.tv_nsec = stx_T.tv_nsec;
106inline void XrdSysStatxHelpers::StatT2StatxT(
const struct timespec & sta_T,
statx_timestamp & stx_T) {
107 stx_T.tv_sec = sta_T.tv_sec;
108 stx_T.tv_nsec = sta_T.tv_nsec;
111inline void XrdSysStatxHelpers::Stat2Statx(
const struct stat & st,
XrdSysStatx & stx) {
113 memset(&stx, 0,
sizeof(stx));
115 stx.stx_blksize = st.st_blksize;
116 stx.stx_nlink = st.st_nlink;
117 stx.stx_uid = st.st_uid;
118 stx.stx_gid = st.st_gid;
119 stx.stx_mode = st.st_mode;
120 stx.stx_ino = st.st_ino;
121 stx.stx_size = st.st_size;
122 stx.stx_blocks = st.st_blocks;
123 StatT2StatxT(st.st_atim, stx.stx_atime);
124 StatT2StatxT(st.st_mtim, stx.stx_mtime);
125 StatT2StatxT(st.st_ctim, stx.stx_ctime);
126 stx.stx_dev_major = major(st.st_dev);
127 stx.stx_dev_minor = minor(st.st_dev);
128 stx.stx_rdev_major = major(st.st_rdev);
129 stx.stx_rdev_minor = minor(st.st_rdev);
137inline void XrdSysStatxHelpers::Statx2Stat(
const XrdSysStatx & stx,
struct stat & st) {
139 memset(&st, 0,
sizeof(st));
148 st.st_nlink = stx.stx_nlink;
150 st.st_uid = stx.stx_uid;
152 st.st_gid = stx.stx_gid;
154 st.st_mode = stx.stx_mode;
156 st.st_ino = stx.stx_ino;
158 st.st_size = stx.stx_size;
160 st.st_blocks = stx.stx_blocks;
162 StatxT2StatT(stx.stx_atime, st.st_atim);
164 StatxT2StatT(stx.stx_mtime, st.st_mtim);
166 StatxT2StatT(stx.stx_ctime, st.st_ctim);
169 st.st_dev = makedev(stx.stx_dev_major, stx.stx_dev_minor);
170 st.st_rdev = makedev(stx.stx_rdev_major, stx.stx_rdev_minor);
171 st.st_blksize = stx.stx_blksize;
#define statx(d, p, f, m, b)
struct timespec statx_timestamp
#define STATX_BASIC_STATS