1 /* Convert between the kernel's `struct stat' format, and libc's.
2 Copyright (C) 1991,1995,1996,1997,2000,2002 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 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.
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 Lesser General Public License for more details.
14
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/>.
18
19 Modified for uClibc by Erik Andersen <andersen@codepoet.org>
20 */
21
22 #include <sys/stat.h>
23 #include <string.h>
24 #include "xstatconv.h"
25
__xstat_conv(struct kernel_stat * kbuf,struct stat * buf)26 void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
27 {
28 /* Convert to current kernel version of `struct stat'. */
29 memset(buf, 0x00, sizeof(*buf));
30 buf->st_dev = kbuf->st_dev;
31 buf->st_ino = kbuf->st_ino;
32 buf->st_mode = kbuf->st_mode;
33 buf->st_nlink = kbuf->st_nlink;
34 buf->st_uid = kbuf->st_uid;
35 buf->st_gid = kbuf->st_gid;
36 buf->st_rdev = kbuf->st_rdev;
37 buf->st_size = kbuf->st_size;
38 buf->st_blksize = kbuf->st_blksize;
39 buf->st_blocks = kbuf->st_blocks;
40 buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
41 buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
42 buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
43 buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
44 buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
45 buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
46 }
47
__xstat32_conv(struct kernel_stat64 * kbuf,struct stat * buf)48 void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
49 {
50 /* Convert to current kernel version of `struct stat64'. */
51 memset(buf, 0x00, sizeof(*buf));
52 buf->st_dev = kbuf->st_dev;
53 buf->st_ino = kbuf->st_ino;
54 buf->st_mode = kbuf->st_mode;
55 buf->st_nlink = kbuf->st_nlink;
56 buf->st_uid = kbuf->st_uid;
57 buf->st_gid = kbuf->st_gid;
58 buf->st_rdev = kbuf->st_rdev;
59 buf->st_size = kbuf->st_size;
60 buf->st_blksize = kbuf->st_blksize;
61 buf->st_blocks = kbuf->st_blocks;
62 buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
63 buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
64 buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
65 buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
66 buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
67 buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
68 }
69
__xstat64_conv(struct kernel_stat64 * kbuf,struct stat64 * buf)70 void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
71 {
72 /* Convert to current kernel version of `struct stat64'. */
73 memset(buf, 0x00, sizeof(*buf));
74 buf->st_dev = kbuf->st_dev;
75 buf->st_ino = kbuf->st_ino;
76 # ifdef _HAVE_STAT64___ST_INO
77 buf->__st_ino = kbuf->__st_ino;
78 # endif
79 buf->st_mode = kbuf->st_mode;
80 buf->st_nlink = kbuf->st_nlink;
81 buf->st_uid = kbuf->st_uid;
82 buf->st_gid = kbuf->st_gid;
83 buf->st_rdev = kbuf->st_rdev;
84 buf->st_size = kbuf->st_size;
85 buf->st_blksize = kbuf->st_blksize;
86 buf->st_blocks = kbuf->st_blocks;
87 buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
88 buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
89 buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
90 buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
91 buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
92 buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
93 }
94