1commit 909fe47c7009aa9a75fe9470c5f8d3dd5b50917a
2Author: Shea Levy <shea@shealevy.com>
3Date: Sun Feb 18 13:50:11 2018 -0500
4
5 linux-user: Support f_flags in statfs when available.
6
7 Signed-off-by: Shea Levy <shea@shealevy.com>
8
9diff --git a/configure b/configure
10index 913e14839d..52fe2bf941 100755
11--- a/configure
12+++ b/configure
13@@ -5303,6 +5303,22 @@ if compile_prog "" "" ; then
14 have_utmpx=yes
15 fi
16
17+##########################################
18+# Check for newer fields of struct statfs on Linux
19+
20+if test "$linux_user" = "yes"; then
21+ cat > $TMPC <<EOF
22+#include <sys/vfs.h>
23+
24+int main(void) {
25+ struct statfs fs;
26+ fs.f_flags = 0;
27+}
28+EOF
29+ if compile_object ; then
30+ have_statfs_flags=yes
31+ fi
32+fi
33 ##########################################
34 # checks for sanitizers
35
36@@ -6518,6 +6534,10 @@ if test "$have_utmpx" = "yes" ; then
37 echo "HAVE_UTMPX=y" >> $config_host_mak
38 fi
39
40+if test "$have_statfs_flags" = "yes" ; then
41+ echo "HAVE_STATFS_FLAGS=y" >> $config_host_mak
42+fi
43+
44 if test "$ivshmem" = "yes" ; then
45 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
46 fi
47diff --git a/linux-user/syscall.c b/linux-user/syscall.c
48index 82b35a6bdf..77481eca2c 100644
49--- a/linux-user/syscall.c
50+++ b/linux-user/syscall.c
51@@ -9534,6 +9534,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
52 __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
53 __put_user(stfs.f_namelen, &target_stfs->f_namelen);
54 __put_user(stfs.f_frsize, &target_stfs->f_frsize);
55+#ifdef HAVE_STATFS_FLAGS
56+ __put_user(stfs.f_flags, &target_stfs->f_flags);
57+#endif
58 memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare));
59 unlock_user_struct(target_stfs, arg2, 1);
60 }
61diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
62index a35c52a60a..64aa49d3c5 100644
63--- a/linux-user/syscall_defs.h
64+++ b/linux-user/syscall_defs.h
65@@ -362,7 +362,14 @@ struct kernel_statfs {
66 int f_ffree;
67 kernel_fsid_t f_fsid;
68 int f_namelen;
69+#ifdef HAVE_STATFS_FLAGS
70+ int f_frsize;
71+ int f_flags;
72+ int f_spare[4];
73+#else
74 int f_spare[6];
75+#endif
76+
77 };
78
79 struct target_dirent {
80@@ -2223,7 +2230,12 @@ struct target_statfs {
81 /* Linux specials */
82 target_fsid_t f_fsid;
83 int32_t f_namelen;
84+#ifdef HAVE_STATFS_FLAGS
85+ int32_t f_flags;
86+ int32_t f_spare[5];
87+#else
88 int32_t f_spare[6];
89+#endif
90 };
91 #else
92 struct target_statfs {
93@@ -2239,7 +2251,12 @@ struct target_statfs {
94 /* Linux specials */
95 target_fsid_t f_fsid;
96 abi_long f_namelen;
97+#ifdef HAVE_STATFS_FLAGS
98+ abi_long f_flags;
99+ abi_long f_spare[5];
100+#else
101 abi_long f_spare[6];
102+#endif
103 };
104 #endif
105
106@@ -2255,7 +2272,12 @@ struct target_statfs64 {
107 uint64_t f_bavail;
108 target_fsid_t f_fsid;
109 uint32_t f_namelen;
110+#ifdef HAVE_STATFS_FLAGS
111+ uint32_t f_flags;
112+ uint32_t f_spare[5];
113+#else
114 uint32_t f_spare[6];
115+#endif
116 };
117 #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
118 defined(TARGET_SPARC64) || defined(TARGET_AARCH64)) && \
119@@ -2271,7 +2293,12 @@ struct target_statfs {
120 target_fsid_t f_fsid;
121 abi_long f_namelen;
122 abi_long f_frsize;
123+#ifdef HAVE_STATFS_FLAGS
124+ abi_long f_flags;
125+ abi_long f_spare[4];
126+#else
127 abi_long f_spare[5];
128+#endif
129 };
130
131 struct target_statfs64 {
132@@ -2285,7 +2312,12 @@ struct target_statfs64 {
133 target_fsid_t f_fsid;
134 abi_long f_namelen;
135 abi_long f_frsize;
136+#ifdef HAVE_STATFS_FLAGS
137+ abi_long f_flags;
138+ abi_long f_spare[4];
139+#else
140 abi_long f_spare[5];
141+#endif
142 };
143 #elif defined(TARGET_S390X)
144 struct target_statfs {
145@@ -2299,7 +2331,13 @@ struct target_statfs {
146 kernel_fsid_t f_fsid;
147 int32_t f_namelen;
148 int32_t f_frsize;
149+#ifdef HAVE_STATFS_FLAGS
150+ int32_t f_flags;
151+ int32_t f_spare[4];
152+#else
153 int32_t f_spare[5];
154+#endif
155+
156 };
157
158 struct target_statfs64 {
159@@ -2313,7 +2351,12 @@ struct target_statfs64 {
160 kernel_fsid_t f_fsid;
161 int32_t f_namelen;
162 int32_t f_frsize;
163+#ifdef HAVE_STATFS_FLAGS
164+ int32_t f_flags;
165+ int32_t f_spare[4];
166+#else
167 int32_t f_spare[5];
168+#endif
169 };
170 #else
171 struct target_statfs {
172@@ -2327,7 +2370,12 @@ struct target_statfs {
173 target_fsid_t f_fsid;
174 uint32_t f_namelen;
175 uint32_t f_frsize;
176+#ifdef HAVE_STATFS_FLAGS
177+ uint32_t f_flags;
178+ uint32_t f_spare[4];
179+#else
180 uint32_t f_spare[5];
181+#endif
182 };
183
184 struct target_statfs64 {
185@@ -2341,7 +2389,12 @@ struct target_statfs64 {
186 target_fsid_t f_fsid;
187 uint32_t f_namelen;
188 uint32_t f_frsize;
189+#ifdef HAVE_STATFS_FLAGS
190+ uint32_t f_flags;
191+ uint32_t f_spare[4];
192+#else
193 uint32_t f_spare[5];
194+#endif
195 };
196 #endif
197