]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/alpha/xstatconv.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / alpha / xstatconv.c
CommitLineData
05da9c9f 1/* Convert between the kernel's `struct stat' format, and libc's.
f7a9f785 2 Copyright (C) 1997-2016 Free Software Foundation, Inc.
05da9c9f
UD
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
3214b89b
AJ
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.
05da9c9f
UD
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
3214b89b 13 Lesser General Public License for more details.
05da9c9f 14
3214b89b 15 You should have received a copy of the GNU Lesser General Public
ab84e3ff
PE
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
05da9c9f 18
c27758e9 19#include <errno.h>
05da9c9f 20#include <string.h>
c27758e9 21#include <sys/stat.h>
ebcd2cd1 22#include <kernel_stat.h>
c27758e9 23#include <xstatconv.h>
6a84c77c 24#include <sys/syscall.h>
05da9c9f 25
c27758e9
UD
26int
27__xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
05da9c9f
UD
28{
29 switch (vers)
30 {
31 case _STAT_VER_KERNEL:
2645f7aa 32 *(struct kernel_stat *) ubuf = *kbuf;
05da9c9f
UD
33 break;
34
35 case _STAT_VER_GLIBC2:
36 {
37 struct glibc2_stat *buf = ubuf;
38
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;
54 }
55 break;
56
57 case _STAT_VER_GLIBC2_1:
58 {
b4d2a423 59 struct glibc21_stat *buf = ubuf;
05da9c9f
UD
60
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;
76 buf->__pad3 = 0;
d1d9eaf4
OB
77 buf->__glibc_reserved[0] = 0;
78 buf->__glibc_reserved[1] = 0;
79 buf->__glibc_reserved[2] = 0;
80 buf->__glibc_reserved[3] = 0;
05da9c9f
UD
81 }
82 break;
83
b4d2a423
RH
84 case _STAT_VER_GLIBC2_3_4:
85 {
86 struct stat64 *buf = ubuf;
87
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;
93
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;
99 buf->__pad0 = 0;
100
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;
107
d1d9eaf4
OB
108 buf->__glibc_reserved[0] = 0;
109 buf->__glibc_reserved[1] = 0;
110 buf->__glibc_reserved[2] = 0;
b4d2a423
RH
111 }
112 break;
113
05da9c9f
UD
114 default:
115 __set_errno (EINVAL);
116 return -1;
117 }
118
119 return 0;
120}