Add INLINE_SYSCALL_RETURN/INLINE_SYSCALL_ERROR_RETURN
[glibc.git] / sysdeps / unix / sysv / linux / statfs64.c
blob0d9e16c7bcc09129a178092a6feb7baf16bd42f6
1 /* Return information about the filesystem on which FILE resides.
2 Copyright (C) 1996-2015 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 <http://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <string.h>
21 #include <sys/statfs.h>
22 #include <stddef.h>
23 #include <sysdep.h>
24 #include <kernel-features.h>
27 # if __ASSUME_STATFS64 == 0
28 int __no_statfs64 attribute_hidden;
29 #endif
31 /* Return information about the filesystem on which FILE resides. */
32 int
33 __statfs64 (const char *file, struct statfs64 *buf)
35 #ifdef __NR_statfs64
36 # if __ASSUME_STATFS64 == 0
37 if (! __no_statfs64)
38 # endif
40 # if __ASSUME_STATFS64 == 0
41 INTERNAL_SYSCALL_DECL (err);
42 int result = INTERNAL_SYSCALL (statfs64, err, 3, file,
43 sizeof (*buf), buf);
45 if (!__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))
46 || INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS)
47 return result;
48 # else
49 return INLINE_SYSCALL_RETURN (statfs64, 3, int, file,
50 sizeof (*buf), buf);
51 # endif
53 # if __ASSUME_STATFS64 == 0
54 __no_statfs64 = 1;
55 # endif
57 #endif
59 #if __ASSUME_STATFS64 == 0
60 struct statfs buf32;
62 if (__statfs (file, &buf32) < 0)
63 return -1;
65 buf->f_type = buf32.f_type;
66 buf->f_bsize = buf32.f_bsize;
67 buf->f_blocks = buf32.f_blocks;
68 buf->f_bfree = buf32.f_bfree;
69 buf->f_bavail = buf32.f_bavail;
70 buf->f_files = buf32.f_files;
71 buf->f_ffree = buf32.f_ffree;
72 buf->f_fsid = buf32.f_fsid;
73 buf->f_namelen = buf32.f_namelen;
74 buf->f_frsize = buf32.f_frsize;
75 memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
77 return 0;
78 #endif
80 weak_alias (__statfs64, statfs64)