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"
13 /* 64bit ports tend to favor newfstatat() */
14 #if __WORDSIZE == 64 && defined __NR_newfstatat
15 # define __NR_fstatat64 __NR_newfstatat
19 int fstatat(int fd
, const char *file
, struct stat
*buf
, int flag
)
22 # ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
23 struct kernel_stat64 kbuf
;
24 ret
= INLINE_SYSCALL(fstatat64
, 4, fd
, file
, &kbuf
, flag
);
26 __xstat32_conv(&kbuf
, buf
);
28 ret
= INLINE_SYSCALL(fstatat64
, 4, fd
, file
, buf
, flag
);
29 # endif /* __ARCH_HAS_DEPRECATED_SYSCALLS__ */
32 libc_hidden_def(fstatat
)
35 #if defined(__NR_statx) && defined __UCLIBC_HAVE_STATX__
36 #include <sys/sysmacros.h> // for makedev
38 int fstatat(int fd
, const char *file
, struct stat
*buf
, int flag
)
43 ret
= INLINE_SYSCALL(statx
, 5, fd
, file
, flag
,
44 STATX_BASIC_STATS
, &tmp
);
48 *buf
= (struct stat
) {
49 .st_dev
= makedev(tmp
.stx_dev_major
, tmp
.stx_dev_minor
),
50 .st_ino
= tmp
.stx_ino
,
51 .st_mode
= tmp
.stx_mode
,
52 .st_nlink
= tmp
.stx_nlink
,
53 .st_uid
= tmp
.stx_uid
,
54 .st_gid
= tmp
.stx_gid
,
55 .st_rdev
= makedev(tmp
.stx_rdev_major
, tmp
.stx_rdev_minor
),
56 .st_size
= tmp
.stx_size
,
57 .st_blksize
= tmp
.stx_blksize
,
58 .st_blocks
= tmp
.stx_blocks
,
59 .st_atim
.tv_sec
= tmp
.stx_atime
.tv_sec
,
60 .st_atim
.tv_nsec
= tmp
.stx_atime
.tv_nsec
,
61 .st_mtim
.tv_sec
= tmp
.stx_mtime
.tv_sec
,
62 .st_mtim
.tv_nsec
= tmp
.stx_mtime
.tv_nsec
,
63 .st_ctim
.tv_sec
= tmp
.stx_ctime
.tv_sec
,
64 .st_ctim
.tv_nsec
= tmp
.stx_ctime
.tv_nsec
,
65 #if defined(__UCLIBC_USE_TIME64__)
66 .__st_atim32
.tv_sec
= stx
.stx_atime
.tv_sec
,
67 .__st_atim32
.tv_nsec
= stx
.stx_atime
.tv_nsec
,
68 .__st_mtim32
.tv_sec
= stx
.stx_mtime
.tv_sec
,
69 .__st_mtim32
.tv_nsec
= stx
.stx_mtime
.tv_nsec
,
70 .__st_ctim32
.tv_sec
= stx
.stx_ctime
.tv_sec
,
71 .__st_ctim32
.tv_nsec
= stx
.stx_ctime
.tv_nsec
,
77 libc_hidden_def(fstatat
)
81 /* should add emulation with fstat() and /proc/self/fd/ ... */