2006-02-27 Roland McGrath <roland@redhat.com>
[glibc-ports.git] / sysdeps / unix / sysv / linux / alpha / lxstat.c
blob38fac2e2b22112418096a94f11e9be11978a1a16
1 /* lxstat 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 __lxstat64 __lxstat64_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 __lxstat64
33 /* Get information about the file NAME in BUF. */
34 int
35 __lxstat (int vers, const char *name, 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 (lstat64, err, 2, name, 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 (lstat, err, 2, name, &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 (__lxstat)
62 weak_alias (__lxstat, _lxstat);
63 strong_alias (__lxstat, __lxstat64);
64 hidden_ver (__lxstat, __lxstat64)