chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / ports / sysdeps / unix / sysv / linux / alpha / xstat.c
1 /* xstat 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 __xstat64 __xstat64_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 __xstat64
31
32
33 /* Get information about the file NAME in BUF.  */
34 int
35 __xstat (int vers, const char *name, struct stat *buf)
36 {
37   INTERNAL_SYSCALL_DECL (err);
38   int result, errno_out;
39   struct kernel_stat kbuf;
40
41   if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
42     {
43       result = INTERNAL_SYSCALL (stat64, 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;
50     }
51
52   result = INTERNAL_SYSCALL (stat, 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);
56   
57  fail:
58   __set_errno (errno_out);
59   return -1;
60 }
61 hidden_def (__xstat)
62 weak_alias (__xstat, _xstat);
63 strong_alias (__xstat, __xstat64);
64 hidden_ver (__xstat, __xstat64)