]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/alpha/xstatconv.c
1 /* Convert between the kernel's `struct stat' format, and libc's.
2 Copyright (C) 1997-2020 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 <https://www.gnu.org/licenses/>. */
22 #include <kernel_stat.h>
23 #include <xstatconv.h>
24 #include <sys/syscall.h>
27 __xstat_conv (int vers
, struct kernel_stat
*kbuf
, void *ubuf
)
31 case _STAT_VER_KERNEL
:
32 *(struct kernel_stat
*) ubuf
= *kbuf
;
35 case _STAT_VER_GLIBC2
:
37 struct glibc2_stat
*buf
= ubuf
;
39 buf
->st_dev
= kbuf
->st_dev
;
40 buf
->st_ino
= kbuf
->st_ino
;
41 buf
->st_mode
= kbuf
->st_mode
;
42 buf
->st_nlink
= kbuf
->st_nlink
;
43 buf
->st_uid
= kbuf
->st_uid
;
44 buf
->st_gid
= kbuf
->st_gid
;
45 buf
->st_rdev
= kbuf
->st_rdev
;
46 buf
->st_size
= kbuf
->st_size
;
47 buf
->st_atime
= kbuf
->st_atime
;
48 buf
->st_mtime
= kbuf
->st_mtime
;
49 buf
->st_ctime
= kbuf
->st_ctime
;
50 buf
->st_blksize
= kbuf
->st_blksize
;
51 buf
->st_blocks
= kbuf
->st_blocks
;
52 buf
->st_flags
= kbuf
->st_flags
;
53 buf
->st_gen
= kbuf
->st_gen
;
57 case _STAT_VER_GLIBC2_1
:
59 struct glibc21_stat
*buf
= ubuf
;
61 buf
->st_dev
= kbuf
->st_dev
;
62 buf
->st_ino
= kbuf
->st_ino
;
63 buf
->st_mode
= kbuf
->st_mode
;
64 buf
->st_nlink
= kbuf
->st_nlink
;
65 buf
->st_uid
= kbuf
->st_uid
;
66 buf
->st_gid
= kbuf
->st_gid
;
67 buf
->st_rdev
= kbuf
->st_rdev
;
68 buf
->st_size
= kbuf
->st_size
;
69 buf
->st_atime
= kbuf
->st_atime
;
70 buf
->st_mtime
= kbuf
->st_mtime
;
71 buf
->st_ctime
= kbuf
->st_ctime
;
72 buf
->st_blocks
= kbuf
->st_blocks
;
73 buf
->st_blksize
= kbuf
->st_blksize
;
74 buf
->st_flags
= kbuf
->st_flags
;
75 buf
->st_gen
= kbuf
->st_gen
;
77 buf
->__glibc_reserved
[0] = 0;
78 buf
->__glibc_reserved
[1] = 0;
79 buf
->__glibc_reserved
[2] = 0;
80 buf
->__glibc_reserved
[3] = 0;
84 case _STAT_VER_GLIBC2_3_4
:
86 struct stat64
*buf
= ubuf
;
88 buf
->st_dev
= kbuf
->st_dev
;
89 buf
->st_ino
= kbuf
->st_ino
;
90 buf
->st_rdev
= kbuf
->st_rdev
;
91 buf
->st_size
= kbuf
->st_size
;
92 buf
->st_blocks
= kbuf
->st_blocks
;
94 buf
->st_mode
= kbuf
->st_mode
;
95 buf
->st_uid
= kbuf
->st_uid
;
96 buf
->st_gid
= kbuf
->st_gid
;
97 buf
->st_blksize
= kbuf
->st_blksize
;
98 buf
->st_nlink
= kbuf
->st_nlink
;
101 buf
->st_atime
= kbuf
->st_atime
;
102 buf
->st_atimensec
= 0;
103 buf
->st_mtime
= kbuf
->st_mtime
;
104 buf
->st_mtimensec
= 0;
105 buf
->st_ctime
= kbuf
->st_ctime
;
106 buf
->st_ctimensec
= 0;
108 buf
->__glibc_reserved
[0] = 0;
109 buf
->__glibc_reserved
[1] = 0;
110 buf
->__glibc_reserved
[2] = 0;
115 __set_errno (EINVAL
);