]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/statfs64.c
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / statfs64.c
CommitLineData
47b33891 1/* Return information about the filesystem on which FILE resides.
2b778ceb 2 Copyright (C) 1996-2021 Free Software Foundation, Inc.
47b33891
RM
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
41bdb6e2
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.
47b33891
RM
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
41bdb6e2 13 Lesser General Public License for more details.
47b33891 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
47b33891 18
9e878fa9
SE
19#include <errno.h>
20#include <string.h>
21#include <stddef.h>
22#include <sysdep.h>
23#include <kernel_stat.h>
24
510abe7b
SE
25/* Hide the prototypes for __statfs and statfs so that GCC will not
26 complain about the different function signatures if they are aliased
27 to __stat64. If STATFS_IS_STATFS64 is not zero then the statfs and
28 statfs64 structures have an identical layout but different type names. */
29
9e878fa9
SE
30#if STATFS_IS_STATFS64
31# define __statfs __statfs_disable
32# define statfs statfs_disable
33#endif
47b33891 34#include <sys/statfs.h>
9e878fa9 35
f8de5057 36#include <kernel-features.h>
51d1ca00 37
08c9a553
UD
38
39# if __ASSUME_STATFS64 == 0
51d1ca00 40int __no_statfs64 attribute_hidden;
08c9a553 41#endif
47b33891
RM
42
43/* Return information about the filesystem on which FILE resides. */
44int
bb8e0116 45__statfs64 (const char *file, struct statfs64 *buf)
47b33891 46{
51d1ca00
UD
47#ifdef __NR_statfs64
48# if __ASSUME_STATFS64 == 0
49 if (! __no_statfs64)
50# endif
51 {
e5dee2c8 52 int result = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
0c5b8b59 53
e5dee2c8
L
54# if __ASSUME_STATFS64 == 0
55 if (result == 0 || errno != ENOSYS)
0c5b8b59 56# endif
e5dee2c8 57 return result;
51d1ca00
UD
58
59# if __ASSUME_STATFS64 == 0
60 __no_statfs64 = 1;
61# endif
62 }
63#endif
64
65#if __ASSUME_STATFS64 == 0
47b33891
RM
66 struct statfs buf32;
67
68 if (__statfs (file, &buf32) < 0)
69 return -1;
70
71 buf->f_type = buf32.f_type;
72 buf->f_bsize = buf32.f_bsize;
73 buf->f_blocks = buf32.f_blocks;
74 buf->f_bfree = buf32.f_bfree;
75 buf->f_bavail = buf32.f_bavail;
76 buf->f_files = buf32.f_files;
77 buf->f_ffree = buf32.f_ffree;
78 buf->f_fsid = buf32.f_fsid;
79 buf->f_namelen = buf32.f_namelen;
51d1ca00 80 buf->f_frsize = buf32.f_frsize;
d3a5ae6a 81 buf->f_flags = buf32.f_flags;
47b33891
RM
82 memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
83
84 return 0;
51d1ca00 85#endif
47b33891 86}
bb8e0116 87weak_alias (__statfs64, statfs64)
510abe7b
SE
88
89#undef __statfs
90#undef statfs
91
92#if STATFS_IS_STATFS64
93weak_alias (__statfs64, __statfs)
94weak_alias (__statfs64, statfs)
95libc_hidden_ver (__statfs64, __statfs)
96#endif