]>
Commit | Line | Data |
---|---|---|
9954bf92 DH |
1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | /* | |
3 | * linux/fs/nfs/fs_context.c | |
4 | * | |
5 | * Copyright (C) 1992 Rick Sladkey | |
f2aedb71 | 6 | * Conversion to new mount api Copyright (C) David Howells |
9954bf92 DH |
7 | * |
8 | * NFS mount handling. | |
9 | * | |
10 | * Split from fs/nfs/super.c by David Howells <dhowells@redhat.com> | |
11 | */ | |
12 | ||
13 | #include <linux/module.h> | |
14 | #include <linux/fs.h> | |
e38bb238 SM |
15 | #include <linux/fs_context.h> |
16 | #include <linux/fs_parser.h> | |
9954bf92 DH |
17 | #include <linux/nfs_fs.h> |
18 | #include <linux/nfs_mount.h> | |
19 | #include <linux/nfs4_mount.h> | |
20 | #include "nfs.h" | |
21 | #include "internal.h" | |
22 | ||
23 | #define NFSDBG_FACILITY NFSDBG_MOUNT | |
24 | ||
25 | #if IS_ENABLED(CONFIG_NFS_V3) | |
26 | #define NFS_DEFAULT_VERSION 3 | |
27 | #else | |
28 | #define NFS_DEFAULT_VERSION 2 | |
29 | #endif | |
30 | ||
31 | #define NFS_MAX_CONNECTIONS 16 | |
32 | ||
e38bb238 SM |
33 | enum nfs_param { |
34 | Opt_ac, | |
35 | Opt_acdirmax, | |
36 | Opt_acdirmin, | |
37 | Opt_acl, | |
38 | Opt_acregmax, | |
39 | Opt_acregmin, | |
9954bf92 | 40 | Opt_actimeo, |
e38bb238 SM |
41 | Opt_addr, |
42 | Opt_bg, | |
43 | Opt_bsize, | |
44 | Opt_clientaddr, | |
45 | Opt_cto, | |
46 | Opt_fg, | |
47 | Opt_fscache, | |
48 | Opt_hard, | |
49 | Opt_intr, | |
50 | Opt_local_lock, | |
51 | Opt_lock, | |
52 | Opt_lookupcache, | |
53 | Opt_migration, | |
54 | Opt_minorversion, | |
55 | Opt_mountaddr, | |
56 | Opt_mounthost, | |
9954bf92 | 57 | Opt_mountport, |
e38bb238 | 58 | Opt_mountproto, |
9954bf92 | 59 | Opt_mountvers, |
e38bb238 | 60 | Opt_namelen, |
9954bf92 | 61 | Opt_nconnect, |
e38bb238 SM |
62 | Opt_port, |
63 | Opt_posix, | |
64 | Opt_proto, | |
65 | Opt_rdirplus, | |
66 | Opt_rdma, | |
67 | Opt_resvport, | |
68 | Opt_retrans, | |
69 | Opt_retry, | |
70 | Opt_rsize, | |
71 | Opt_sec, | |
72 | Opt_sharecache, | |
73 | Opt_sloppy, | |
74 | Opt_soft, | |
75 | Opt_softerr, | |
76 | Opt_source, | |
77 | Opt_tcp, | |
78 | Opt_timeo, | |
79 | Opt_udp, | |
80 | Opt_v, | |
81 | Opt_vers, | |
82 | Opt_wsize, | |
9954bf92 DH |
83 | }; |
84 | ||
e38bb238 SM |
85 | static const struct fs_parameter_spec nfs_param_specs[] = { |
86 | fsparam_flag_no("ac", Opt_ac), | |
87 | fsparam_u32 ("acdirmax", Opt_acdirmax), | |
88 | fsparam_u32 ("acdirmin", Opt_acdirmin), | |
89 | fsparam_flag_no("acl", Opt_acl), | |
90 | fsparam_u32 ("acregmax", Opt_acregmax), | |
91 | fsparam_u32 ("acregmin", Opt_acregmin), | |
92 | fsparam_u32 ("actimeo", Opt_actimeo), | |
93 | fsparam_string("addr", Opt_addr), | |
94 | fsparam_flag ("bg", Opt_bg), | |
95 | fsparam_u32 ("bsize", Opt_bsize), | |
96 | fsparam_string("clientaddr", Opt_clientaddr), | |
97 | fsparam_flag_no("cto", Opt_cto), | |
98 | fsparam_flag ("fg", Opt_fg), | |
99 | __fsparam(fs_param_is_string, "fsc", Opt_fscache, | |
100 | fs_param_neg_with_no|fs_param_v_optional), | |
101 | fsparam_flag ("hard", Opt_hard), | |
102 | __fsparam(fs_param_is_flag, "intr", Opt_intr, | |
103 | fs_param_neg_with_no|fs_param_deprecated), | |
104 | fsparam_enum ("local_lock", Opt_local_lock), | |
105 | fsparam_flag_no("lock", Opt_lock), | |
106 | fsparam_enum ("lookupcache", Opt_lookupcache), | |
107 | fsparam_flag_no("migration", Opt_migration), | |
108 | fsparam_u32 ("minorversion", Opt_minorversion), | |
109 | fsparam_string("mountaddr", Opt_mountaddr), | |
110 | fsparam_string("mounthost", Opt_mounthost), | |
111 | fsparam_u32 ("mountport", Opt_mountport), | |
112 | fsparam_string("mountproto", Opt_mountproto), | |
113 | fsparam_u32 ("mountvers", Opt_mountvers), | |
114 | fsparam_u32 ("namlen", Opt_namelen), | |
115 | fsparam_u32 ("nconnect", Opt_nconnect), | |
116 | fsparam_string("nfsvers", Opt_vers), | |
117 | fsparam_u32 ("port", Opt_port), | |
118 | fsparam_flag_no("posix", Opt_posix), | |
119 | fsparam_string("proto", Opt_proto), | |
120 | fsparam_flag_no("rdirplus", Opt_rdirplus), | |
121 | fsparam_flag ("rdma", Opt_rdma), | |
122 | fsparam_flag_no("resvport", Opt_resvport), | |
123 | fsparam_u32 ("retrans", Opt_retrans), | |
124 | fsparam_string("retry", Opt_retry), | |
125 | fsparam_u32 ("rsize", Opt_rsize), | |
126 | fsparam_string("sec", Opt_sec), | |
127 | fsparam_flag_no("sharecache", Opt_sharecache), | |
128 | fsparam_flag ("sloppy", Opt_sloppy), | |
129 | fsparam_flag ("soft", Opt_soft), | |
130 | fsparam_flag ("softerr", Opt_softerr), | |
131 | fsparam_string("source", Opt_source), | |
132 | fsparam_flag ("tcp", Opt_tcp), | |
133 | fsparam_u32 ("timeo", Opt_timeo), | |
134 | fsparam_flag ("udp", Opt_udp), | |
135 | fsparam_flag ("v2", Opt_v), | |
136 | fsparam_flag ("v3", Opt_v), | |
137 | fsparam_flag ("v4", Opt_v), | |
138 | fsparam_flag ("v4.0", Opt_v), | |
139 | fsparam_flag ("v4.1", Opt_v), | |
140 | fsparam_flag ("v4.2", Opt_v), | |
141 | fsparam_string("vers", Opt_vers), | |
142 | fsparam_u32 ("wsize", Opt_wsize), | |
143 | {} | |
9954bf92 DH |
144 | }; |
145 | ||
146 | enum { | |
e38bb238 SM |
147 | Opt_local_lock_all, |
148 | Opt_local_lock_flock, | |
149 | Opt_local_lock_none, | |
150 | Opt_local_lock_posix, | |
9954bf92 DH |
151 | }; |
152 | ||
153 | enum { | |
e38bb238 SM |
154 | Opt_lookupcache_all, |
155 | Opt_lookupcache_none, | |
156 | Opt_lookupcache_positive, | |
9954bf92 DH |
157 | }; |
158 | ||
e38bb238 SM |
159 | static const struct fs_parameter_enum nfs_param_enums[] = { |
160 | { Opt_local_lock, "all", Opt_local_lock_all }, | |
161 | { Opt_local_lock, "flock", Opt_local_lock_flock }, | |
162 | { Opt_local_lock, "none", Opt_local_lock_none }, | |
163 | { Opt_local_lock, "posix", Opt_local_lock_posix }, | |
164 | { Opt_lookupcache, "all", Opt_lookupcache_all }, | |
165 | { Opt_lookupcache, "none", Opt_lookupcache_none }, | |
166 | { Opt_lookupcache, "pos", Opt_lookupcache_positive }, | |
167 | { Opt_lookupcache, "positive", Opt_lookupcache_positive }, | |
168 | {} | |
169 | }; | |
9954bf92 | 170 | |
e38bb238 SM |
171 | static const struct fs_parameter_description nfs_fs_parameters = { |
172 | .name = "nfs", | |
173 | .specs = nfs_param_specs, | |
174 | .enums = nfs_param_enums, | |
9954bf92 DH |
175 | }; |
176 | ||
177 | enum { | |
e38bb238 SM |
178 | Opt_vers_2, |
179 | Opt_vers_3, | |
180 | Opt_vers_4, | |
181 | Opt_vers_4_0, | |
182 | Opt_vers_4_1, | |
183 | Opt_vers_4_2, | |
9954bf92 DH |
184 | }; |
185 | ||
e38bb238 SM |
186 | static const struct constant_table nfs_vers_tokens[] = { |
187 | { "2", Opt_vers_2 }, | |
188 | { "3", Opt_vers_3 }, | |
189 | { "4", Opt_vers_4 }, | |
190 | { "4.0", Opt_vers_4_0 }, | |
191 | { "4.1", Opt_vers_4_1 }, | |
192 | { "4.2", Opt_vers_4_2 }, | |
9954bf92 DH |
193 | }; |
194 | ||
195 | enum { | |
e38bb238 SM |
196 | Opt_xprt_rdma, |
197 | Opt_xprt_rdma6, | |
198 | Opt_xprt_tcp, | |
199 | Opt_xprt_tcp6, | |
200 | Opt_xprt_udp, | |
201 | Opt_xprt_udp6, | |
202 | nr__Opt_xprt | |
9954bf92 DH |
203 | }; |
204 | ||
e38bb238 SM |
205 | static const struct constant_table nfs_xprt_protocol_tokens[nr__Opt_xprt] = { |
206 | { "rdma", Opt_xprt_rdma }, | |
207 | { "rdma6", Opt_xprt_rdma6 }, | |
208 | { "tcp", Opt_xprt_tcp }, | |
209 | { "tcp6", Opt_xprt_tcp6 }, | |
210 | { "udp", Opt_xprt_udp }, | |
211 | { "udp6", Opt_xprt_udp6 }, | |
9954bf92 DH |
212 | }; |
213 | ||
214 | enum { | |
e38bb238 SM |
215 | Opt_sec_krb5, |
216 | Opt_sec_krb5i, | |
217 | Opt_sec_krb5p, | |
218 | Opt_sec_lkey, | |
219 | Opt_sec_lkeyi, | |
220 | Opt_sec_lkeyp, | |
221 | Opt_sec_none, | |
222 | Opt_sec_spkm, | |
223 | Opt_sec_spkmi, | |
224 | Opt_sec_spkmp, | |
225 | Opt_sec_sys, | |
226 | nr__Opt_sec | |
9954bf92 DH |
227 | }; |
228 | ||
e38bb238 SM |
229 | static const struct constant_table nfs_secflavor_tokens[] = { |
230 | { "krb5", Opt_sec_krb5 }, | |
231 | { "krb5i", Opt_sec_krb5i }, | |
232 | { "krb5p", Opt_sec_krb5p }, | |
233 | { "lkey", Opt_sec_lkey }, | |
234 | { "lkeyi", Opt_sec_lkeyi }, | |
235 | { "lkeyp", Opt_sec_lkeyp }, | |
236 | { "none", Opt_sec_none }, | |
237 | { "null", Opt_sec_none }, | |
238 | { "spkm3", Opt_sec_spkm }, | |
239 | { "spkm3i", Opt_sec_spkmi }, | |
240 | { "spkm3p", Opt_sec_spkmp }, | |
241 | { "sys", Opt_sec_sys }, | |
9954bf92 DH |
242 | }; |
243 | ||
9954bf92 DH |
244 | /* |
245 | * Sanity-check a server address provided by the mount command. | |
246 | * | |
247 | * Address family must be initialized, and address must not be | |
248 | * the ANY address for that family. | |
249 | */ | |
250 | static int nfs_verify_server_address(struct sockaddr *addr) | |
251 | { | |
252 | switch (addr->sa_family) { | |
253 | case AF_INET: { | |
254 | struct sockaddr_in *sa = (struct sockaddr_in *)addr; | |
255 | return sa->sin_addr.s_addr != htonl(INADDR_ANY); | |
256 | } | |
257 | case AF_INET6: { | |
258 | struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr; | |
259 | return !ipv6_addr_any(sa); | |
260 | } | |
261 | } | |
262 | ||
263 | dfprintk(MOUNT, "NFS: Invalid IP address specified\n"); | |
264 | return 0; | |
265 | } | |
266 | ||
267 | /* | |
268 | * Sanity check the NFS transport protocol. | |
269 | * | |
270 | */ | |
5eb005ca | 271 | static void nfs_validate_transport_protocol(struct nfs_fs_context *ctx) |
9954bf92 | 272 | { |
5eb005ca | 273 | switch (ctx->nfs_server.protocol) { |
9954bf92 DH |
274 | case XPRT_TRANSPORT_UDP: |
275 | case XPRT_TRANSPORT_TCP: | |
276 | case XPRT_TRANSPORT_RDMA: | |
277 | break; | |
278 | default: | |
5eb005ca | 279 | ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
9954bf92 DH |
280 | } |
281 | } | |
282 | ||
283 | /* | |
284 | * For text based NFSv2/v3 mounts, the mount protocol transport default | |
285 | * settings should depend upon the specified NFS transport. | |
286 | */ | |
5eb005ca | 287 | static void nfs_set_mount_transport_protocol(struct nfs_fs_context *ctx) |
9954bf92 | 288 | { |
5eb005ca | 289 | nfs_validate_transport_protocol(ctx); |
9954bf92 | 290 | |
5eb005ca DH |
291 | if (ctx->mount_server.protocol == XPRT_TRANSPORT_UDP || |
292 | ctx->mount_server.protocol == XPRT_TRANSPORT_TCP) | |
9954bf92 | 293 | return; |
5eb005ca | 294 | switch (ctx->nfs_server.protocol) { |
9954bf92 | 295 | case XPRT_TRANSPORT_UDP: |
5eb005ca | 296 | ctx->mount_server.protocol = XPRT_TRANSPORT_UDP; |
9954bf92 DH |
297 | break; |
298 | case XPRT_TRANSPORT_TCP: | |
299 | case XPRT_TRANSPORT_RDMA: | |
5eb005ca | 300 | ctx->mount_server.protocol = XPRT_TRANSPORT_TCP; |
9954bf92 DH |
301 | } |
302 | } | |
303 | ||
304 | /* | |
305 | * Add 'flavor' to 'auth_info' if not already present. | |
306 | * Returns true if 'flavor' ends up in the list, false otherwise | |
307 | */ | |
62a55d08 | 308 | static int nfs_auth_info_add(struct fs_context *fc, |
e558100f DH |
309 | struct nfs_auth_info *auth_info, |
310 | rpc_authflavor_t flavor) | |
9954bf92 DH |
311 | { |
312 | unsigned int i; | |
313 | unsigned int max_flavor_len = ARRAY_SIZE(auth_info->flavors); | |
314 | ||
315 | /* make sure this flavor isn't already in the list */ | |
316 | for (i = 0; i < auth_info->flavor_len; i++) { | |
317 | if (flavor == auth_info->flavors[i]) | |
e558100f | 318 | return 0; |
9954bf92 DH |
319 | } |
320 | ||
ce8866f0 SM |
321 | if (auth_info->flavor_len + 1 >= max_flavor_len) |
322 | return nfs_invalf(fc, "NFS: too many sec= flavors"); | |
9954bf92 DH |
323 | |
324 | auth_info->flavors[auth_info->flavor_len++] = flavor; | |
e558100f | 325 | return 0; |
9954bf92 DH |
326 | } |
327 | ||
328 | /* | |
329 | * Parse the value of the 'sec=' option. | |
330 | */ | |
62a55d08 | 331 | static int nfs_parse_security_flavors(struct fs_context *fc, |
e38bb238 | 332 | struct fs_parameter *param) |
9954bf92 | 333 | { |
62a55d08 | 334 | struct nfs_fs_context *ctx = nfs_fc2context(fc); |
9954bf92 | 335 | rpc_authflavor_t pseudoflavor; |
e38bb238 | 336 | char *string = param->string, *p; |
e558100f | 337 | int ret; |
9954bf92 | 338 | |
e38bb238 | 339 | dfprintk(MOUNT, "NFS: parsing %s=%s option\n", param->key, param->string); |
9954bf92 | 340 | |
e38bb238 SM |
341 | while ((p = strsep(&string, ":")) != NULL) { |
342 | if (!*p) | |
343 | continue; | |
344 | switch (lookup_constant(nfs_secflavor_tokens, p, -1)) { | |
9954bf92 DH |
345 | case Opt_sec_none: |
346 | pseudoflavor = RPC_AUTH_NULL; | |
347 | break; | |
348 | case Opt_sec_sys: | |
349 | pseudoflavor = RPC_AUTH_UNIX; | |
350 | break; | |
351 | case Opt_sec_krb5: | |
352 | pseudoflavor = RPC_AUTH_GSS_KRB5; | |
353 | break; | |
354 | case Opt_sec_krb5i: | |
355 | pseudoflavor = RPC_AUTH_GSS_KRB5I; | |
356 | break; | |
357 | case Opt_sec_krb5p: | |
358 | pseudoflavor = RPC_AUTH_GSS_KRB5P; | |
359 | break; | |
360 | case Opt_sec_lkey: | |
361 | pseudoflavor = RPC_AUTH_GSS_LKEY; | |
362 | break; | |
363 | case Opt_sec_lkeyi: | |
364 | pseudoflavor = RPC_AUTH_GSS_LKEYI; | |
365 | break; | |
366 | case Opt_sec_lkeyp: | |
367 | pseudoflavor = RPC_AUTH_GSS_LKEYP; | |
368 | break; | |
369 | case Opt_sec_spkm: | |
370 | pseudoflavor = RPC_AUTH_GSS_SPKM; | |
371 | break; | |
372 | case Opt_sec_spkmi: | |
373 | pseudoflavor = RPC_AUTH_GSS_SPKMI; | |
374 | break; | |
375 | case Opt_sec_spkmp: | |
376 | pseudoflavor = RPC_AUTH_GSS_SPKMP; | |
377 | break; | |
378 | default: | |
ce8866f0 | 379 | return nfs_invalf(fc, "NFS: sec=%s option not recognized", p); |
9954bf92 DH |
380 | } |
381 | ||
62a55d08 | 382 | ret = nfs_auth_info_add(fc, &ctx->auth_info, pseudoflavor); |
e558100f DH |
383 | if (ret < 0) |
384 | return ret; | |
9954bf92 DH |
385 | } |
386 | ||
e558100f | 387 | return 0; |
9954bf92 DH |
388 | } |
389 | ||
62a55d08 | 390 | static int nfs_parse_version_string(struct fs_context *fc, |
e38bb238 | 391 | const char *string) |
9954bf92 | 392 | { |
62a55d08 SM |
393 | struct nfs_fs_context *ctx = nfs_fc2context(fc); |
394 | ||
5eb005ca | 395 | ctx->flags &= ~NFS_MOUNT_VER3; |
e38bb238 | 396 | switch (lookup_constant(nfs_vers_tokens, string, -1)) { |
9954bf92 | 397 | case Opt_vers_2: |
5eb005ca | 398 | ctx->version = 2; |
9954bf92 DH |
399 | break; |
400 | case Opt_vers_3: | |
5eb005ca DH |
401 | ctx->flags |= NFS_MOUNT_VER3; |
402 | ctx->version = 3; | |
9954bf92 DH |
403 | break; |
404 | case Opt_vers_4: | |
405 | /* Backward compatibility option. In future, | |
406 | * the mount program should always supply | |
407 | * a NFSv4 minor version number. | |
408 | */ | |
5eb005ca | 409 | ctx->version = 4; |
9954bf92 DH |
410 | break; |
411 | case Opt_vers_4_0: | |
5eb005ca DH |
412 | ctx->version = 4; |
413 | ctx->minorversion = 0; | |
9954bf92 DH |
414 | break; |
415 | case Opt_vers_4_1: | |
5eb005ca DH |
416 | ctx->version = 4; |
417 | ctx->minorversion = 1; | |
9954bf92 DH |
418 | break; |
419 | case Opt_vers_4_2: | |
5eb005ca DH |
420 | ctx->version = 4; |
421 | ctx->minorversion = 2; | |
9954bf92 DH |
422 | break; |
423 | default: | |
ce8866f0 | 424 | return nfs_invalf(fc, "NFS: Unsupported NFS version"); |
9954bf92 | 425 | } |
e558100f | 426 | return 0; |
9954bf92 DH |
427 | } |
428 | ||
9954bf92 | 429 | /* |
e38bb238 | 430 | * Parse a single mount parameter. |
9954bf92 | 431 | */ |
f2aedb71 | 432 | static int nfs_fs_context_parse_param(struct fs_context *fc, |
e38bb238 | 433 | struct fs_parameter *param) |
9954bf92 | 434 | { |
e38bb238 | 435 | struct fs_parse_result result; |
f2aedb71 | 436 | struct nfs_fs_context *ctx = nfs_fc2context(fc); |
e38bb238 SM |
437 | unsigned short protofamily, mountfamily; |
438 | unsigned int len; | |
439 | int ret, opt; | |
9954bf92 | 440 | |
e38bb238 | 441 | dfprintk(MOUNT, "NFS: parsing nfs mount option '%s'\n", param->key); |
9954bf92 | 442 | |
f2aedb71 | 443 | opt = fs_parse(fc, &nfs_fs_parameters, param, &result); |
e38bb238 SM |
444 | if (opt < 0) |
445 | return ctx->sloppy ? 1 : opt; | |
446 | ||
447 | switch (opt) { | |
f2aedb71 | 448 | case Opt_source: |
ce8866f0 SM |
449 | if (fc->source) |
450 | return nfs_invalf(fc, "NFS: Multiple sources not supported"); | |
f2aedb71 DH |
451 | fc->source = param->string; |
452 | param->string = NULL; | |
453 | break; | |
454 | ||
9954bf92 DH |
455 | /* |
456 | * boolean options: foo/nofoo | |
457 | */ | |
cbd071b5 DH |
458 | case Opt_soft: |
459 | ctx->flags |= NFS_MOUNT_SOFT; | |
460 | ctx->flags &= ~NFS_MOUNT_SOFTERR; | |
461 | break; | |
462 | case Opt_softerr: | |
463 | ctx->flags |= NFS_MOUNT_SOFTERR; | |
464 | ctx->flags &= ~NFS_MOUNT_SOFT; | |
465 | break; | |
466 | case Opt_hard: | |
467 | ctx->flags &= ~(NFS_MOUNT_SOFT|NFS_MOUNT_SOFTERR); | |
468 | break; | |
469 | case Opt_posix: | |
e38bb238 SM |
470 | if (result.negated) |
471 | ctx->flags &= ~NFS_MOUNT_POSIX; | |
472 | else | |
473 | ctx->flags |= NFS_MOUNT_POSIX; | |
cbd071b5 DH |
474 | break; |
475 | case Opt_cto: | |
e38bb238 SM |
476 | if (result.negated) |
477 | ctx->flags |= NFS_MOUNT_NOCTO; | |
478 | else | |
479 | ctx->flags &= ~NFS_MOUNT_NOCTO; | |
cbd071b5 DH |
480 | break; |
481 | case Opt_ac: | |
e38bb238 SM |
482 | if (result.negated) |
483 | ctx->flags |= NFS_MOUNT_NOAC; | |
484 | else | |
485 | ctx->flags &= ~NFS_MOUNT_NOAC; | |
cbd071b5 DH |
486 | break; |
487 | case Opt_lock: | |
e38bb238 SM |
488 | if (result.negated) { |
489 | ctx->flags |= NFS_MOUNT_NONLM; | |
490 | ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL); | |
491 | } else { | |
492 | ctx->flags &= ~NFS_MOUNT_NONLM; | |
493 | ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL); | |
494 | } | |
cbd071b5 DH |
495 | break; |
496 | case Opt_udp: | |
497 | ctx->flags &= ~NFS_MOUNT_TCP; | |
498 | ctx->nfs_server.protocol = XPRT_TRANSPORT_UDP; | |
499 | break; | |
500 | case Opt_tcp: | |
501 | ctx->flags |= NFS_MOUNT_TCP; | |
502 | ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP; | |
503 | break; | |
504 | case Opt_rdma: | |
505 | ctx->flags |= NFS_MOUNT_TCP; /* for side protocols */ | |
506 | ctx->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | |
e38bb238 | 507 | xprt_load_transport(param->key); |
cbd071b5 DH |
508 | break; |
509 | case Opt_acl: | |
e38bb238 SM |
510 | if (result.negated) |
511 | ctx->flags |= NFS_MOUNT_NOACL; | |
512 | else | |
513 | ctx->flags &= ~NFS_MOUNT_NOACL; | |
cbd071b5 DH |
514 | break; |
515 | case Opt_rdirplus: | |
e38bb238 SM |
516 | if (result.negated) |
517 | ctx->flags |= NFS_MOUNT_NORDIRPLUS; | |
518 | else | |
519 | ctx->flags &= ~NFS_MOUNT_NORDIRPLUS; | |
cbd071b5 DH |
520 | break; |
521 | case Opt_sharecache: | |
e38bb238 SM |
522 | if (result.negated) |
523 | ctx->flags |= NFS_MOUNT_UNSHARED; | |
524 | else | |
525 | ctx->flags &= ~NFS_MOUNT_UNSHARED; | |
cbd071b5 DH |
526 | break; |
527 | case Opt_resvport: | |
e38bb238 SM |
528 | if (result.negated) |
529 | ctx->flags |= NFS_MOUNT_NORESVPORT; | |
530 | else | |
531 | ctx->flags &= ~NFS_MOUNT_NORESVPORT; | |
cbd071b5 DH |
532 | break; |
533 | case Opt_fscache: | |
cbd071b5 | 534 | kfree(ctx->fscache_uniq); |
e38bb238 SM |
535 | ctx->fscache_uniq = param->string; |
536 | param->string = NULL; | |
537 | if (result.negated) | |
538 | ctx->options &= ~NFS_OPTION_FSCACHE; | |
539 | else | |
540 | ctx->options |= NFS_OPTION_FSCACHE; | |
cbd071b5 DH |
541 | break; |
542 | case Opt_migration: | |
e38bb238 SM |
543 | if (result.negated) |
544 | ctx->options &= ~NFS_OPTION_MIGRATION; | |
545 | else | |
546 | ctx->options |= NFS_OPTION_MIGRATION; | |
cbd071b5 | 547 | break; |
9954bf92 DH |
548 | |
549 | /* | |
550 | * options that take numeric values | |
551 | */ | |
cbd071b5 | 552 | case Opt_port: |
e38bb238 SM |
553 | if (result.uint_32 > USHRT_MAX) |
554 | goto out_of_bounds; | |
555 | ctx->nfs_server.port = result.uint_32; | |
cbd071b5 DH |
556 | break; |
557 | case Opt_rsize: | |
e38bb238 | 558 | ctx->rsize = result.uint_32; |
cbd071b5 DH |
559 | break; |
560 | case Opt_wsize: | |
e38bb238 | 561 | ctx->wsize = result.uint_32; |
cbd071b5 DH |
562 | break; |
563 | case Opt_bsize: | |
e38bb238 | 564 | ctx->bsize = result.uint_32; |
cbd071b5 DH |
565 | break; |
566 | case Opt_timeo: | |
e38bb238 SM |
567 | if (result.uint_32 < 1 || result.uint_32 > INT_MAX) |
568 | goto out_of_bounds; | |
569 | ctx->timeo = result.uint_32; | |
cbd071b5 DH |
570 | break; |
571 | case Opt_retrans: | |
e38bb238 SM |
572 | if (result.uint_32 > INT_MAX) |
573 | goto out_of_bounds; | |
574 | ctx->retrans = result.uint_32; | |
cbd071b5 DH |
575 | break; |
576 | case Opt_acregmin: | |
e38bb238 | 577 | ctx->acregmin = result.uint_32; |
cbd071b5 DH |
578 | break; |
579 | case Opt_acregmax: | |
e38bb238 | 580 | ctx->acregmax = result.uint_32; |
cbd071b5 DH |
581 | break; |
582 | case Opt_acdirmin: | |
e38bb238 | 583 | ctx->acdirmin = result.uint_32; |
cbd071b5 DH |
584 | break; |
585 | case Opt_acdirmax: | |
e38bb238 | 586 | ctx->acdirmax = result.uint_32; |
cbd071b5 DH |
587 | break; |
588 | case Opt_actimeo: | |
e38bb238 SM |
589 | ctx->acregmin = result.uint_32; |
590 | ctx->acregmax = result.uint_32; | |
591 | ctx->acdirmin = result.uint_32; | |
592 | ctx->acdirmax = result.uint_32; | |
cbd071b5 DH |
593 | break; |
594 | case Opt_namelen: | |
e38bb238 | 595 | ctx->namlen = result.uint_32; |
cbd071b5 DH |
596 | break; |
597 | case Opt_mountport: | |
e38bb238 SM |
598 | if (result.uint_32 > USHRT_MAX) |
599 | goto out_of_bounds; | |
600 | ctx->mount_server.port = result.uint_32; | |
cbd071b5 DH |
601 | break; |
602 | case Opt_mountvers: | |
e38bb238 SM |
603 | if (result.uint_32 < NFS_MNT_VERSION || |
604 | result.uint_32 > NFS_MNT3_VERSION) | |
605 | goto out_of_bounds; | |
606 | ctx->mount_server.version = result.uint_32; | |
cbd071b5 DH |
607 | break; |
608 | case Opt_minorversion: | |
e38bb238 SM |
609 | if (result.uint_32 > NFS4_MAX_MINOR_VERSION) |
610 | goto out_of_bounds; | |
611 | ctx->minorversion = result.uint_32; | |
cbd071b5 | 612 | break; |
9954bf92 DH |
613 | |
614 | /* | |
615 | * options that take text values | |
616 | */ | |
e38bb238 | 617 | case Opt_v: |
62a55d08 | 618 | ret = nfs_parse_version_string(fc, param->key + 1); |
e38bb238 SM |
619 | if (ret < 0) |
620 | return ret; | |
621 | break; | |
622 | case Opt_vers: | |
62a55d08 | 623 | ret = nfs_parse_version_string(fc, param->string); |
e558100f DH |
624 | if (ret < 0) |
625 | return ret; | |
cbd071b5 DH |
626 | break; |
627 | case Opt_sec: | |
62a55d08 | 628 | ret = nfs_parse_security_flavors(fc, param); |
e558100f DH |
629 | if (ret < 0) |
630 | return ret; | |
cbd071b5 | 631 | break; |
cbd071b5 | 632 | |
e38bb238 SM |
633 | case Opt_proto: |
634 | protofamily = AF_INET; | |
635 | switch (lookup_constant(nfs_xprt_protocol_tokens, param->string, -1)) { | |
cbd071b5 | 636 | case Opt_xprt_udp6: |
e38bb238 | 637 | protofamily = AF_INET6; |
cbd071b5 DH |
638 | /* fall through */ |
639 | case Opt_xprt_udp: | |
640 | ctx->flags &= ~NFS_MOUNT_TCP; | |
641 | ctx->nfs_server.protocol = XPRT_TRANSPORT_UDP; | |
9954bf92 | 642 | break; |
cbd071b5 | 643 | case Opt_xprt_tcp6: |
e38bb238 | 644 | protofamily = AF_INET6; |
cbd071b5 DH |
645 | /* fall through */ |
646 | case Opt_xprt_tcp: | |
647 | ctx->flags |= NFS_MOUNT_TCP; | |
648 | ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP; | |
9954bf92 | 649 | break; |
cbd071b5 | 650 | case Opt_xprt_rdma6: |
e38bb238 | 651 | protofamily = AF_INET6; |
cbd071b5 DH |
652 | /* fall through */ |
653 | case Opt_xprt_rdma: | |
654 | /* vector side protocols to TCP */ | |
655 | ctx->flags |= NFS_MOUNT_TCP; | |
656 | ctx->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | |
e38bb238 | 657 | xprt_load_transport(param->string); |
9954bf92 | 658 | break; |
cbd071b5 | 659 | default: |
ce8866f0 | 660 | return nfs_invalf(fc, "NFS: Unrecognized transport protocol"); |
cbd071b5 | 661 | } |
e38bb238 SM |
662 | |
663 | ctx->protofamily = protofamily; | |
cbd071b5 | 664 | break; |
e38bb238 | 665 | |
cbd071b5 | 666 | case Opt_mountproto: |
e38bb238 SM |
667 | mountfamily = AF_INET; |
668 | switch (lookup_constant(nfs_xprt_protocol_tokens, param->string, -1)) { | |
cbd071b5 | 669 | case Opt_xprt_udp6: |
e38bb238 | 670 | mountfamily = AF_INET6; |
cbd071b5 DH |
671 | /* fall through */ |
672 | case Opt_xprt_udp: | |
673 | ctx->mount_server.protocol = XPRT_TRANSPORT_UDP; | |
674 | break; | |
675 | case Opt_xprt_tcp6: | |
e38bb238 | 676 | mountfamily = AF_INET6; |
cbd071b5 DH |
677 | /* fall through */ |
678 | case Opt_xprt_tcp: | |
679 | ctx->mount_server.protocol = XPRT_TRANSPORT_TCP; | |
680 | break; | |
681 | case Opt_xprt_rdma: /* not used for side protocols */ | |
682 | default: | |
ce8866f0 | 683 | return nfs_invalf(fc, "NFS: Unrecognized transport protocol"); |
cbd071b5 | 684 | } |
e38bb238 | 685 | ctx->mountfamily = mountfamily; |
cbd071b5 | 686 | break; |
e38bb238 | 687 | |
cbd071b5 | 688 | case Opt_addr: |
62a55d08 | 689 | len = rpc_pton(fc->net_ns, param->string, param->size, |
e38bb238 SM |
690 | &ctx->nfs_server.address, |
691 | sizeof(ctx->nfs_server._address)); | |
692 | if (len == 0) | |
cbd071b5 | 693 | goto out_invalid_address; |
e38bb238 | 694 | ctx->nfs_server.addrlen = len; |
cbd071b5 DH |
695 | break; |
696 | case Opt_clientaddr: | |
e38bb238 SM |
697 | kfree(ctx->client_address); |
698 | ctx->client_address = param->string; | |
699 | param->string = NULL; | |
cbd071b5 DH |
700 | break; |
701 | case Opt_mounthost: | |
e38bb238 SM |
702 | kfree(ctx->mount_server.hostname); |
703 | ctx->mount_server.hostname = param->string; | |
704 | param->string = NULL; | |
cbd071b5 DH |
705 | break; |
706 | case Opt_mountaddr: | |
62a55d08 | 707 | len = rpc_pton(fc->net_ns, param->string, param->size, |
e38bb238 SM |
708 | &ctx->mount_server.address, |
709 | sizeof(ctx->mount_server._address)); | |
710 | if (len == 0) | |
cbd071b5 | 711 | goto out_invalid_address; |
e38bb238 | 712 | ctx->mount_server.addrlen = len; |
cbd071b5 DH |
713 | break; |
714 | case Opt_nconnect: | |
e38bb238 SM |
715 | if (result.uint_32 < 1 || result.uint_32 > NFS_MAX_CONNECTIONS) |
716 | goto out_of_bounds; | |
717 | ctx->nfs_server.nconnect = result.uint_32; | |
cbd071b5 DH |
718 | break; |
719 | case Opt_lookupcache: | |
e38bb238 | 720 | switch (result.uint_32) { |
cbd071b5 DH |
721 | case Opt_lookupcache_all: |
722 | ctx->flags &= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE); | |
9954bf92 | 723 | break; |
cbd071b5 DH |
724 | case Opt_lookupcache_positive: |
725 | ctx->flags &= ~NFS_MOUNT_LOOKUP_CACHE_NONE; | |
726 | ctx->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG; | |
9954bf92 | 727 | break; |
cbd071b5 DH |
728 | case Opt_lookupcache_none: |
729 | ctx->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE; | |
9954bf92 | 730 | break; |
cbd071b5 | 731 | default: |
e38bb238 | 732 | goto out_invalid_value; |
cbd071b5 DH |
733 | } |
734 | break; | |
cbd071b5 | 735 | case Opt_local_lock: |
e38bb238 | 736 | switch (result.uint_32) { |
cbd071b5 DH |
737 | case Opt_local_lock_all: |
738 | ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK | | |
739 | NFS_MOUNT_LOCAL_FCNTL); | |
9954bf92 | 740 | break; |
cbd071b5 DH |
741 | case Opt_local_lock_flock: |
742 | ctx->flags |= NFS_MOUNT_LOCAL_FLOCK; | |
9954bf92 | 743 | break; |
cbd071b5 DH |
744 | case Opt_local_lock_posix: |
745 | ctx->flags |= NFS_MOUNT_LOCAL_FCNTL; | |
9954bf92 | 746 | break; |
cbd071b5 DH |
747 | case Opt_local_lock_none: |
748 | ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK | | |
749 | NFS_MOUNT_LOCAL_FCNTL); | |
9954bf92 | 750 | break; |
cbd071b5 | 751 | default: |
e38bb238 | 752 | goto out_invalid_value; |
cbd071b5 DH |
753 | } |
754 | break; | |
9954bf92 DH |
755 | |
756 | /* | |
757 | * Special options | |
758 | */ | |
cbd071b5 | 759 | case Opt_sloppy: |
e38bb238 | 760 | ctx->sloppy = true; |
cbd071b5 DH |
761 | dfprintk(MOUNT, "NFS: relaxing parsing rules\n"); |
762 | break; | |
9954bf92 DH |
763 | } |
764 | ||
f8ee01e3 DH |
765 | return 0; |
766 | ||
f8ee01e3 | 767 | out_invalid_value: |
ce8866f0 | 768 | return nfs_invalf(fc, "NFS: Bad mount option value specified"); |
e38bb238 | 769 | out_invalid_address: |
ce8866f0 | 770 | return nfs_invalf(fc, "NFS: Bad IP address specified"); |
e38bb238 | 771 | out_of_bounds: |
ce8866f0 | 772 | nfs_invalf(fc, "NFS: Value for '%s' out of range", param->key); |
e38bb238 SM |
773 | return -ERANGE; |
774 | } | |
775 | ||
9954bf92 | 776 | /* |
62a55d08 | 777 | * Split fc->source into "hostname:export_path". |
9954bf92 DH |
778 | * |
779 | * The leftmost colon demarks the split between the server's hostname | |
780 | * and the export path. If the hostname starts with a left square | |
781 | * bracket, then it may contain colons. | |
782 | * | |
783 | * Note: caller frees hostname and export path, even on error. | |
784 | */ | |
62a55d08 SM |
785 | static int nfs_parse_source(struct fs_context *fc, |
786 | size_t maxnamlen, size_t maxpathlen) | |
9954bf92 | 787 | { |
62a55d08 SM |
788 | struct nfs_fs_context *ctx = nfs_fc2context(fc); |
789 | const char *dev_name = fc->source; | |
9954bf92 | 790 | size_t len; |
62a55d08 | 791 | const char *end; |
9954bf92 DH |
792 | |
793 | if (unlikely(!dev_name || !*dev_name)) { | |
794 | dfprintk(MOUNT, "NFS: device name not specified\n"); | |
795 | return -EINVAL; | |
796 | } | |
797 | ||
798 | /* Is the host name protected with square brakcets? */ | |
799 | if (*dev_name == '[') { | |
800 | end = strchr(++dev_name, ']'); | |
801 | if (end == NULL || end[1] != ':') | |
802 | goto out_bad_devname; | |
803 | ||
804 | len = end - dev_name; | |
805 | end++; | |
806 | } else { | |
62a55d08 | 807 | const char *comma; |
9954bf92 DH |
808 | |
809 | end = strchr(dev_name, ':'); | |
810 | if (end == NULL) | |
811 | goto out_bad_devname; | |
812 | len = end - dev_name; | |
813 | ||
814 | /* kill possible hostname list: not supported */ | |
62a55d08 SM |
815 | comma = memchr(dev_name, ',', len); |
816 | if (comma) | |
9954bf92 DH |
817 | len = comma - dev_name; |
818 | } | |
819 | ||
820 | if (len > maxnamlen) | |
821 | goto out_hostname; | |
822 | ||
823 | /* N.B. caller will free nfs_server.hostname in all cases */ | |
e558100f DH |
824 | ctx->nfs_server.hostname = kmemdup_nul(dev_name, len, GFP_KERNEL); |
825 | if (!ctx->nfs_server.hostname) | |
9954bf92 DH |
826 | goto out_nomem; |
827 | len = strlen(++end); | |
828 | if (len > maxpathlen) | |
829 | goto out_path; | |
e558100f DH |
830 | ctx->nfs_server.export_path = kmemdup_nul(end, len, GFP_KERNEL); |
831 | if (!ctx->nfs_server.export_path) | |
9954bf92 DH |
832 | goto out_nomem; |
833 | ||
e558100f | 834 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", ctx->nfs_server.export_path); |
9954bf92 DH |
835 | return 0; |
836 | ||
837 | out_bad_devname: | |
ce8866f0 | 838 | return nfs_invalf(fc, "NFS: device name not in host:path format"); |
9954bf92 | 839 | out_nomem: |
ce8866f0 | 840 | nfs_errorf(fc, "NFS: not enough memory to parse device name"); |
9954bf92 | 841 | return -ENOMEM; |
9954bf92 | 842 | out_hostname: |
ce8866f0 | 843 | nfs_errorf(fc, "NFS: server hostname too long"); |
9954bf92 | 844 | return -ENAMETOOLONG; |
9954bf92 | 845 | out_path: |
ce8866f0 | 846 | nfs_errorf(fc, "NFS: export pathname too long"); |
9954bf92 DH |
847 | return -ENAMETOOLONG; |
848 | } | |
849 | ||
f2aedb71 DH |
850 | static inline bool is_remount_fc(struct fs_context *fc) |
851 | { | |
852 | return fc->root != NULL; | |
853 | } | |
854 | ||
9954bf92 | 855 | /* |
e558100f | 856 | * Parse monolithic NFS2/NFS3 mount data |
9954bf92 DH |
857 | * - fills in the mount root filehandle |
858 | * | |
859 | * For option strings, user space handles the following behaviors: | |
860 | * | |
861 | * + DNS: mapping server host name to IP address ("addr=" option) | |
862 | * | |
863 | * + failure mode: how to behave if a mount request can't be handled | |
864 | * immediately ("fg/bg" option) | |
865 | * | |
866 | * + retry: how often to retry a mount request ("retry=" option) | |
867 | * | |
868 | * + breaking back: trying proto=udp after proto=tcp, v2 after v3, | |
869 | * mountproto=tcp after mountproto=udp, and so on | |
870 | */ | |
f2aedb71 DH |
871 | static int nfs23_parse_monolithic(struct fs_context *fc, |
872 | struct nfs_mount_data *data) | |
9954bf92 | 873 | { |
f2aedb71 | 874 | struct nfs_fs_context *ctx = nfs_fc2context(fc); |
62a55d08 | 875 | struct nfs_fh *mntfh = ctx->mntfh; |
5eb005ca | 876 | struct sockaddr *sap = (struct sockaddr *)&ctx->nfs_server.address; |
9954bf92 DH |
877 | int extra_flags = NFS_MOUNT_LEGACY_INTERFACE; |
878 | ||
879 | if (data == NULL) | |
880 | goto out_no_data; | |
881 | ||
5eb005ca | 882 | ctx->version = NFS_DEFAULT_VERSION; |
9954bf92 DH |
883 | switch (data->version) { |
884 | case 1: | |
885 | data->namlen = 0; /* fall through */ | |
886 | case 2: | |
887 | data->bsize = 0; /* fall through */ | |
888 | case 3: | |
889 | if (data->flags & NFS_MOUNT_VER3) | |
890 | goto out_no_v3; | |
891 | data->root.size = NFS2_FHSIZE; | |
892 | memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE); | |
893 | /* Turn off security negotiation */ | |
894 | extra_flags |= NFS_MOUNT_SECFLAVOUR; | |
895 | /* fall through */ | |
896 | case 4: | |
897 | if (data->flags & NFS_MOUNT_SECFLAVOUR) | |
898 | goto out_no_sec; | |
899 | /* fall through */ | |
900 | case 5: | |
901 | memset(data->context, 0, sizeof(data->context)); | |
902 | /* fall through */ | |
903 | case 6: | |
904 | if (data->flags & NFS_MOUNT_VER3) { | |
905 | if (data->root.size > NFS3_FHSIZE || data->root.size == 0) | |
906 | goto out_invalid_fh; | |
907 | mntfh->size = data->root.size; | |
5eb005ca | 908 | ctx->version = 3; |
9954bf92 DH |
909 | } else { |
910 | mntfh->size = NFS2_FHSIZE; | |
5eb005ca | 911 | ctx->version = 2; |
9954bf92 DH |
912 | } |
913 | ||
914 | ||
915 | memcpy(mntfh->data, data->root.data, mntfh->size); | |
916 | if (mntfh->size < sizeof(mntfh->data)) | |
917 | memset(mntfh->data + mntfh->size, 0, | |
918 | sizeof(mntfh->data) - mntfh->size); | |
919 | ||
920 | /* | |
5eb005ca | 921 | * Translate to nfs_fs_context, which nfs_fill_super |
9954bf92 DH |
922 | * can deal with. |
923 | */ | |
5eb005ca DH |
924 | ctx->flags = data->flags & NFS_MOUNT_FLAGMASK; |
925 | ctx->flags |= extra_flags; | |
926 | ctx->rsize = data->rsize; | |
927 | ctx->wsize = data->wsize; | |
928 | ctx->timeo = data->timeo; | |
929 | ctx->retrans = data->retrans; | |
930 | ctx->acregmin = data->acregmin; | |
931 | ctx->acregmax = data->acregmax; | |
932 | ctx->acdirmin = data->acdirmin; | |
933 | ctx->acdirmax = data->acdirmax; | |
934 | ctx->need_mount = false; | |
9954bf92 DH |
935 | |
936 | memcpy(sap, &data->addr, sizeof(data->addr)); | |
5eb005ca DH |
937 | ctx->nfs_server.addrlen = sizeof(data->addr); |
938 | ctx->nfs_server.port = ntohs(data->addr.sin_port); | |
9954bf92 DH |
939 | if (sap->sa_family != AF_INET || |
940 | !nfs_verify_server_address(sap)) | |
941 | goto out_no_address; | |
942 | ||
943 | if (!(data->flags & NFS_MOUNT_TCP)) | |
5eb005ca | 944 | ctx->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
9954bf92 | 945 | /* N.B. caller will free nfs_server.hostname in all cases */ |
5eb005ca | 946 | ctx->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL); |
f2aedb71 DH |
947 | if (!ctx->nfs_server.hostname) |
948 | goto out_nomem; | |
949 | ||
5eb005ca DH |
950 | ctx->namlen = data->namlen; |
951 | ctx->bsize = data->bsize; | |
9954bf92 DH |
952 | |
953 | if (data->flags & NFS_MOUNT_SECFLAVOUR) | |
5eb005ca | 954 | ctx->selected_flavor = data->pseudoflavor; |
9954bf92 | 955 | else |
5eb005ca | 956 | ctx->selected_flavor = RPC_AUTH_UNIX; |
9954bf92 DH |
957 | |
958 | if (!(data->flags & NFS_MOUNT_NONLM)) | |
5eb005ca | 959 | ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK| |
9954bf92 DH |
960 | NFS_MOUNT_LOCAL_FCNTL); |
961 | else | |
5eb005ca | 962 | ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK| |
9954bf92 | 963 | NFS_MOUNT_LOCAL_FCNTL); |
62a55d08 | 964 | |
9954bf92 DH |
965 | /* |
966 | * The legacy version 6 binary mount data from userspace has a | |
967 | * field used only to transport selinux information into the | |
968 | * the kernel. To continue to support that functionality we | |
969 | * have a touch of selinux knowledge here in the NFS code. The | |
970 | * userspace code converted context=blah to just blah so we are | |
971 | * converting back to the full string selinux understands. | |
972 | */ | |
973 | if (data->context[0]){ | |
974 | #ifdef CONFIG_SECURITY_SELINUX | |
f2aedb71 DH |
975 | int ret; |
976 | ||
9954bf92 | 977 | data->context[NFS_MAX_CONTEXT_LEN] = '\0'; |
f2aedb71 DH |
978 | ret = vfs_parse_fs_string(fc, "context", |
979 | data->context, strlen(data->context)); | |
980 | if (ret < 0) | |
981 | return ret; | |
9954bf92 DH |
982 | #else |
983 | return -EINVAL; | |
984 | #endif | |
985 | } | |
986 | ||
987 | break; | |
988 | default: | |
f2aedb71 | 989 | goto generic; |
9954bf92 DH |
990 | } |
991 | ||
f2aedb71 | 992 | ctx->skip_reconfig_option_check = true; |
9954bf92 DH |
993 | return 0; |
994 | ||
f2aedb71 DH |
995 | generic: |
996 | return generic_parse_monolithic(fc, data); | |
997 | ||
9954bf92 | 998 | out_no_data: |
f2aedb71 DH |
999 | if (is_remount_fc(fc)) { |
1000 | ctx->skip_reconfig_option_check = true; | |
1001 | return 0; | |
1002 | } | |
ce8866f0 | 1003 | return nfs_invalf(fc, "NFS: mount program didn't pass any mount data"); |
9954bf92 DH |
1004 | |
1005 | out_no_v3: | |
ce8866f0 | 1006 | return nfs_invalf(fc, "NFS: nfs_mount_data version does not support v3"); |
9954bf92 DH |
1007 | |
1008 | out_no_sec: | |
ce8866f0 | 1009 | return nfs_invalf(fc, "NFS: nfs_mount_data version supports only AUTH_SYS"); |
9954bf92 DH |
1010 | |
1011 | out_nomem: | |
ce8866f0 | 1012 | dfprintk(MOUNT, "NFS: not enough memory to handle mount options"); |
9954bf92 DH |
1013 | return -ENOMEM; |
1014 | ||
1015 | out_no_address: | |
ce8866f0 | 1016 | return nfs_invalf(fc, "NFS: mount program didn't pass remote address"); |
9954bf92 DH |
1017 | |
1018 | out_invalid_fh: | |
ce8866f0 | 1019 | return nfs_invalf(fc, "NFS: invalid root filehandle"); |
9954bf92 DH |
1020 | } |
1021 | ||
1022 | #if IS_ENABLED(CONFIG_NFS_V4) | |
9954bf92 DH |
1023 | /* |
1024 | * Validate NFSv4 mount options | |
1025 | */ | |
f2aedb71 DH |
1026 | static int nfs4_parse_monolithic(struct fs_context *fc, |
1027 | struct nfs4_mount_data *data) | |
9954bf92 | 1028 | { |
f2aedb71 | 1029 | struct nfs_fs_context *ctx = nfs_fc2context(fc); |
5eb005ca | 1030 | struct sockaddr *sap = (struct sockaddr *)&ctx->nfs_server.address; |
9954bf92 DH |
1031 | char *c; |
1032 | ||
1033 | if (data == NULL) | |
1034 | goto out_no_data; | |
1035 | ||
5eb005ca | 1036 | ctx->version = 4; |
9954bf92 DH |
1037 | |
1038 | switch (data->version) { | |
1039 | case 1: | |
5eb005ca | 1040 | if (data->host_addrlen > sizeof(ctx->nfs_server.address)) |
9954bf92 DH |
1041 | goto out_no_address; |
1042 | if (data->host_addrlen == 0) | |
1043 | goto out_no_address; | |
5eb005ca | 1044 | ctx->nfs_server.addrlen = data->host_addrlen; |
9954bf92 DH |
1045 | if (copy_from_user(sap, data->host_addr, data->host_addrlen)) |
1046 | return -EFAULT; | |
1047 | if (!nfs_verify_server_address(sap)) | |
1048 | goto out_no_address; | |
5eb005ca | 1049 | ctx->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port); |
9954bf92 DH |
1050 | |
1051 | if (data->auth_flavourlen) { | |
1052 | rpc_authflavor_t pseudoflavor; | |
1053 | if (data->auth_flavourlen > 1) | |
1054 | goto out_inval_auth; | |
1055 | if (copy_from_user(&pseudoflavor, | |
1056 | data->auth_flavours, | |
1057 | sizeof(pseudoflavor))) | |
1058 | return -EFAULT; | |
5eb005ca | 1059 | ctx->selected_flavor = pseudoflavor; |
9954bf92 | 1060 | } else |
5eb005ca | 1061 | ctx->selected_flavor = RPC_AUTH_UNIX; |
9954bf92 DH |
1062 | |
1063 | c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); | |
1064 | if (IS_ERR(c)) | |
1065 | return PTR_ERR(c); | |
5eb005ca | 1066 | ctx->nfs_server.hostname = c; |
9954bf92 DH |
1067 | |
1068 | c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN); | |
1069 | if (IS_ERR(c)) | |
1070 | return PTR_ERR(c); | |
5eb005ca | 1071 | ctx->nfs_server.export_path = c; |
9954bf92 DH |
1072 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c); |
1073 | ||
1074 | c = strndup_user(data->client_addr.data, 16); | |
1075 | if (IS_ERR(c)) | |
1076 | return PTR_ERR(c); | |
5eb005ca | 1077 | ctx->client_address = c; |
9954bf92 DH |
1078 | |
1079 | /* | |
f2aedb71 | 1080 | * Translate to nfs_fs_context, which nfs_fill_super |
9954bf92 DH |
1081 | * can deal with. |
1082 | */ | |
1083 | ||
5eb005ca DH |
1084 | ctx->flags = data->flags & NFS4_MOUNT_FLAGMASK; |
1085 | ctx->rsize = data->rsize; | |
1086 | ctx->wsize = data->wsize; | |
1087 | ctx->timeo = data->timeo; | |
1088 | ctx->retrans = data->retrans; | |
1089 | ctx->acregmin = data->acregmin; | |
1090 | ctx->acregmax = data->acregmax; | |
1091 | ctx->acdirmin = data->acdirmin; | |
1092 | ctx->acdirmax = data->acdirmax; | |
1093 | ctx->nfs_server.protocol = data->proto; | |
1094 | nfs_validate_transport_protocol(ctx); | |
1095 | if (ctx->nfs_server.protocol == XPRT_TRANSPORT_UDP) | |
9954bf92 DH |
1096 | goto out_invalid_transport_udp; |
1097 | ||
1098 | break; | |
1099 | default: | |
f2aedb71 | 1100 | goto generic; |
9954bf92 DH |
1101 | } |
1102 | ||
f2aedb71 | 1103 | ctx->skip_reconfig_option_check = true; |
9954bf92 DH |
1104 | return 0; |
1105 | ||
f2aedb71 DH |
1106 | generic: |
1107 | return generic_parse_monolithic(fc, data); | |
1108 | ||
9954bf92 | 1109 | out_no_data: |
f2aedb71 DH |
1110 | if (is_remount_fc(fc)) { |
1111 | ctx->skip_reconfig_option_check = true; | |
1112 | return 0; | |
1113 | } | |
ce8866f0 | 1114 | return nfs_invalf(fc, "NFS4: mount program didn't pass any mount data"); |
9954bf92 DH |
1115 | |
1116 | out_inval_auth: | |
ce8866f0 SM |
1117 | return nfs_invalf(fc, "NFS4: Invalid number of RPC auth flavours %d", |
1118 | data->auth_flavourlen); | |
9954bf92 DH |
1119 | |
1120 | out_no_address: | |
ce8866f0 | 1121 | return nfs_invalf(fc, "NFS4: mount program didn't pass remote address"); |
9954bf92 DH |
1122 | |
1123 | out_invalid_transport_udp: | |
ce8866f0 | 1124 | return nfs_invalf(fc, "NFSv4: Unsupported transport protocol udp"); |
9954bf92 | 1125 | } |
f2aedb71 | 1126 | #endif |
9954bf92 | 1127 | |
f2aedb71 DH |
1128 | /* |
1129 | * Parse a monolithic block of data from sys_mount(). | |
1130 | */ | |
1131 | static int nfs_fs_context_parse_monolithic(struct fs_context *fc, | |
1132 | void *data) | |
9954bf92 | 1133 | { |
f2aedb71 DH |
1134 | if (fc->fs_type == &nfs_fs_type) |
1135 | return nfs23_parse_monolithic(fc, data); | |
1136 | ||
1137 | #if IS_ENABLED(CONFIG_NFS_V4) | |
1138 | if (fc->fs_type == &nfs4_fs_type) | |
1139 | return nfs4_parse_monolithic(fc, data); | |
9954bf92 DH |
1140 | #endif |
1141 | ||
ce8866f0 | 1142 | return nfs_invalf(fc, "NFS: Unsupported monolithic data version"); |
f2aedb71 DH |
1143 | } |
1144 | ||
1145 | /* | |
1146 | * Validate the preparsed information in the config. | |
1147 | */ | |
1148 | static int nfs_fs_context_validate(struct fs_context *fc) | |
9954bf92 | 1149 | { |
f2aedb71 DH |
1150 | struct nfs_fs_context *ctx = nfs_fc2context(fc); |
1151 | struct nfs_subversion *nfs_mod; | |
1152 | struct sockaddr *sap = (struct sockaddr *)&ctx->nfs_server.address; | |
9954bf92 DH |
1153 | int max_namelen = PAGE_SIZE; |
1154 | int max_pathlen = NFS_MAXPATHLEN; | |
f2aedb71 DH |
1155 | int port = 0; |
1156 | int ret; | |
9954bf92 | 1157 | |
f2aedb71 DH |
1158 | if (!fc->source) |
1159 | goto out_no_device_name; | |
1160 | ||
1161 | /* Check for sanity first. */ | |
1162 | if (ctx->minorversion && ctx->version != 4) | |
1163 | goto out_minorversion_mismatch; | |
1164 | ||
1165 | if (ctx->options & NFS_OPTION_MIGRATION && | |
1166 | (ctx->version != 4 || ctx->minorversion != 0)) | |
1167 | goto out_migration_misuse; | |
1168 | ||
1169 | /* Verify that any proto=/mountproto= options match the address | |
1170 | * families in the addr=/mountaddr= options. | |
1171 | */ | |
1172 | if (ctx->protofamily != AF_UNSPEC && | |
1173 | ctx->protofamily != ctx->nfs_server.address.sa_family) | |
1174 | goto out_proto_mismatch; | |
1175 | ||
1176 | if (ctx->mountfamily != AF_UNSPEC) { | |
1177 | if (ctx->mount_server.addrlen) { | |
1178 | if (ctx->mountfamily != ctx->mount_server.address.sa_family) | |
1179 | goto out_mountproto_mismatch; | |
1180 | } else { | |
1181 | if (ctx->mountfamily != ctx->nfs_server.address.sa_family) | |
1182 | goto out_mountproto_mismatch; | |
1183 | } | |
1184 | } | |
9954bf92 DH |
1185 | |
1186 | if (!nfs_verify_server_address(sap)) | |
1187 | goto out_no_address; | |
1188 | ||
5eb005ca | 1189 | if (ctx->version == 4) { |
62a55d08 SM |
1190 | if (IS_ENABLED(CONFIG_NFS_V4)) { |
1191 | if (ctx->nfs_server.protocol == XPRT_TRANSPORT_RDMA) | |
1192 | port = NFS_RDMA_PORT; | |
1193 | else | |
1194 | port = NFS_PORT; | |
1195 | max_namelen = NFS4_MAXNAMLEN; | |
1196 | max_pathlen = NFS4_MAXPATHLEN; | |
1197 | nfs_validate_transport_protocol(ctx); | |
1198 | if (ctx->nfs_server.protocol == XPRT_TRANSPORT_UDP) | |
1199 | goto out_invalid_transport_udp; | |
1200 | ctx->flags &= ~(NFS_MOUNT_NONLM | NFS_MOUNT_NOACL | | |
1201 | NFS_MOUNT_VER3 | NFS_MOUNT_LOCAL_FLOCK | | |
1202 | NFS_MOUNT_LOCAL_FCNTL); | |
1203 | } else { | |
1204 | goto out_v4_not_compiled; | |
1205 | } | |
9954bf92 | 1206 | } else { |
5eb005ca DH |
1207 | nfs_set_mount_transport_protocol(ctx); |
1208 | if (ctx->nfs_server.protocol == XPRT_TRANSPORT_RDMA) | |
9954bf92 DH |
1209 | port = NFS_RDMA_PORT; |
1210 | } | |
1211 | ||
5eb005ca | 1212 | nfs_set_port(sap, &ctx->nfs_server.port, port); |
9954bf92 | 1213 | |
62a55d08 | 1214 | ret = nfs_parse_source(fc, max_namelen, max_pathlen); |
f2aedb71 DH |
1215 | if (ret < 0) |
1216 | return ret; | |
1217 | ||
1218 | /* Load the NFS protocol module if we haven't done so yet */ | |
62a55d08 | 1219 | if (!ctx->nfs_mod) { |
f2aedb71 DH |
1220 | nfs_mod = get_nfs_version(ctx->version); |
1221 | if (IS_ERR(nfs_mod)) { | |
1222 | ret = PTR_ERR(nfs_mod); | |
1223 | goto out_version_unavailable; | |
1224 | } | |
62a55d08 | 1225 | ctx->nfs_mod = nfs_mod; |
f2aedb71 DH |
1226 | } |
1227 | return 0; | |
9954bf92 | 1228 | |
f2aedb71 | 1229 | out_no_device_name: |
ce8866f0 | 1230 | return nfs_invalf(fc, "NFS: Device name not specified"); |
9954bf92 | 1231 | out_v4_not_compiled: |
ce8866f0 | 1232 | nfs_errorf(fc, "NFS: NFSv4 is not compiled into kernel"); |
9954bf92 | 1233 | return -EPROTONOSUPPORT; |
9954bf92 | 1234 | out_invalid_transport_udp: |
ce8866f0 | 1235 | return nfs_invalf(fc, "NFSv4: Unsupported transport protocol udp"); |
9954bf92 | 1236 | out_no_address: |
ce8866f0 | 1237 | return nfs_invalf(fc, "NFS: mount program didn't pass remote address"); |
f2aedb71 | 1238 | out_mountproto_mismatch: |
ce8866f0 | 1239 | return nfs_invalf(fc, "NFS: Mount server address does not match mountproto= option"); |
f2aedb71 | 1240 | out_proto_mismatch: |
ce8866f0 | 1241 | return nfs_invalf(fc, "NFS: Server address does not match proto= option"); |
f2aedb71 | 1242 | out_minorversion_mismatch: |
ce8866f0 | 1243 | return nfs_invalf(fc, "NFS: Mount option vers=%u does not support minorversion=%u", |
f2aedb71 | 1244 | ctx->version, ctx->minorversion); |
f2aedb71 | 1245 | out_migration_misuse: |
ce8866f0 | 1246 | return nfs_invalf(fc, "NFS: 'Migration' not supported for this NFS version"); |
f2aedb71 | 1247 | out_version_unavailable: |
ce8866f0 | 1248 | nfs_errorf(fc, "NFS: Version unavailable"); |
f2aedb71 DH |
1249 | return ret; |
1250 | } | |
1251 | ||
1252 | /* | |
1253 | * Create an NFS superblock by the appropriate method. | |
1254 | */ | |
1255 | static int nfs_get_tree(struct fs_context *fc) | |
1256 | { | |
1257 | struct nfs_fs_context *ctx = nfs_fc2context(fc); | |
1258 | int err = nfs_fs_context_validate(fc); | |
1259 | ||
1260 | if (err) | |
1261 | return err; | |
1262 | if (!ctx->internal) | |
62a55d08 | 1263 | return ctx->nfs_mod->rpc_ops->try_get_tree(fc); |
f2aedb71 DH |
1264 | else |
1265 | return nfs_get_tree_common(fc); | |
9954bf92 | 1266 | } |
f2aedb71 DH |
1267 | |
1268 | /* | |
1269 | * Handle duplication of a configuration. The caller copied *src into *sc, but | |
1270 | * it can't deal with resource pointers in the filesystem context, so we have | |
1271 | * to do that. We need to clear pointers, copy data or get extra refs as | |
1272 | * appropriate. | |
1273 | */ | |
1274 | static int nfs_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc) | |
1275 | { | |
1276 | struct nfs_fs_context *src = nfs_fc2context(src_fc), *ctx; | |
1277 | ||
1278 | ctx = kmemdup(src, sizeof(struct nfs_fs_context), GFP_KERNEL); | |
1279 | if (!ctx) | |
1280 | return -ENOMEM; | |
1281 | ||
62a55d08 SM |
1282 | ctx->mntfh = nfs_alloc_fhandle(); |
1283 | if (!ctx->mntfh) { | |
f2aedb71 DH |
1284 | kfree(ctx); |
1285 | return -ENOMEM; | |
1286 | } | |
62a55d08 | 1287 | nfs_copy_fh(ctx->mntfh, src->mntfh); |
f2aedb71 | 1288 | |
62a55d08 | 1289 | __module_get(ctx->nfs_mod->owner); |
f2aedb71 DH |
1290 | ctx->client_address = NULL; |
1291 | ctx->mount_server.hostname = NULL; | |
1292 | ctx->nfs_server.export_path = NULL; | |
1293 | ctx->nfs_server.hostname = NULL; | |
1294 | ctx->fscache_uniq = NULL; | |
f2aedb71 DH |
1295 | ctx->clone_data.fattr = NULL; |
1296 | fc->fs_private = ctx; | |
1297 | return 0; | |
1298 | } | |
1299 | ||
1300 | static void nfs_fs_context_free(struct fs_context *fc) | |
1301 | { | |
1302 | struct nfs_fs_context *ctx = nfs_fc2context(fc); | |
1303 | ||
1304 | if (ctx) { | |
62a55d08 SM |
1305 | if (ctx->server) |
1306 | nfs_free_server(ctx->server); | |
1307 | if (ctx->nfs_mod) | |
1308 | put_nfs_version(ctx->nfs_mod); | |
f2aedb71 DH |
1309 | kfree(ctx->client_address); |
1310 | kfree(ctx->mount_server.hostname); | |
1311 | kfree(ctx->nfs_server.export_path); | |
1312 | kfree(ctx->nfs_server.hostname); | |
1313 | kfree(ctx->fscache_uniq); | |
62a55d08 | 1314 | nfs_free_fhandle(ctx->mntfh); |
f2aedb71 DH |
1315 | nfs_free_fattr(ctx->clone_data.fattr); |
1316 | kfree(ctx); | |
1317 | } | |
1318 | } | |
1319 | ||
1320 | static const struct fs_context_operations nfs_fs_context_ops = { | |
1321 | .free = nfs_fs_context_free, | |
1322 | .dup = nfs_fs_context_dup, | |
1323 | .parse_param = nfs_fs_context_parse_param, | |
1324 | .parse_monolithic = nfs_fs_context_parse_monolithic, | |
1325 | .get_tree = nfs_get_tree, | |
1326 | .reconfigure = nfs_reconfigure, | |
1327 | }; | |
1328 | ||
1329 | /* | |
1330 | * Prepare superblock configuration. We use the namespaces attached to the | |
1331 | * context. This may be the current process's namespaces, or it may be a | |
1332 | * container's namespaces. | |
1333 | */ | |
1334 | static int nfs_init_fs_context(struct fs_context *fc) | |
1335 | { | |
1336 | struct nfs_fs_context *ctx; | |
1337 | ||
1338 | ctx = kzalloc(sizeof(struct nfs_fs_context), GFP_KERNEL); | |
1339 | if (unlikely(!ctx)) | |
1340 | return -ENOMEM; | |
1341 | ||
62a55d08 SM |
1342 | ctx->mntfh = nfs_alloc_fhandle(); |
1343 | if (unlikely(!ctx->mntfh)) { | |
f2aedb71 DH |
1344 | kfree(ctx); |
1345 | return -ENOMEM; | |
1346 | } | |
1347 | ||
1348 | ctx->protofamily = AF_UNSPEC; | |
1349 | ctx->mountfamily = AF_UNSPEC; | |
1350 | ctx->mount_server.port = NFS_UNSPEC_PORT; | |
1351 | ||
1352 | if (fc->root) { | |
1353 | /* reconfigure, start with the current config */ | |
1354 | struct nfs_server *nfss = fc->root->d_sb->s_fs_info; | |
1355 | struct net *net = nfss->nfs_client->cl_net; | |
1356 | ||
1357 | ctx->flags = nfss->flags; | |
1358 | ctx->rsize = nfss->rsize; | |
1359 | ctx->wsize = nfss->wsize; | |
1360 | ctx->retrans = nfss->client->cl_timeout->to_retries; | |
1361 | ctx->selected_flavor = nfss->client->cl_auth->au_flavor; | |
1362 | ctx->acregmin = nfss->acregmin / HZ; | |
1363 | ctx->acregmax = nfss->acregmax / HZ; | |
1364 | ctx->acdirmin = nfss->acdirmin / HZ; | |
1365 | ctx->acdirmax = nfss->acdirmax / HZ; | |
1366 | ctx->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ; | |
1367 | ctx->nfs_server.port = nfss->port; | |
1368 | ctx->nfs_server.addrlen = nfss->nfs_client->cl_addrlen; | |
1369 | ctx->version = nfss->nfs_client->rpc_ops->version; | |
1370 | ctx->minorversion = nfss->nfs_client->cl_minorversion; | |
1371 | ||
1372 | memcpy(&ctx->nfs_server.address, &nfss->nfs_client->cl_addr, | |
1373 | ctx->nfs_server.addrlen); | |
1374 | ||
1375 | if (fc->net_ns != net) { | |
1376 | put_net(fc->net_ns); | |
1377 | fc->net_ns = get_net(net); | |
1378 | } | |
1379 | ||
62a55d08 SM |
1380 | ctx->nfs_mod = nfss->nfs_client->cl_nfs_mod; |
1381 | __module_get(ctx->nfs_mod->owner); | |
f2aedb71 DH |
1382 | } else { |
1383 | /* defaults */ | |
1384 | ctx->timeo = NFS_UNSPEC_TIMEO; | |
1385 | ctx->retrans = NFS_UNSPEC_RETRANS; | |
1386 | ctx->acregmin = NFS_DEF_ACREGMIN; | |
1387 | ctx->acregmax = NFS_DEF_ACREGMAX; | |
1388 | ctx->acdirmin = NFS_DEF_ACDIRMIN; | |
1389 | ctx->acdirmax = NFS_DEF_ACDIRMAX; | |
1390 | ctx->nfs_server.port = NFS_UNSPEC_PORT; | |
1391 | ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP; | |
1392 | ctx->selected_flavor = RPC_AUTH_MAXFLAVOR; | |
1393 | ctx->minorversion = 0; | |
1394 | ctx->need_mount = true; | |
1395 | } | |
f2aedb71 DH |
1396 | fc->fs_private = ctx; |
1397 | fc->ops = &nfs_fs_context_ops; | |
1398 | return 0; | |
1399 | } | |
1400 | ||
1401 | struct file_system_type nfs_fs_type = { | |
1402 | .owner = THIS_MODULE, | |
1403 | .name = "nfs", | |
1404 | .init_fs_context = nfs_init_fs_context, | |
1405 | .parameters = &nfs_fs_parameters, | |
1406 | .kill_sb = nfs_kill_super, | |
1407 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, | |
1408 | }; | |
1409 | MODULE_ALIAS_FS("nfs"); | |
1410 | EXPORT_SYMBOL_GPL(nfs_fs_type); | |
1411 | ||
1412 | #if IS_ENABLED(CONFIG_NFS_V4) | |
1413 | struct file_system_type nfs4_fs_type = { | |
1414 | .owner = THIS_MODULE, | |
1415 | .name = "nfs4", | |
1416 | .init_fs_context = nfs_init_fs_context, | |
1417 | .parameters = &nfs_fs_parameters, | |
1418 | .kill_sb = nfs_kill_super, | |
1419 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, | |
1420 | }; | |
1421 | MODULE_ALIAS_FS("nfs4"); | |
1422 | MODULE_ALIAS("nfs4"); | |
1423 | EXPORT_SYMBOL_GPL(nfs4_fs_type); | |
1424 | #endif /* CONFIG_NFS_V4 */ |