Update.
[glibc.git] / sysdeps / unix / sysv / linux / lxstat.c
blob11c903864662c83d12c29902e5252ecaf1fcf9ad
1 /* lxstat using old-style Unix fstat system call.
2 Copyright (C) 1991, 1995, 1996, 1997 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 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.
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.
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. */
20 #include <errno.h>
21 #include <stddef.h>
22 #include <sys/stat.h>
24 #include <kernel_stat.h>
26 extern int __syscall_lstat (const char *, struct kernel_stat *);
28 /* Get information about the file NAME in BUF. */
29 int
30 __lxstat (int vers, const char *name, struct stat *buf)
32 struct kernel_stat kbuf;
33 int result;
35 switch (vers)
37 case _STAT_VER_LINUX_OLD:
38 /* Nothing to do. The struct is in the form the kernel expects
39 it to be. */
40 result = __syscall_lstat (name, (struct kernel_stat *) buf);
41 break;
43 case _STAT_VER_LINUX:
44 /* Do the system call. */
45 result = __syscall_lstat (name, &kbuf);
47 /* Convert to current kernel version of `struct stat'. */
48 buf->st_dev = kbuf.st_dev;
49 #ifdef _HAVE___PAD1
50 buf->__pad1 = 0;
51 #endif
52 buf->st_ino = kbuf.st_ino;
53 buf->st_mode = kbuf.st_mode;
54 buf->st_nlink = kbuf.st_nlink;
55 buf->st_uid = kbuf.st_uid;
56 buf->st_gid = kbuf.st_gid;
57 buf->st_rdev = kbuf.st_rdev;
58 #ifdef _HAVE___PAD2
59 buf->__pad2 = 0;
60 #endif
61 buf->st_size = kbuf.st_size;
62 buf->st_blksize = kbuf.st_blksize;
63 buf->st_blocks = kbuf.st_blocks;
64 buf->st_atime = kbuf.st_atime;
65 #ifdef _HAVE___UNUSED1
66 buf->__unused1 = 0;
67 #endif
68 buf->st_mtime = kbuf.st_mtime;
69 #ifdef _HAVE___UNUSED2
70 buf->__unused2 = 0;
71 #endif
72 buf->st_ctime = kbuf.st_ctime;
73 #ifdef _HAVE___UNUSED3
74 buf->__unused3 = 0;
75 #endif
76 #ifdef _HAVE___UNUSED4
77 buf->__unused4 = 0;
78 #endif
79 #ifdef _HAVE___UNUSED5
80 buf->__unused5 = 0;
81 #endif
82 break;
84 default:
85 __set_errno (EINVAL);
86 result = -1;
87 break;
90 return result;
92 weak_alias (__lxstat, _lxstat)