2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / alpha / fxstat.c
blob40e08fd86ee248f08d6a9488559055463c263d2c
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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #define __fxstat64 __fxstat64_disable
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>
30 #undef __fxstat64
33 /* Get information about the file NAME in BUF. */
34 int
35 __fxstat (int vers, int fd, struct stat *buf)
37 INTERNAL_SYSCALL_DECL (err);
38 int result, errno_out;
39 struct kernel_stat kbuf;
41 if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
43 result = INTERNAL_SYSCALL (fstat64, err, 2, fd, buf);
44 if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
45 return result;
46 errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
47 if (errno_out != ENOSYS)
48 goto fail;
49 __libc_missing_axp_stat64 = 1;
52 result = INTERNAL_SYSCALL (fstat, err, 2, fd, &kbuf);
53 if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
54 return __xstat_conv (vers, &kbuf, buf);
55 errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
57 fail:
58 __set_errno (errno_out);
59 return -1;
61 hidden_def (__fxstat)
62 weak_alias (__fxstat, _fxstat);
63 strong_alias (__fxstat, __fxstat64);
64 hidden_ver (__fxstat, __fxstat64)