]>
Commit | Line | Data |
---|---|---|
9756dfe1 | 1 | /* lxstat64 using old-style Unix lstat system call. |
63a34b0f | 2 | Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. |
4cca6b86 UD |
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 Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | 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 | Library General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Library General Public | |
16 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
19 | ||
9756dfe1 UD |
20 | #include <errno.h> |
21 | #include <stddef.h> | |
22 | #include <sys/stat.h> | |
23 | #include <kernel_stat.h> | |
4cca6b86 | 24 | |
0dee6738 UD |
25 | #include <sysdep.h> |
26 | #include <sys/syscall.h> | |
c63598bf | 27 | #include "kernel-features.h" |
0dee6738 | 28 | |
63a34b0f UD |
29 | #if __ASSUME_STAT64_SYSCALL == 0 |
30 | # include <xstatconv.c> | |
31 | #endif | |
9756dfe1 UD |
32 | |
33 | extern int __syscall_lstat (const char *, struct kernel_stat *); | |
34 | ||
63a34b0f UD |
35 | #ifdef __NR_lstat64 |
36 | extern int __syscall_lstat64 (const char *, struct stat64 *); | |
37 | # if __ASSUME_STAT64_SYSCALL == 0 | |
38 | /* The variable is shared between all wrappers around *stat64 calls. */ | |
01496d70 | 39 | extern int __have_no_stat64; |
63a34b0f UD |
40 | # endif |
41 | #endif | |
42 | ||
9756dfe1 UD |
43 | /* Get information about the file NAME in BUF. */ |
44 | int | |
45 | __lxstat64 (int vers, const char *name, struct stat64 *buf) | |
46 | { | |
63a34b0f | 47 | #ifdef __ASSUME_STAT64_SYSCALL |
29332175 | 48 | return INLINE_SYSCALL (lstat64, 2, name, buf); |
63a34b0f | 49 | #else |
9756dfe1 UD |
50 | struct kernel_stat kbuf; |
51 | int result; | |
63a34b0f | 52 | # ifdef __NR_lstat64 |
01496d70 | 53 | if (! __have_no_stat64) |
63a34b0f UD |
54 | { |
55 | int saved_errno = errno; | |
29332175 | 56 | result = INLINE_SYSCALL (lstat64, 2, name, buf); |
63a34b0f UD |
57 | |
58 | if (result != -1 || errno != ENOSYS) | |
59 | return result; | |
9756dfe1 | 60 | |
63a34b0f | 61 | __set_errno (saved_errno); |
01496d70 | 62 | __have_no_stat64 = 1; |
63a34b0f UD |
63 | } |
64 | # endif | |
0dee6738 | 65 | result = INLINE_SYSCALL (lstat, 2, name, &kbuf); |
9756dfe1 UD |
66 | if (result == 0) |
67 | result = xstat64_conv (vers, &kbuf, buf); | |
68 | ||
69 | return result; | |
63a34b0f | 70 | #endif |
9756dfe1 | 71 | } |