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 = kbuf->st_atim;
41 buf->st_mtim = kbuf->st_mtim;
42 buf->st_ctim = kbuf->st_ctim;
43 }
44
__xstat32_conv(struct kernel_stat64 * kbuf,struct stat * buf)45 void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
46 {
47 /* Convert to current kernel version of `struct stat64'. */
48 memset(buf, 0x00, sizeof(*buf));
49 buf->st_dev = kbuf->st_dev;
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_size = kbuf->st_size;
57 buf->st_blksize = kbuf->st_blksize;
58 buf->st_blocks = kbuf->st_blocks;
59 buf->st_atim = kbuf->st_atim;
60 buf->st_mtim = kbuf->st_mtim;
61 buf->st_ctim = kbuf->st_ctim;
62 }
63
64 #ifdef __UCLIBC_HAS_LFS__
65
__xstat64_conv(struct kernel_stat64 * kbuf,struct stat64 * buf)66 void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
67 {
68 /* Convert to current kernel version of `struct stat64'. */
69 memset(buf, 0x00, sizeof(*buf));
70 buf->st_dev = kbuf->st_dev;
71 buf->st_ino = kbuf->st_ino;
72 # ifdef _HAVE_STAT64___ST_INO
73 buf->__st_ino = kbuf->__st_ino;
74 # endif
75 buf->st_mode = kbuf->st_mode;
76 buf->st_nlink = kbuf->st_nlink;
77 buf->st_uid = kbuf->st_uid;
78 buf->st_gid = kbuf->st_gid;
79 buf->st_rdev = kbuf->st_rdev;
80 buf->st_size = kbuf->st_size;
81 buf->st_blksize = kbuf->st_blksize;
82 buf->st_blocks = kbuf->st_blocks;
83 buf->st_atim = kbuf->st_atim;
84 buf->st_mtim = kbuf->st_mtim;
85 buf->st_ctim = kbuf->st_ctim;
86 }
87
88 #endif /* __UCLIBC_HAS_LFS__ */
89