Replace FSF snail mail address by URL.
[jlayton/glibc.git] / sysdeps / unix / sysv / linux / alpha / xstatconv.c
1 /* Convert between the kernel's `struct stat' format, and libc's.
2    Copyright (C) 1997, 2003, 2004 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 #include <errno.h>
20 #include <string.h>
21 #include <sys/stat.h>
22 #include <kernel_stat.h>
23 #include <xstatconv.h>
24 #include <sys/syscall.h>
25
26
27 #ifdef __NR_stat64
28 # if __ASSUME_STAT64_SYSCALL == 0
29 int __libc_missing_axp_stat64;
30 # endif
31 #endif
32
33 int
34 __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
35 {
36   switch (vers)
37     {
38     case _STAT_VER_KERNEL:
39       *(struct kernel_stat *) ubuf = *kbuf;
40       break;
41
42     case _STAT_VER_GLIBC2:
43       {
44         struct glibc2_stat *buf = ubuf;
45
46         buf->st_dev = kbuf->st_dev;
47         buf->st_ino = kbuf->st_ino;
48         buf->st_mode = kbuf->st_mode;
49         buf->st_nlink = kbuf->st_nlink;
50         buf->st_uid = kbuf->st_uid;
51         buf->st_gid = kbuf->st_gid;
52         buf->st_rdev = kbuf->st_rdev;
53         buf->st_size = kbuf->st_size;
54         buf->st_atime = kbuf->st_atime;
55         buf->st_mtime = kbuf->st_mtime;
56         buf->st_ctime = kbuf->st_ctime;
57         buf->st_blksize = kbuf->st_blksize;
58         buf->st_blocks = kbuf->st_blocks;
59         buf->st_flags = kbuf->st_flags;
60         buf->st_gen = kbuf->st_gen;
61       }
62       break;
63
64     case _STAT_VER_GLIBC2_1:
65       {
66         struct glibc21_stat *buf = ubuf;
67
68         buf->st_dev = kbuf->st_dev;
69         buf->st_ino = kbuf->st_ino;
70         buf->st_mode = kbuf->st_mode;
71         buf->st_nlink = kbuf->st_nlink;
72         buf->st_uid = kbuf->st_uid;
73         buf->st_gid = kbuf->st_gid;
74         buf->st_rdev = kbuf->st_rdev;
75         buf->st_size = kbuf->st_size;
76         buf->st_atime = kbuf->st_atime;
77         buf->st_mtime = kbuf->st_mtime;
78         buf->st_ctime = kbuf->st_ctime;
79         buf->st_blocks = kbuf->st_blocks;
80         buf->st_blksize = kbuf->st_blksize;
81         buf->st_flags = kbuf->st_flags;
82         buf->st_gen = kbuf->st_gen;
83         buf->__pad3 = 0;
84         buf->__unused[0] = 0;
85         buf->__unused[1] = 0;
86         buf->__unused[2] = 0;
87         buf->__unused[3] = 0;
88       }
89       break;
90
91     case _STAT_VER_GLIBC2_3_4:
92       {
93         struct stat64 *buf = ubuf;
94
95         buf->st_dev = kbuf->st_dev;
96         buf->st_ino = kbuf->st_ino;
97         buf->st_rdev = kbuf->st_rdev;
98         buf->st_size = kbuf->st_size;
99         buf->st_blocks = kbuf->st_blocks;
100
101         buf->st_mode = kbuf->st_mode;
102         buf->st_uid = kbuf->st_uid;
103         buf->st_gid = kbuf->st_gid;
104         buf->st_blksize = kbuf->st_blksize;
105         buf->st_nlink = kbuf->st_nlink;
106         buf->__pad0 = 0;
107
108         buf->st_atime = kbuf->st_atime;
109         buf->st_atimensec = 0;
110         buf->st_mtime = kbuf->st_mtime;
111         buf->st_mtimensec = 0;
112         buf->st_ctime = kbuf->st_ctime;
113         buf->st_ctimensec = 0;
114
115         buf->__unused[0] = 0;
116         buf->__unused[1] = 0;
117         buf->__unused[2] = 0;
118       }
119       break;
120
121     default:
122       __set_errno (EINVAL);
123       return -1;
124     }
125
126   return 0;
127 }