* sysdeps/mach/hurd/xstat64.c: Conditionalize entire contents of the
[platform/upstream/glibc.git] / sysdeps / mach / hurd / xstatconv.c
1 /* Convert between `struct stat' format, and `struct stat64' format.
2    Copyright (C) 2000,01,02 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 #include <errno.h>
21 #include <sys/stat.h>
22
23 static inline int
24 xstat64_conv (struct stat *buf, const struct stat64 *buf64)
25 {
26   if (sizeof *buf == sizeof *buf64
27       && sizeof buf->st_ino == sizeof buf64->st_ino
28       && sizeof buf->st_size == sizeof buf64->st_size
29       && sizeof buf->st_blocks == sizeof buf64->st_blocks)
30     {
31       *buf = *(struct stat *) buf64;
32       return 0;
33     }
34
35   buf->st_fstype = buf64->st_fstype;
36   buf->st_fsid = buf64->st_fsid;
37   buf->st_ino = buf64->st_ino;
38   buf->st_gen = buf64->st_gen;
39   buf->st_rdev = buf64->st_rdev;
40   buf->st_mode = buf64->st_mode;
41   buf->st_nlink = buf64->st_nlink;
42   buf->st_uid = buf64->st_uid;
43   buf->st_gid = buf64->st_gid;
44   buf->st_size = buf64->st_size;
45   buf->st_atime = buf64->st_atime;
46   buf->st_atime_usec = buf64->st_atime_usec;
47   buf->st_mtime = buf64->st_mtime;
48   buf->st_mtime_usec = buf64->st_mtime_usec;
49   buf->st_ctime = buf64->st_ctime;
50   buf->st_ctime_usec = buf64->st_ctime_usec;
51   buf->st_blksize = buf64->st_blksize;
52   buf->st_blocks = buf64->st_blocks;
53   buf->st_author = buf64->st_author;
54   buf->st_flags = buf64->st_flags;
55
56   if ((sizeof buf->st_ino != sizeof buf64->st_ino
57        && buf->st_ino != buf64->st_ino)
58       || (sizeof buf->st_size != sizeof buf64->st_size
59           && buf->st_size != buf64->st_size)
60       || (sizeof buf->st_blocks != sizeof buf64->st_blocks
61           && buf->st_blocks != buf64->st_blocks))
62     {
63       __set_errno (EOVERFLOW);
64       return -1;
65     }
66
67   return 0;
68 }