]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/alpha/fxstat.c
alpha: fix *xstat.c build failure for Linux headers < 2.6.4
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / alpha / fxstat.c
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.
4
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.
9
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.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 #define __fxstat64 __fxstat64_disable
21
22 #include <errno.h>
23 #include <stddef.h>
24 #include <sys/stat.h>
25 #include <kernel_stat.h>
26 #include <sysdep.h>
27 #include <sys/syscall.h>
28 #include <xstatconv.h>
29
30 #undef __fxstat64
31
32
33 /* Get information about the file NAME in BUF. */
34 int
35 __fxstat (int vers, int fd, struct stat *buf)
36 {
37 INTERNAL_SYSCALL_DECL (err);
38 int result;
39 struct kernel_stat kbuf;
40
41 #if __ASSUME_STAT64_SYSCALL > 0
42 if (vers == _STAT_VER_KERNEL64)
43 {
44 result = INTERNAL_SYSCALL (fstat64, err, 2, fd, buf);
45 if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
46 return result;
47 __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
48 return -1;
49 }
50 #elif defined __NR_fstat64
51 if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
52 {
53 int errno_out;
54 result = INTERNAL_SYSCALL (fstat64, err, 2, fd, buf);
55 if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
56 return result;
57 errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
58 if (errno_out != ENOSYS)
59 {
60 __set_errno (errno_out);
61 return -1;
62 }
63 __libc_missing_axp_stat64 = 1;
64 }
65 #endif
66
67 result = INTERNAL_SYSCALL (fstat, err, 2, fd, &kbuf);
68 if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
69 return __xstat_conv (vers, &kbuf, buf);
70 __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
71 return -1;
72 }
73 hidden_def (__fxstat)
74 weak_alias (__fxstat, _fxstat);
75 strong_alias (__fxstat, __fxstat64);
76 hidden_ver (__fxstat, __fxstat64)