blob: 40ceff9ae9b7f68588af798e03fd33576f470aba [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From e89652b853ca7de671093ae44305fa3435e13d3d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 15 Dec 2022 13:29:43 -0800
4Subject: [PATCH] Replace statfs64 with statfs
5
6autoconf AC_SYS_LARGEFILE is used by configure to add needed defines
7when needed for enabling 64bit off_t, therefore replacing statfs64 with
8statfs should be functionally same. Additionally this helps compiling
9with latest musl where 64bit LFS functions like statfs64 and friends are
10now moved under _LARGEFILE64_SOURCE feature test macro, this works on
11glibc systems because _GNU_SOURCE macros also enables
12_LARGEFILE64_SOURCE indirectly. This is not case with musl and this
13latest issue is exposed.
14
15Upstream-Status: Submitted [https://lore.kernel.org/linux-nfs/20221215213605.4061853-1-raj.khem@gmail.com/T/#u]
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 support/export/cache.c | 14 +++++++-------
19 support/include/nfsd_path.h | 6 +++---
20 support/misc/nfsd_path.c | 24 ++++++++++++------------
21 utils/exportfs/exportfs.c | 4 ++--
22 4 files changed, 24 insertions(+), 24 deletions(-)
23
24diff --git a/support/export/cache.c b/support/export/cache.c
25index a5823e9..2497d4f 100644
26--- a/support/export/cache.c
27+++ b/support/export/cache.c
28@@ -346,27 +346,27 @@ static int uuid_by_path(char *path, int type, size_t uuidlen, char *uuid)
29
30 /* Possible sources of uuid are
31 * - blkid uuid
32- * - statfs64 uuid
33+ * - statfs uuid
34 *
35- * On some filesystems (e.g. vfat) the statfs64 uuid is simply an
36+ * On some filesystems (e.g. vfat) the statfs uuid is simply an
37 * encoding of the device that the filesystem is mounted from, so
38 * it we be very bad to use that (as device numbers change). blkid
39 * must be preferred.
40- * On other filesystems (e.g. btrfs) the statfs64 uuid contains
41+ * On other filesystems (e.g. btrfs) the statfs uuid contains
42 * important info that the blkid uuid cannot contain: This happens
43 * when multiple subvolumes are exported (they have the same
44- * blkid uuid but different statfs64 uuids).
45+ * blkid uuid but different statfs uuids).
46 * We rely on get_uuid_blkdev *knowing* which is which and not returning
47- * a uuid for filesystems where the statfs64 uuid is better.
48+ * a uuid for filesystems where the statfs uuid is better.
49 *
50 */
51- struct statfs64 st;
52+ struct statfs st;
53 char fsid_val[17];
54 const char *blkid_val = NULL;
55 const char *val;
56 int rc;
57
58- rc = nfsd_path_statfs64(path, &st);
59+ rc = nfsd_path_statfs(path, &st);
60
61 if (type == 0 && rc == 0) {
62 const unsigned long *bad;
63diff --git a/support/include/nfsd_path.h b/support/include/nfsd_path.h
64index 3b73aad..aa1e1dd 100644
65--- a/support/include/nfsd_path.h
66+++ b/support/include/nfsd_path.h
67@@ -7,7 +7,7 @@
68 #include <sys/stat.h>
69
70 struct file_handle;
71-struct statfs64;
72+struct statfs;
73
74 void nfsd_path_init(void);
75
76@@ -18,8 +18,8 @@ char * nfsd_path_prepend_dir(const char *dir, const char *pathname);
77 int nfsd_path_stat(const char *pathname, struct stat *statbuf);
78 int nfsd_path_lstat(const char *pathname, struct stat *statbuf);
79
80-int nfsd_path_statfs64(const char *pathname,
81- struct statfs64 *statbuf);
82+int nfsd_path_statfs(const char *pathname,
83+ struct statfs *statbuf);
84
85 char * nfsd_realpath(const char *path, char *resolved_path);
86
87diff --git a/support/misc/nfsd_path.c b/support/misc/nfsd_path.c
88index 65e53c1..c3dea4f 100644
89--- a/support/misc/nfsd_path.c
90+++ b/support/misc/nfsd_path.c
91@@ -184,46 +184,46 @@ nfsd_path_lstat(const char *pathname, struct stat *statbuf)
92 return nfsd_run_stat(nfsd_wq, nfsd_lstatfunc, pathname, statbuf);
93 }
94
95-struct nfsd_statfs64_data {
96+struct nfsd_statfs_data {
97 const char *pathname;
98- struct statfs64 *statbuf;
99+ struct statfs *statbuf;
100 int ret;
101 int err;
102 };
103
104 static void
105-nfsd_statfs64func(void *data)
106+nfsd_statfsfunc(void *data)
107 {
108- struct nfsd_statfs64_data *d = data;
109+ struct nfsd_statfs_data *d = data;
110
111- d->ret = statfs64(d->pathname, d->statbuf);
112+ d->ret = statfs(d->pathname, d->statbuf);
113 if (d->ret < 0)
114 d->err = errno;
115 }
116
117 static int
118-nfsd_run_statfs64(struct xthread_workqueue *wq,
119+nfsd_run_statfs(struct xthread_workqueue *wq,
120 const char *pathname,
121- struct statfs64 *statbuf)
122+ struct statfs *statbuf)
123 {
124- struct nfsd_statfs64_data data = {
125+ struct nfsd_statfs_data data = {
126 pathname,
127 statbuf,
128 0,
129 0
130 };
131- xthread_work_run_sync(wq, nfsd_statfs64func, &data);
132+ xthread_work_run_sync(wq, nfsd_statfsfunc, &data);
133 if (data.ret < 0)
134 errno = data.err;
135 return data.ret;
136 }
137
138 int
139-nfsd_path_statfs64(const char *pathname, struct statfs64 *statbuf)
140+nfsd_path_statfs(const char *pathname, struct statfs *statbuf)
141 {
142 if (!nfsd_wq)
143- return statfs64(pathname, statbuf);
144- return nfsd_run_statfs64(nfsd_wq, pathname, statbuf);
145+ return statfs(pathname, statbuf);
146+ return nfsd_run_statfs(nfsd_wq, pathname, statbuf);
147 }
148
149 struct nfsd_realpath_data {
150diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
151index 0897b22..6d79a5b 100644
152--- a/utils/exportfs/exportfs.c
153+++ b/utils/exportfs/exportfs.c
154@@ -513,7 +513,7 @@ validate_export(nfs_export *exp)
155 */
156 struct stat stb;
157 char *path = exportent_realpath(&exp->m_export);
158- struct statfs64 stf;
159+ struct statfs stf;
160 int fs_has_fsid = 0;
161
162 if (stat(path, &stb) < 0) {
163@@ -528,7 +528,7 @@ validate_export(nfs_export *exp)
164 if (!can_test())
165 return;
166
167- if (!statfs64(path, &stf) &&
168+ if (!statfs(path, &stf) &&
169 (stf.f_fsid.__val[0] || stf.f_fsid.__val[1]))
170 fs_has_fsid = 1;
171