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, see
17 <http://www.gnu.org/licenses/>. */
22 #include <kernel_stat.h>
23 #include <xstatconv.h>
24 #include <sys/syscall.h>
28 # if __ASSUME_STAT64_SYSCALL == 0
29 int __libc_missing_axp_stat64;
34 __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
38 case _STAT_VER_KERNEL:
39 *(struct kernel_stat *) ubuf = *kbuf;
42 case _STAT_VER_GLIBC2:
44 struct glibc2_stat *buf = ubuf;
46 buf->st_dev = kbuf->st_dev;
47 buf->st_ino = kbuf->st_ino;
48 buf->st_mode = kbuf->st_mode;
49 buf->st_nlink = kbuf->st_nlink;
50 buf->st_uid = kbuf->st_uid;
51 buf->st_gid = kbuf->st_gid;
52 buf->st_rdev = kbuf->st_rdev;
53 buf->st_size = kbuf->st_size;
54 buf->st_atime = kbuf->st_atime;
55 buf->st_mtime = kbuf->st_mtime;
56 buf->st_ctime = kbuf->st_ctime;
57 buf->st_blksize = kbuf->st_blksize;
58 buf->st_blocks = kbuf->st_blocks;
59 buf->st_flags = kbuf->st_flags;
60 buf->st_gen = kbuf->st_gen;
64 case _STAT_VER_GLIBC2_1:
66 struct glibc21_stat *buf = ubuf;
68 buf->st_dev = kbuf->st_dev;
69 buf->st_ino = kbuf->st_ino;
70 buf->st_mode = kbuf->st_mode;
71 buf->st_nlink = kbuf->st_nlink;
72 buf->st_uid = kbuf->st_uid;
73 buf->st_gid = kbuf->st_gid;
74 buf->st_rdev = kbuf->st_rdev;
75 buf->st_size = kbuf->st_size;
76 buf->st_atime = kbuf->st_atime;
77 buf->st_mtime = kbuf->st_mtime;
78 buf->st_ctime = kbuf->st_ctime;
79 buf->st_blocks = kbuf->st_blocks;
80 buf->st_blksize = kbuf->st_blksize;
81 buf->st_flags = kbuf->st_flags;
82 buf->st_gen = kbuf->st_gen;
91 case _STAT_VER_GLIBC2_3_4:
93 struct stat64 *buf = ubuf;
95 buf->st_dev = kbuf->st_dev;
96 buf->st_ino = kbuf->st_ino;
97 buf->st_rdev = kbuf->st_rdev;
98 buf->st_size = kbuf->st_size;
99 buf->st_blocks = kbuf->st_blocks;
101 buf->st_mode = kbuf->st_mode;
102 buf->st_uid = kbuf->st_uid;
103 buf->st_gid = kbuf->st_gid;
104 buf->st_blksize = kbuf->st_blksize;
105 buf->st_nlink = kbuf->st_nlink;
108 buf->st_atime = kbuf->st_atime;
109 buf->st_atimensec = 0;
110 buf->st_mtime = kbuf->st_mtime;
111 buf->st_mtimensec = 0;
112 buf->st_ctime = kbuf->st_ctime;
113 buf->st_ctimensec = 0;
115 buf->__unused[0] = 0;
116 buf->__unused[1] = 0;
117 buf->__unused[2] = 0;
122 __set_errno (EINVAL);