1 /* fxstat using old-style Unix stat system call.
2 Copyright (C) 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
19 #define __fxstat64 __fxstat64_disable
24 #include <kernel_stat.h>
26 #include <sys/syscall.h>
27 #include <xstatconv.h>
32 /* Get information about the file NAME in BUF. */
34 __fxstat (int vers
, int fd
, struct stat
*buf
)
36 INTERNAL_SYSCALL_DECL (err
);
38 struct kernel_stat kbuf
;
40 #if __ASSUME_STAT64_SYSCALL > 0
41 if (vers
== _STAT_VER_KERNEL64
)
43 result
= INTERNAL_SYSCALL (fstat64
, err
, 2, fd
, buf
);
44 if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result
, err
), 1))
46 __set_errno (INTERNAL_SYSCALL_ERRNO (result
, err
));
49 #elif defined __NR_fstat64
50 if (vers
== _STAT_VER_KERNEL64
&& !__libc_missing_axp_stat64
)
53 result
= INTERNAL_SYSCALL (fstat64
, err
, 2, fd
, buf
);
54 if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result
, err
), 1))
56 errno_out
= INTERNAL_SYSCALL_ERRNO (result
, err
);
57 if (errno_out
!= ENOSYS
)
59 __set_errno (errno_out
);
62 __libc_missing_axp_stat64
= 1;
66 result
= INTERNAL_SYSCALL (fstat
, err
, 2, fd
, &kbuf
);
67 if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result
, err
), 1))
68 return __xstat_conv (vers
, &kbuf
, buf
);
69 __set_errno (INTERNAL_SYSCALL_ERRNO (result
, err
));
73 weak_alias (__fxstat
, _fxstat
);
74 strong_alias (__fxstat
, __fxstat64
);
75 hidden_ver (__fxstat
, __fxstat64
)