4 * Copyright (C) 2009 Analog Devices Inc.
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
9 #include <sys/syscall.h>
11 #include "xstatconv.h"
12 #include <bits/uClibc_arch_features.h>
14 /* 64bit ports tend to favor newfstatat() */
15 #if __WORDSIZE == 64 && defined __NR_newfstatat
16 # define __NR_fstatat64 __NR_newfstatat
19 #if defined(__NR_fstatat64) && !defined(__UCLIBC_USE_TIME64__)
20 int fstatat(int fd
, const char *file
, struct stat
*buf
, int flag
)
23 # ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
24 struct kernel_stat64 kbuf
;
25 ret
= INLINE_SYSCALL(fstatat64
, 4, fd
, file
, &kbuf
, flag
);
27 __xstat32_conv(&kbuf
, buf
);
29 ret
= INLINE_SYSCALL(fstatat64
, 4, fd
, file
, buf
, flag
);
30 # endif /* __ARCH_HAS_DEPRECATED_SYSCALLS__ */
33 libc_hidden_def(fstatat
)
36 #if defined(__NR_statx) && defined __UCLIBC_HAVE_STATX__
37 #include <sys/sysmacros.h> // for makedev
39 int fstatat(int fd
, const char *file
, struct stat
*buf
, int flag
)
44 ret
= INLINE_SYSCALL(statx
, 5, fd
, file
, flag
,
45 STATX_BASIC_STATS
, &tmp
);
49 *buf
= (struct stat
) {
50 .st_dev
= makedev(tmp
.stx_dev_major
, tmp
.stx_dev_minor
),
51 .st_ino
= tmp
.stx_ino
,
52 .st_mode
= tmp
.stx_mode
,
53 .st_nlink
= tmp
.stx_nlink
,
54 .st_uid
= tmp
.stx_uid
,
55 .st_gid
= tmp
.stx_gid
,
56 .st_rdev
= makedev(tmp
.stx_rdev_major
, tmp
.stx_rdev_minor
),
57 .st_size
= tmp
.stx_size
,
58 .st_blksize
= tmp
.stx_blksize
,
59 .st_blocks
= tmp
.stx_blocks
,
60 .st_atim
.tv_sec
= tmp
.stx_atime
.tv_sec
,
61 .st_atim
.tv_nsec
= tmp
.stx_atime
.tv_nsec
,
62 .st_mtim
.tv_sec
= tmp
.stx_mtime
.tv_sec
,
63 .st_mtim
.tv_nsec
= tmp
.stx_mtime
.tv_nsec
,
64 .st_ctim
.tv_sec
= tmp
.stx_ctime
.tv_sec
,
65 .st_ctim
.tv_nsec
= tmp
.stx_ctime
.tv_nsec
,
70 libc_hidden_def(fstatat
)
74 /* should add emulation with fstat() and /proc/self/fd/ ... */