]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/alpha/xstatconv.c
Update.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / alpha / xstatconv.c
1 /* Convert between the kernel's `struct stat' format, and libc's.
2 Copyright (C) 1997 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 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
20 #include <string.h>
21
22
23 static inline int
24 xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
25 {
26 switch (vers)
27 {
28 case _STAT_VER_KERNEL:
29 /* Nothing to do. The struct is in the form the kernel expects.
30 We should have short-circuted before we got here, but for
31 completeness... */
32 memcpy ((struct kernel_stat *) ubuf, kbuf, sizeof (*kbuf));
33 break;
34
35 case _STAT_VER_GLIBC2:
36 {
37 struct glibc2_stat *buf = ubuf;
38
39 buf->st_dev = kbuf->st_dev;
40 buf->st_ino = kbuf->st_ino;
41 buf->st_mode = kbuf->st_mode;
42 buf->st_nlink = kbuf->st_nlink;
43 buf->st_uid = kbuf->st_uid;
44 buf->st_gid = kbuf->st_gid;
45 buf->st_rdev = kbuf->st_rdev;
46 buf->st_size = kbuf->st_size;
47 buf->st_atime = kbuf->st_atime;
48 buf->st_mtime = kbuf->st_mtime;
49 buf->st_ctime = kbuf->st_ctime;
50 buf->st_blksize = kbuf->st_blksize;
51 buf->st_blocks = kbuf->st_blocks;
52 buf->st_flags = kbuf->st_flags;
53 buf->st_gen = kbuf->st_gen;
54 }
55 break;
56
57 case _STAT_VER_GLIBC2_1:
58 {
59 struct stat64 *buf = ubuf;
60
61 buf->st_dev = kbuf->st_dev;
62 buf->st_ino = kbuf->st_ino;
63 buf->st_mode = kbuf->st_mode;
64 buf->st_nlink = kbuf->st_nlink;
65 buf->st_uid = kbuf->st_uid;
66 buf->st_gid = kbuf->st_gid;
67 buf->st_rdev = kbuf->st_rdev;
68 buf->st_size = kbuf->st_size;
69 buf->st_atime = kbuf->st_atime;
70 buf->st_mtime = kbuf->st_mtime;
71 buf->st_ctime = kbuf->st_ctime;
72 buf->st_blocks = kbuf->st_blocks;
73 buf->st_blksize = kbuf->st_blksize;
74 buf->st_flags = kbuf->st_flags;
75 buf->st_gen = kbuf->st_gen;
76 buf->__pad3 = 0;
77 buf->__unused[0] = 0;
78 buf->__unused[1] = 0;
79 buf->__unused[2] = 0;
80 buf->__unused[3] = 0;
81 }
82 break;
83
84 default:
85 __set_errno (EINVAL);
86 return -1;
87 }
88
89 return 0;
90 }