Update.
[glibc.git] / sysdeps / unix / sysv / linux / mips / lxstat.c
blob7907b2f2d221d20f4c0eedc8a3e4377feb03d1cb
1 /* lxstat using old-style Unix lstat 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 buf->st_pad1[0] = 0; buf->st_pad1[1] = 0; buf->st_pad1[2] = 0;
50 buf->st_ino = kbuf.st_ino;
51 buf->st_mode = kbuf.st_mode;
52 buf->st_nlink = kbuf.st_nlink;
53 buf->st_uid = kbuf.st_uid;
54 buf->st_gid = kbuf.st_gid;
55 buf->st_rdev = kbuf.st_rdev;
56 buf->st_pad2[0] = 0; buf->st_pad2[1] = 0;
57 buf->st_pad3 = 0;
58 buf->st_size = kbuf.st_size;
59 buf->st_blksize = kbuf.st_blksize;
60 buf->st_blocks = kbuf.st_blocks;
62 buf->st_atime = kbuf.st_atime; buf->__reserved0 = 0;
63 buf->st_mtime = kbuf.st_mtime; buf->__reserved1 = 0;
64 buf->st_ctime = kbuf.st_ctime; buf->__reserved2 = 0;
66 buf->st_pad4[0] = 0; buf->st_pad4[1] = 0;
67 buf->st_pad4[2] = 0; buf->st_pad4[3] = 0;
68 buf->st_pad4[4] = 0; buf->st_pad4[5] = 0;
69 buf->st_pad4[6] = 0; buf->st_pad4[7] = 0;
70 break;
72 default:
73 __set_errno (EINVAL);
74 result = -1;
75 break;
78 return result;
80 weak_alias (__lxstat, _lxstat)