2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / alpha / xstatconv.c
bloba193b62ad1a421a99ccbe13ed8ef3b303c30ae1c
1 /* Convert between the kernel's `struct stat' format, and libc's.
2 Copyright (C) 1997, 2003, 2004 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 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.
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.
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. */
20 #include <errno.h>
21 #include <string.h>
22 #include <sys/stat.h>
23 #include <kernel_stat.h>
24 #include <xstatconv.h>
27 int __libc_missing_axp_stat64;
29 int
30 __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
32 switch (vers)
34 case _STAT_VER_KERNEL:
35 *(struct kernel_stat *) ubuf = *kbuf;
36 break;
38 case _STAT_VER_GLIBC2:
40 struct glibc2_stat *buf = ubuf;
42 buf->st_dev = kbuf->st_dev;
43 buf->st_ino = kbuf->st_ino;
44 buf->st_mode = kbuf->st_mode;
45 buf->st_nlink = kbuf->st_nlink;
46 buf->st_uid = kbuf->st_uid;
47 buf->st_gid = kbuf->st_gid;
48 buf->st_rdev = kbuf->st_rdev;
49 buf->st_size = kbuf->st_size;
50 buf->st_atime = kbuf->st_atime;
51 buf->st_mtime = kbuf->st_mtime;
52 buf->st_ctime = kbuf->st_ctime;
53 buf->st_blksize = kbuf->st_blksize;
54 buf->st_blocks = kbuf->st_blocks;
55 buf->st_flags = kbuf->st_flags;
56 buf->st_gen = kbuf->st_gen;
58 break;
60 case _STAT_VER_GLIBC2_1:
62 struct glibc21_stat *buf = ubuf;
64 buf->st_dev = kbuf->st_dev;
65 buf->st_ino = kbuf->st_ino;
66 buf->st_mode = kbuf->st_mode;
67 buf->st_nlink = kbuf->st_nlink;
68 buf->st_uid = kbuf->st_uid;
69 buf->st_gid = kbuf->st_gid;
70 buf->st_rdev = kbuf->st_rdev;
71 buf->st_size = kbuf->st_size;
72 buf->st_atime = kbuf->st_atime;
73 buf->st_mtime = kbuf->st_mtime;
74 buf->st_ctime = kbuf->st_ctime;
75 buf->st_blocks = kbuf->st_blocks;
76 buf->st_blksize = kbuf->st_blksize;
77 buf->st_flags = kbuf->st_flags;
78 buf->st_gen = kbuf->st_gen;
79 buf->__pad3 = 0;
80 buf->__unused[0] = 0;
81 buf->__unused[1] = 0;
82 buf->__unused[2] = 0;
83 buf->__unused[3] = 0;
85 break;
87 case _STAT_VER_GLIBC2_3_4:
89 struct stat64 *buf = ubuf;
91 buf->st_dev = kbuf->st_dev;
92 buf->st_ino = kbuf->st_ino;
93 buf->st_rdev = kbuf->st_rdev;
94 buf->st_size = kbuf->st_size;
95 buf->st_blocks = kbuf->st_blocks;
97 buf->st_mode = kbuf->st_mode;
98 buf->st_uid = kbuf->st_uid;
99 buf->st_gid = kbuf->st_gid;
100 buf->st_blksize = kbuf->st_blksize;
101 buf->st_nlink = kbuf->st_nlink;
102 buf->__pad0 = 0;
104 buf->st_atime = kbuf->st_atime;
105 buf->st_atimensec = 0;
106 buf->st_mtime = kbuf->st_mtime;
107 buf->st_mtimensec = 0;
108 buf->st_ctime = kbuf->st_ctime;
109 buf->st_ctimensec = 0;
111 buf->__unused[0] = 0;
112 buf->__unused[1] = 0;
113 buf->__unused[2] = 0;
115 break;
117 default:
118 __set_errno (EINVAL);
119 return -1;
122 return 0;