]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/fstatvfs64.c
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / fstatvfs64.c
1 /* Return information about the filesystem on which FD resides.
2 Copyright (C) 1996-2021 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 <https://www.gnu.org/licenses/>. */
18
19 #include <errno.h>
20 #include <string.h>
21 #include <sys/stat.h>
22 #include <sys/statfs.h>
23 #include "internal_statvfs.h"
24 #include <kernel-features.h>
25
26 /* Return information about the filesystem on which FD resides. */
27 int
28 __fstatvfs64 (int fd, struct statvfs64 *buf)
29 {
30 struct statfs64 fsbuf;
31 int res = __fstatfs64 (fd, &fsbuf);
32
33 #ifndef __ASSUME_STATFS64
34 if (res < 0 && errno == ENOSYS)
35 {
36 struct statvfs buf32;
37
38 res = fstatvfs (fd, &buf32);
39 if (res == 0)
40 {
41 buf->f_bsize = buf32.f_bsize;
42 buf->f_frsize = buf32.f_frsize;
43 buf->f_blocks = buf32.f_blocks;
44 buf->f_bfree = buf32.f_bfree;
45 buf->f_bavail = buf32.f_bavail;
46 buf->f_files = buf32.f_files;
47 buf->f_ffree = buf32.f_ffree;
48 buf->f_favail = buf32.f_favail;
49 buf->f_fsid = buf32.f_fsid;
50 buf->f_flag = buf32.f_flag;
51 buf->f_namemax = buf32.f_namemax;
52 memcpy (buf->__f_spare, buf32.__f_spare, sizeof (buf32.__f_spare));
53 }
54 }
55 #endif
56
57 if (res == 0)
58 /* Convert the result. */
59 __internal_statvfs64 (NULL, buf, &fsbuf, fd);
60
61 return res;
62 }
63 weak_alias (__fstatvfs64, fstatvfs64)