blob: deef3929e05eaa041ed03cbe9d9a3289e7be5052 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA.
19
20 Modified for uClibc by Erik Andersen <andersen@codepoet.org>
21 */
22
23#include <sys/syscall.h>
24#include <sys/stat.h>
25#include <string.h>
26#include "xstatconv.h"
27
28void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
29{
30 /* Convert to current kernel version of `struct stat'. */
31 memset(buf, 0x00, sizeof(*buf));
32 buf->st_dev = kbuf->st_dev;
33 buf->st_ino = kbuf->st_ino;
34 buf->st_mode = kbuf->st_mode;
35 buf->st_nlink = kbuf->st_nlink;
36 buf->st_uid = kbuf->st_uid;
37 buf->st_gid = kbuf->st_gid;
38 buf->st_rdev = kbuf->st_rdev;
39 buf->st_size = kbuf->st_size;
40 buf->st_blksize = kbuf->st_blksize;
41 buf->st_blocks = kbuf->st_blocks;
42 buf->st_atim = kbuf->st_atim;
43 buf->st_mtim = kbuf->st_mtim;
44 buf->st_ctim = kbuf->st_ctim;
45}
46
47void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
48{
49 /* Convert to current kernel version of `struct stat64'. */
50 memset(buf, 0x00, sizeof(*buf));
51 buf->st_dev = kbuf->st_dev;
52 buf->st_ino = kbuf->st_ino;
53 buf->st_mode = kbuf->st_mode;
54 buf->st_nlink = kbuf->st_nlink;
55 buf->st_uid = kbuf->st_uid;
56 buf->st_gid = kbuf->st_gid;
57 buf->st_rdev = kbuf->st_rdev;
58 buf->st_size = kbuf->st_size;
59 buf->st_blksize = kbuf->st_blksize;
60 buf->st_blocks = kbuf->st_blocks;
61 buf->st_atim = kbuf->st_atim;
62 buf->st_mtim = kbuf->st_mtim;
63 buf->st_ctim = kbuf->st_ctim;
64}
65
66#ifdef __UCLIBC_HAS_LFS__
67
68void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
69{
70 /* Convert to current kernel version of `struct stat64'. */
71 memset(buf, 0x00, sizeof(*buf));
72 buf->st_dev = kbuf->st_dev;
73 buf->st_ino = kbuf->st_ino;
74# ifdef _HAVE_STAT64___ST_INO
75 buf->__st_ino = kbuf->__st_ino;
76# endif
77 buf->st_mode = kbuf->st_mode;
78 buf->st_nlink = kbuf->st_nlink;
79 buf->st_uid = kbuf->st_uid;
80 buf->st_gid = kbuf->st_gid;
81 buf->st_rdev = kbuf->st_rdev;
82 buf->st_size = kbuf->st_size;
83 buf->st_blksize = kbuf->st_blksize;
84 buf->st_blocks = kbuf->st_blocks;
85 buf->st_atim = kbuf->st_atim;
86 buf->st_mtim = kbuf->st_mtim;
87 buf->st_ctim = kbuf->st_ctim;
88}
89
90#endif /* __UCLIBC_HAS_LFS__ */