statx emulation through fstatat
| 351 | |
| 352 | //! statx emulation through fstatat |
| 353 | int statx_fstatat(int dirfd, const char* path, int flags, unsigned int mask, struct ::statx* stx) |
| 354 | { |
| 355 | struct ::stat st; |
| 356 | flags &= AT_EMPTY_PATH | AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW; |
| 357 | int res = ::fstatat(dirfd, path, &st, flags); |
| 358 | if (BOOST_LIKELY(res == 0)) |
| 359 | { |
| 360 | std::memset(stx, 0, sizeof(*stx)); |
| 361 | stx->stx_mask = STATX_BASIC_STATS; |
| 362 | stx->stx_blksize = st.st_blksize; |
| 363 | stx->stx_nlink = st.st_nlink; |
| 364 | stx->stx_uid = st.st_uid; |
| 365 | stx->stx_gid = st.st_gid; |
| 366 | stx->stx_mode = st.st_mode; |
| 367 | stx->stx_ino = st.st_ino; |
| 368 | stx->stx_size = st.st_size; |
| 369 | stx->stx_blocks = st.st_blocks; |
| 370 | stx->stx_atime.tv_sec = st.st_atim.tv_sec; |
| 371 | stx->stx_atime.tv_nsec = st.st_atim.tv_nsec; |
| 372 | stx->stx_ctime.tv_sec = st.st_ctim.tv_sec; |
| 373 | stx->stx_ctime.tv_nsec = st.st_ctim.tv_nsec; |
| 374 | stx->stx_mtime.tv_sec = st.st_mtim.tv_sec; |
| 375 | stx->stx_mtime.tv_nsec = st.st_mtim.tv_nsec; |
| 376 | stx->stx_rdev_major = major(st.st_rdev); |
| 377 | stx->stx_rdev_minor = minor(st.st_rdev); |
| 378 | stx->stx_dev_major = major(st.st_dev); |
| 379 | stx->stx_dev_minor = minor(st.st_dev); |
| 380 | } |
| 381 | |
| 382 | return res; |
| 383 | } |
| 384 | |
| 385 | typedef int statx_t(int dirfd, const char* path, int flags, unsigned int mask, struct ::statx* stx); |
| 386 |