diff options
Diffstat (limited to 'fs/nfsd/nfsctl.c')
-rw-r--r-- | fs/nfsd/nfsctl.c | 481 |
1 files changed, 452 insertions, 29 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index e3f9783fdcf7..3d93b2064ce5 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -84,6 +84,8 @@ static ssize_t write_unexport(struct file *file, char *buf, size_t size); | |||
84 | static ssize_t write_getfd(struct file *file, char *buf, size_t size); | 84 | static ssize_t write_getfd(struct file *file, char *buf, size_t size); |
85 | static ssize_t write_getfs(struct file *file, char *buf, size_t size); | 85 | static ssize_t write_getfs(struct file *file, char *buf, size_t size); |
86 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size); | 86 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size); |
87 | static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size); | ||
88 | static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size); | ||
87 | static ssize_t write_threads(struct file *file, char *buf, size_t size); | 89 | static ssize_t write_threads(struct file *file, char *buf, size_t size); |
88 | static ssize_t write_pool_threads(struct file *file, char *buf, size_t size); | 90 | static ssize_t write_pool_threads(struct file *file, char *buf, size_t size); |
89 | static ssize_t write_versions(struct file *file, char *buf, size_t size); | 91 | static ssize_t write_versions(struct file *file, char *buf, size_t size); |
@@ -94,9 +96,6 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size); | |||
94 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); | 96 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); |
95 | #endif | 97 | #endif |
96 | 98 | ||
97 | static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size); | ||
98 | static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size); | ||
99 | |||
100 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { | 99 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { |
101 | [NFSD_Svc] = write_svc, | 100 | [NFSD_Svc] = write_svc, |
102 | [NFSD_Add] = write_add, | 101 | [NFSD_Add] = write_add, |
@@ -106,8 +105,8 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { | |||
106 | [NFSD_Getfd] = write_getfd, | 105 | [NFSD_Getfd] = write_getfd, |
107 | [NFSD_Getfs] = write_getfs, | 106 | [NFSD_Getfs] = write_getfs, |
108 | [NFSD_Fh] = write_filehandle, | 107 | [NFSD_Fh] = write_filehandle, |
109 | [NFSD_FO_UnlockIP] = failover_unlock_ip, | 108 | [NFSD_FO_UnlockIP] = write_unlock_ip, |
110 | [NFSD_FO_UnlockFS] = failover_unlock_fs, | 109 | [NFSD_FO_UnlockFS] = write_unlock_fs, |
111 | [NFSD_Threads] = write_threads, | 110 | [NFSD_Threads] = write_threads, |
112 | [NFSD_Pool_Threads] = write_pool_threads, | 111 | [NFSD_Pool_Threads] = write_pool_threads, |
113 | [NFSD_Versions] = write_versions, | 112 | [NFSD_Versions] = write_versions, |
@@ -176,10 +175,24 @@ static const struct file_operations exports_operations = { | |||
176 | /*----------------------------------------------------------------------------*/ | 175 | /*----------------------------------------------------------------------------*/ |
177 | /* | 176 | /* |
178 | * payload - write methods | 177 | * payload - write methods |
179 | * If the method has a response, the response should be put in buf, | ||
180 | * and the length returned. Otherwise return 0 or and -error. | ||
181 | */ | 178 | */ |
182 | 179 | ||
180 | /** | ||
181 | * write_svc - Start kernel's NFSD server | ||
182 | * | ||
183 | * Deprecated. /proc/fs/nfsd/threads is preferred. | ||
184 | * Function remains to support old versions of nfs-utils. | ||
185 | * | ||
186 | * Input: | ||
187 | * buf: struct nfsctl_svc | ||
188 | * svc_port: port number of this | ||
189 | * server's listener | ||
190 | * svc_nthreads: number of threads to start | ||
191 | * size: size in bytes of passed in nfsctl_svc | ||
192 | * Output: | ||
193 | * On success: returns zero | ||
194 | * On error: return code is negative errno value | ||
195 | */ | ||
183 | static ssize_t write_svc(struct file *file, char *buf, size_t size) | 196 | static ssize_t write_svc(struct file *file, char *buf, size_t size) |
184 | { | 197 | { |
185 | struct nfsctl_svc *data; | 198 | struct nfsctl_svc *data; |
@@ -189,6 +202,30 @@ static ssize_t write_svc(struct file *file, char *buf, size_t size) | |||
189 | return nfsd_svc(data->svc_port, data->svc_nthreads); | 202 | return nfsd_svc(data->svc_port, data->svc_nthreads); |
190 | } | 203 | } |
191 | 204 | ||
205 | /** | ||
206 | * write_add - Add or modify client entry in auth unix cache | ||
207 | * | ||
208 | * Deprecated. /proc/net/rpc/auth.unix.ip is preferred. | ||
209 | * Function remains to support old versions of nfs-utils. | ||
210 | * | ||
211 | * Input: | ||
212 | * buf: struct nfsctl_client | ||
213 | * cl_ident: '\0'-terminated C string | ||
214 | * containing domain name | ||
215 | * of client | ||
216 | * cl_naddr: no. of items in cl_addrlist | ||
217 | * cl_addrlist: array of client addresses | ||
218 | * cl_fhkeytype: ignored | ||
219 | * cl_fhkeylen: ignored | ||
220 | * cl_fhkey: ignored | ||
221 | * size: size in bytes of passed in nfsctl_client | ||
222 | * Output: | ||
223 | * On success: returns zero | ||
224 | * On error: return code is negative errno value | ||
225 | * | ||
226 | * Note: Only AF_INET client addresses are passed in, since | ||
227 | * nfsctl_client.cl_addrlist contains only in_addr fields for addresses. | ||
228 | */ | ||
192 | static ssize_t write_add(struct file *file, char *buf, size_t size) | 229 | static ssize_t write_add(struct file *file, char *buf, size_t size) |
193 | { | 230 | { |
194 | struct nfsctl_client *data; | 231 | struct nfsctl_client *data; |
@@ -198,6 +235,30 @@ static ssize_t write_add(struct file *file, char *buf, size_t size) | |||
198 | return exp_addclient(data); | 235 | return exp_addclient(data); |
199 | } | 236 | } |
200 | 237 | ||
238 | /** | ||
239 | * write_del - Remove client from auth unix cache | ||
240 | * | ||
241 | * Deprecated. /proc/net/rpc/auth.unix.ip is preferred. | ||
242 | * Function remains to support old versions of nfs-utils. | ||
243 | * | ||
244 | * Input: | ||
245 | * buf: struct nfsctl_client | ||
246 | * cl_ident: '\0'-terminated C string | ||
247 | * containing domain name | ||
248 | * of client | ||
249 | * cl_naddr: ignored | ||
250 | * cl_addrlist: ignored | ||
251 | * cl_fhkeytype: ignored | ||
252 | * cl_fhkeylen: ignored | ||
253 | * cl_fhkey: ignored | ||
254 | * size: size in bytes of passed in nfsctl_client | ||
255 | * Output: | ||
256 | * On success: returns zero | ||
257 | * On error: return code is negative errno value | ||
258 | * | ||
259 | * Note: Only AF_INET client addresses are passed in, since | ||
260 | * nfsctl_client.cl_addrlist contains only in_addr fields for addresses. | ||
261 | */ | ||
201 | static ssize_t write_del(struct file *file, char *buf, size_t size) | 262 | static ssize_t write_del(struct file *file, char *buf, size_t size) |
202 | { | 263 | { |
203 | struct nfsctl_client *data; | 264 | struct nfsctl_client *data; |
@@ -207,6 +268,33 @@ static ssize_t write_del(struct file *file, char *buf, size_t size) | |||
207 | return exp_delclient(data); | 268 | return exp_delclient(data); |
208 | } | 269 | } |
209 | 270 | ||
271 | /** | ||
272 | * write_export - Export part or all of a local file system | ||
273 | * | ||
274 | * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred. | ||
275 | * Function remains to support old versions of nfs-utils. | ||
276 | * | ||
277 | * Input: | ||
278 | * buf: struct nfsctl_export | ||
279 | * ex_client: '\0'-terminated C string | ||
280 | * containing domain name | ||
281 | * of client allowed to access | ||
282 | * this export | ||
283 | * ex_path: '\0'-terminated C string | ||
284 | * containing pathname of | ||
285 | * directory in local file system | ||
286 | * ex_dev: fsid to use for this export | ||
287 | * ex_ino: ignored | ||
288 | * ex_flags: export flags for this export | ||
289 | * ex_anon_uid: UID to use for anonymous | ||
290 | * requests | ||
291 | * ex_anon_gid: GID to use for anonymous | ||
292 | * requests | ||
293 | * size: size in bytes of passed in nfsctl_export | ||
294 | * Output: | ||
295 | * On success: returns zero | ||
296 | * On error: return code is negative errno value | ||
297 | */ | ||
210 | static ssize_t write_export(struct file *file, char *buf, size_t size) | 298 | static ssize_t write_export(struct file *file, char *buf, size_t size) |
211 | { | 299 | { |
212 | struct nfsctl_export *data; | 300 | struct nfsctl_export *data; |
@@ -216,6 +304,31 @@ static ssize_t write_export(struct file *file, char *buf, size_t size) | |||
216 | return exp_export(data); | 304 | return exp_export(data); |
217 | } | 305 | } |
218 | 306 | ||
307 | /** | ||
308 | * write_unexport - Unexport a previously exported file system | ||
309 | * | ||
310 | * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred. | ||
311 | * Function remains to support old versions of nfs-utils. | ||
312 | * | ||
313 | * Input: | ||
314 | * buf: struct nfsctl_export | ||
315 | * ex_client: '\0'-terminated C string | ||
316 | * containing domain name | ||
317 | * of client no longer allowed | ||
318 | * to access this export | ||
319 | * ex_path: '\0'-terminated C string | ||
320 | * containing pathname of | ||
321 | * directory in local file system | ||
322 | * ex_dev: ignored | ||
323 | * ex_ino: ignored | ||
324 | * ex_flags: ignored | ||
325 | * ex_anon_uid: ignored | ||
326 | * ex_anon_gid: ignored | ||
327 | * size: size in bytes of passed in nfsctl_export | ||
328 | * Output: | ||
329 | * On success: returns zero | ||
330 | * On error: return code is negative errno value | ||
331 | */ | ||
219 | static ssize_t write_unexport(struct file *file, char *buf, size_t size) | 332 | static ssize_t write_unexport(struct file *file, char *buf, size_t size) |
220 | { | 333 | { |
221 | struct nfsctl_export *data; | 334 | struct nfsctl_export *data; |
@@ -226,6 +339,30 @@ static ssize_t write_unexport(struct file *file, char *buf, size_t size) | |||
226 | return exp_unexport(data); | 339 | return exp_unexport(data); |
227 | } | 340 | } |
228 | 341 | ||
342 | /** | ||
343 | * write_getfs - Get a variable-length NFS file handle by path | ||
344 | * | ||
345 | * Deprecated. /proc/fs/nfsd/filehandle is preferred. | ||
346 | * Function remains to support old versions of nfs-utils. | ||
347 | * | ||
348 | * Input: | ||
349 | * buf: struct nfsctl_fsparm | ||
350 | * gd_addr: socket address of client | ||
351 | * gd_path: '\0'-terminated C string | ||
352 | * containing pathname of | ||
353 | * directory in local file system | ||
354 | * gd_maxlen: maximum size of returned file | ||
355 | * handle | ||
356 | * size: size in bytes of passed in nfsctl_fsparm | ||
357 | * Output: | ||
358 | * On success: passed-in buffer filled with a knfsd_fh structure | ||
359 | * (a variable-length raw NFS file handle); | ||
360 | * return code is the size in bytes of the file handle | ||
361 | * On error: return code is negative errno value | ||
362 | * | ||
363 | * Note: Only AF_INET client addresses are passed in, since gd_addr | ||
364 | * is the same size as a struct sockaddr_in. | ||
365 | */ | ||
229 | static ssize_t write_getfs(struct file *file, char *buf, size_t size) | 366 | static ssize_t write_getfs(struct file *file, char *buf, size_t size) |
230 | { | 367 | { |
231 | struct nfsctl_fsparm *data; | 368 | struct nfsctl_fsparm *data; |
@@ -265,6 +402,29 @@ static ssize_t write_getfs(struct file *file, char *buf, size_t size) | |||
265 | return err; | 402 | return err; |
266 | } | 403 | } |
267 | 404 | ||
405 | /** | ||
406 | * write_getfd - Get a fixed-length NFS file handle by path (used by mountd) | ||
407 | * | ||
408 | * Deprecated. /proc/fs/nfsd/filehandle is preferred. | ||
409 | * Function remains to support old versions of nfs-utils. | ||
410 | * | ||
411 | * Input: | ||
412 | * buf: struct nfsctl_fdparm | ||
413 | * gd_addr: socket address of client | ||
414 | * gd_path: '\0'-terminated C string | ||
415 | * containing pathname of | ||
416 | * directory in local file system | ||
417 | * gd_version: fdparm structure version | ||
418 | * size: size in bytes of passed in nfsctl_fdparm | ||
419 | * Output: | ||
420 | * On success: passed-in buffer filled with nfsctl_res | ||
421 | * (a fixed-length raw NFS file handle); | ||
422 | * return code is the size in bytes of the file handle | ||
423 | * On error: return code is negative errno value | ||
424 | * | ||
425 | * Note: Only AF_INET client addresses are passed in, since gd_addr | ||
426 | * is the same size as a struct sockaddr_in. | ||
427 | */ | ||
268 | static ssize_t write_getfd(struct file *file, char *buf, size_t size) | 428 | static ssize_t write_getfd(struct file *file, char *buf, size_t size) |
269 | { | 429 | { |
270 | struct nfsctl_fdparm *data; | 430 | struct nfsctl_fdparm *data; |
@@ -309,7 +469,23 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size) | |||
309 | return err; | 469 | return err; |
310 | } | 470 | } |
311 | 471 | ||
312 | static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) | 472 | /** |
473 | * write_unlock_ip - Release all locks used by a client | ||
474 | * | ||
475 | * Experimental. | ||
476 | * | ||
477 | * Input: | ||
478 | * buf: '\n'-terminated C string containing a | ||
479 | * presentation format IPv4 address | ||
480 | * size: length of C string in @buf | ||
481 | * Output: | ||
482 | * On success: returns zero if all specified locks were released; | ||
483 | * returns one if one or more locks were not released | ||
484 | * On error: return code is negative errno value | ||
485 | * | ||
486 | * Note: Only AF_INET client addresses are passed in | ||
487 | */ | ||
488 | static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size) | ||
313 | { | 489 | { |
314 | struct sockaddr_in sin = { | 490 | struct sockaddr_in sin = { |
315 | .sin_family = AF_INET, | 491 | .sin_family = AF_INET, |
@@ -330,7 +506,7 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) | |||
330 | return -EINVAL; | 506 | return -EINVAL; |
331 | 507 | ||
332 | /* get ipv4 address */ | 508 | /* get ipv4 address */ |
333 | if (sscanf(fo_path, NIPQUAD_FMT "%c", &b1, &b2, &b3, &b4, &c) != 4) | 509 | if (sscanf(fo_path, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4) |
334 | return -EINVAL; | 510 | return -EINVAL; |
335 | if (b1 > 255 || b2 > 255 || b3 > 255 || b4 > 255) | 511 | if (b1 > 255 || b2 > 255 || b3 > 255 || b4 > 255) |
336 | return -EINVAL; | 512 | return -EINVAL; |
@@ -339,7 +515,21 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) | |||
339 | return nlmsvc_unlock_all_by_ip((struct sockaddr *)&sin); | 515 | return nlmsvc_unlock_all_by_ip((struct sockaddr *)&sin); |
340 | } | 516 | } |
341 | 517 | ||
342 | static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) | 518 | /** |
519 | * write_unlock_fs - Release all locks on a local file system | ||
520 | * | ||
521 | * Experimental. | ||
522 | * | ||
523 | * Input: | ||
524 | * buf: '\n'-terminated C string containing the | ||
525 | * absolute pathname of a local file system | ||
526 | * size: length of C string in @buf | ||
527 | * Output: | ||
528 | * On success: returns zero if all specified locks were released; | ||
529 | * returns one if one or more locks were not released | ||
530 | * On error: return code is negative errno value | ||
531 | */ | ||
532 | static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size) | ||
343 | { | 533 | { |
344 | struct path path; | 534 | struct path path; |
345 | char *fo_path; | 535 | char *fo_path; |
@@ -360,21 +550,44 @@ static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) | |||
360 | if (error) | 550 | if (error) |
361 | return error; | 551 | return error; |
362 | 552 | ||
553 | /* | ||
554 | * XXX: Needs better sanity checking. Otherwise we could end up | ||
555 | * releasing locks on the wrong file system. | ||
556 | * | ||
557 | * For example: | ||
558 | * 1. Does the path refer to a directory? | ||
559 | * 2. Is that directory a mount point, or | ||
560 | * 3. Is that directory the root of an exported file system? | ||
561 | */ | ||
363 | error = nlmsvc_unlock_all_by_sb(path.mnt->mnt_sb); | 562 | error = nlmsvc_unlock_all_by_sb(path.mnt->mnt_sb); |
364 | 563 | ||
365 | path_put(&path); | 564 | path_put(&path); |
366 | return error; | 565 | return error; |
367 | } | 566 | } |
368 | 567 | ||
568 | /** | ||
569 | * write_filehandle - Get a variable-length NFS file handle by path | ||
570 | * | ||
571 | * On input, the buffer contains a '\n'-terminated C string comprised of | ||
572 | * three alphanumeric words separated by whitespace. The string may | ||
573 | * contain escape sequences. | ||
574 | * | ||
575 | * Input: | ||
576 | * buf: | ||
577 | * domain: client domain name | ||
578 | * path: export pathname | ||
579 | * maxsize: numeric maximum size of | ||
580 | * @buf | ||
581 | * size: length of C string in @buf | ||
582 | * Output: | ||
583 | * On success: passed-in buffer filled with '\n'-terminated C | ||
584 | * string containing a ASCII hex text version | ||
585 | * of the NFS file handle; | ||
586 | * return code is the size in bytes of the string | ||
587 | * On error: return code is negative errno value | ||
588 | */ | ||
369 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size) | 589 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size) |
370 | { | 590 | { |
371 | /* request is: | ||
372 | * domain path maxsize | ||
373 | * response is | ||
374 | * filehandle | ||
375 | * | ||
376 | * qword quoting is used, so filehandle will be \x.... | ||
377 | */ | ||
378 | char *dname, *path; | 591 | char *dname, *path; |
379 | int uninitialized_var(maxsize); | 592 | int uninitialized_var(maxsize); |
380 | char *mesg = buf; | 593 | char *mesg = buf; |
@@ -391,11 +604,13 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size) | |||
391 | 604 | ||
392 | dname = mesg; | 605 | dname = mesg; |
393 | len = qword_get(&mesg, dname, size); | 606 | len = qword_get(&mesg, dname, size); |
394 | if (len <= 0) return -EINVAL; | 607 | if (len <= 0) |
608 | return -EINVAL; | ||
395 | 609 | ||
396 | path = dname+len+1; | 610 | path = dname+len+1; |
397 | len = qword_get(&mesg, path, size); | 611 | len = qword_get(&mesg, path, size); |
398 | if (len <= 0) return -EINVAL; | 612 | if (len <= 0) |
613 | return -EINVAL; | ||
399 | 614 | ||
400 | len = get_int(&mesg, &maxsize); | 615 | len = get_int(&mesg, &maxsize); |
401 | if (len) | 616 | if (len) |
@@ -419,17 +634,43 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size) | |||
419 | if (len) | 634 | if (len) |
420 | return len; | 635 | return len; |
421 | 636 | ||
422 | mesg = buf; len = SIMPLE_TRANSACTION_LIMIT; | 637 | mesg = buf; |
638 | len = SIMPLE_TRANSACTION_LIMIT; | ||
423 | qword_addhex(&mesg, &len, (char*)&fh.fh_base, fh.fh_size); | 639 | qword_addhex(&mesg, &len, (char*)&fh.fh_base, fh.fh_size); |
424 | mesg[-1] = '\n'; | 640 | mesg[-1] = '\n'; |
425 | return mesg - buf; | 641 | return mesg - buf; |
426 | } | 642 | } |
427 | 643 | ||
644 | /** | ||
645 | * write_threads - Start NFSD, or report the current number of running threads | ||
646 | * | ||
647 | * Input: | ||
648 | * buf: ignored | ||
649 | * size: zero | ||
650 | * Output: | ||
651 | * On success: passed-in buffer filled with '\n'-terminated C | ||
652 | * string numeric value representing the number of | ||
653 | * running NFSD threads; | ||
654 | * return code is the size in bytes of the string | ||
655 | * On error: return code is zero | ||
656 | * | ||
657 | * OR | ||
658 | * | ||
659 | * Input: | ||
660 | * buf: C string containing an unsigned | ||
661 | * integer value representing the | ||
662 | * number of NFSD threads to start | ||
663 | * size: non-zero length of C string in @buf | ||
664 | * Output: | ||
665 | * On success: NFS service is started; | ||
666 | * passed-in buffer filled with '\n'-terminated C | ||
667 | * string numeric value representing the number of | ||
668 | * running NFSD threads; | ||
669 | * return code is the size in bytes of the string | ||
670 | * On error: return code is zero or a negative errno value | ||
671 | */ | ||
428 | static ssize_t write_threads(struct file *file, char *buf, size_t size) | 672 | static ssize_t write_threads(struct file *file, char *buf, size_t size) |
429 | { | 673 | { |
430 | /* if size > 0, look for a number of threads and call nfsd_svc | ||
431 | * then write out number of threads as reply | ||
432 | */ | ||
433 | char *mesg = buf; | 674 | char *mesg = buf; |
434 | int rv; | 675 | int rv; |
435 | if (size > 0) { | 676 | if (size > 0) { |
@@ -437,9 +678,9 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size) | |||
437 | rv = get_int(&mesg, &newthreads); | 678 | rv = get_int(&mesg, &newthreads); |
438 | if (rv) | 679 | if (rv) |
439 | return rv; | 680 | return rv; |
440 | if (newthreads <0) | 681 | if (newthreads < 0) |
441 | return -EINVAL; | 682 | return -EINVAL; |
442 | rv = nfsd_svc(2049, newthreads); | 683 | rv = nfsd_svc(NFS_PORT, newthreads); |
443 | if (rv) | 684 | if (rv) |
444 | return rv; | 685 | return rv; |
445 | } | 686 | } |
@@ -447,6 +688,28 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size) | |||
447 | return strlen(buf); | 688 | return strlen(buf); |
448 | } | 689 | } |
449 | 690 | ||
691 | /** | ||
692 | * write_pool_threads - Set or report the current number of threads per pool | ||
693 | * | ||
694 | * Input: | ||
695 | * buf: ignored | ||
696 | * size: zero | ||
697 | * | ||
698 | * OR | ||
699 | * | ||
700 | * Input: | ||
701 | * buf: C string containing whitespace- | ||
702 | * separated unsigned integer values | ||
703 | * representing the number of NFSD | ||
704 | * threads to start in each pool | ||
705 | * size: non-zero length of C string in @buf | ||
706 | * Output: | ||
707 | * On success: passed-in buffer filled with '\n'-terminated C | ||
708 | * string containing integer values representing the | ||
709 | * number of NFSD threads in each pool; | ||
710 | * return code is the size in bytes of the string | ||
711 | * On error: return code is zero or a negative errno value | ||
712 | */ | ||
450 | static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) | 713 | static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) |
451 | { | 714 | { |
452 | /* if size > 0, look for an array of number of threads per node | 715 | /* if size > 0, look for an array of number of threads per node |
@@ -517,10 +780,6 @@ out_free: | |||
517 | 780 | ||
518 | static ssize_t __write_versions(struct file *file, char *buf, size_t size) | 781 | static ssize_t __write_versions(struct file *file, char *buf, size_t size) |
519 | { | 782 | { |
520 | /* | ||
521 | * Format: | ||
522 | * [-/+]vers [-/+]vers ... | ||
523 | */ | ||
524 | char *mesg = buf; | 783 | char *mesg = buf; |
525 | char *vers, sign; | 784 | char *vers, sign; |
526 | int len, num; | 785 | int len, num; |
@@ -578,6 +837,38 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) | |||
578 | return len; | 837 | return len; |
579 | } | 838 | } |
580 | 839 | ||
840 | /** | ||
841 | * write_versions - Set or report the available NFS protocol versions | ||
842 | * | ||
843 | * Input: | ||
844 | * buf: ignored | ||
845 | * size: zero | ||
846 | * Output: | ||
847 | * On success: passed-in buffer filled with '\n'-terminated C | ||
848 | * string containing positive or negative integer | ||
849 | * values representing the current status of each | ||
850 | * protocol version; | ||
851 | * return code is the size in bytes of the string | ||
852 | * On error: return code is zero or a negative errno value | ||
853 | * | ||
854 | * OR | ||
855 | * | ||
856 | * Input: | ||
857 | * buf: C string containing whitespace- | ||
858 | * separated positive or negative | ||
859 | * integer values representing NFS | ||
860 | * protocol versions to enable ("+n") | ||
861 | * or disable ("-n") | ||
862 | * size: non-zero length of C string in @buf | ||
863 | * Output: | ||
864 | * On success: status of zero or more protocol versions has | ||
865 | * been updated; passed-in buffer filled with | ||
866 | * '\n'-terminated C string containing positive | ||
867 | * or negative integer values representing the | ||
868 | * current status of each protocol version; | ||
869 | * return code is the size in bytes of the string | ||
870 | * On error: return code is zero or a negative errno value | ||
871 | */ | ||
581 | static ssize_t write_versions(struct file *file, char *buf, size_t size) | 872 | static ssize_t write_versions(struct file *file, char *buf, size_t size) |
582 | { | 873 | { |
583 | ssize_t rv; | 874 | ssize_t rv; |
@@ -687,6 +978,75 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size) | |||
687 | return -EINVAL; | 978 | return -EINVAL; |
688 | } | 979 | } |
689 | 980 | ||
981 | /** | ||
982 | * write_ports - Pass a socket file descriptor or transport name to listen on | ||
983 | * | ||
984 | * Input: | ||
985 | * buf: ignored | ||
986 | * size: zero | ||
987 | * Output: | ||
988 | * On success: passed-in buffer filled with a '\n'-terminated C | ||
989 | * string containing a whitespace-separated list of | ||
990 | * named NFSD listeners; | ||
991 | * return code is the size in bytes of the string | ||
992 | * On error: return code is zero or a negative errno value | ||
993 | * | ||
994 | * OR | ||
995 | * | ||
996 | * Input: | ||
997 | * buf: C string containing an unsigned | ||
998 | * integer value representing a bound | ||
999 | * but unconnected socket that is to be | ||
1000 | * used as an NFSD listener | ||
1001 | * size: non-zero length of C string in @buf | ||
1002 | * Output: | ||
1003 | * On success: NFS service is started; | ||
1004 | * passed-in buffer filled with a '\n'-terminated C | ||
1005 | * string containing a unique alphanumeric name of | ||
1006 | * the listener; | ||
1007 | * return code is the size in bytes of the string | ||
1008 | * On error: return code is a negative errno value | ||
1009 | * | ||
1010 | * OR | ||
1011 | * | ||
1012 | * Input: | ||
1013 | * buf: C string containing a "-" followed | ||
1014 | * by an integer value representing a | ||
1015 | * previously passed in socket file | ||
1016 | * descriptor | ||
1017 | * size: non-zero length of C string in @buf | ||
1018 | * Output: | ||
1019 | * On success: NFS service no longer listens on that socket; | ||
1020 | * passed-in buffer filled with a '\n'-terminated C | ||
1021 | * string containing a unique name of the listener; | ||
1022 | * return code is the size in bytes of the string | ||
1023 | * On error: return code is a negative errno value | ||
1024 | * | ||
1025 | * OR | ||
1026 | * | ||
1027 | * Input: | ||
1028 | * buf: C string containing a transport | ||
1029 | * name and an unsigned integer value | ||
1030 | * representing the port to listen on, | ||
1031 | * separated by whitespace | ||
1032 | * size: non-zero length of C string in @buf | ||
1033 | * Output: | ||
1034 | * On success: returns zero; NFS service is started | ||
1035 | * On error: return code is a negative errno value | ||
1036 | * | ||
1037 | * OR | ||
1038 | * | ||
1039 | * Input: | ||
1040 | * buf: C string containing a "-" followed | ||
1041 | * by a transport name and an unsigned | ||
1042 | * integer value representing the port | ||
1043 | * to listen on, separated by whitespace | ||
1044 | * size: non-zero length of C string in @buf | ||
1045 | * Output: | ||
1046 | * On success: returns zero; NFS service no longer listens | ||
1047 | * on that transport | ||
1048 | * On error: return code is a negative errno value | ||
1049 | */ | ||
690 | static ssize_t write_ports(struct file *file, char *buf, size_t size) | 1050 | static ssize_t write_ports(struct file *file, char *buf, size_t size) |
691 | { | 1051 | { |
692 | ssize_t rv; | 1052 | ssize_t rv; |
@@ -700,6 +1060,27 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) | |||
700 | 1060 | ||
701 | int nfsd_max_blksize; | 1061 | int nfsd_max_blksize; |
702 | 1062 | ||
1063 | /** | ||
1064 | * write_maxblksize - Set or report the current NFS blksize | ||
1065 | * | ||
1066 | * Input: | ||
1067 | * buf: ignored | ||
1068 | * size: zero | ||
1069 | * | ||
1070 | * OR | ||
1071 | * | ||
1072 | * Input: | ||
1073 | * buf: C string containing an unsigned | ||
1074 | * integer value representing the new | ||
1075 | * NFS blksize | ||
1076 | * size: non-zero length of C string in @buf | ||
1077 | * Output: | ||
1078 | * On success: passed-in buffer filled with '\n'-terminated C string | ||
1079 | * containing numeric value of the current NFS blksize | ||
1080 | * setting; | ||
1081 | * return code is the size in bytes of the string | ||
1082 | * On error: return code is zero or a negative errno value | ||
1083 | */ | ||
703 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) | 1084 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) |
704 | { | 1085 | { |
705 | char *mesg = buf; | 1086 | char *mesg = buf; |
@@ -752,6 +1133,27 @@ static ssize_t __write_leasetime(struct file *file, char *buf, size_t size) | |||
752 | return strlen(buf); | 1133 | return strlen(buf); |
753 | } | 1134 | } |
754 | 1135 | ||
1136 | /** | ||
1137 | * write_leasetime - Set or report the current NFSv4 lease time | ||
1138 | * | ||
1139 | * Input: | ||
1140 | * buf: ignored | ||
1141 | * size: zero | ||
1142 | * | ||
1143 | * OR | ||
1144 | * | ||
1145 | * Input: | ||
1146 | * buf: C string containing an unsigned | ||
1147 | * integer value representing the new | ||
1148 | * NFSv4 lease expiry time | ||
1149 | * size: non-zero length of C string in @buf | ||
1150 | * Output: | ||
1151 | * On success: passed-in buffer filled with '\n'-terminated C | ||
1152 | * string containing unsigned integer value of the | ||
1153 | * current lease expiry time; | ||
1154 | * return code is the size in bytes of the string | ||
1155 | * On error: return code is zero or a negative errno value | ||
1156 | */ | ||
755 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) | 1157 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) |
756 | { | 1158 | { |
757 | ssize_t rv; | 1159 | ssize_t rv; |
@@ -788,6 +1190,27 @@ static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size) | |||
788 | return strlen(buf); | 1190 | return strlen(buf); |
789 | } | 1191 | } |
790 | 1192 | ||
1193 | /** | ||
1194 | * write_recoverydir - Set or report the pathname of the recovery directory | ||
1195 | * | ||
1196 | * Input: | ||
1197 | * buf: ignored | ||
1198 | * size: zero | ||
1199 | * | ||
1200 | * OR | ||
1201 | * | ||
1202 | * Input: | ||
1203 | * buf: C string containing the pathname | ||
1204 | * of the directory on a local file | ||
1205 | * system containing permanent NFSv4 | ||
1206 | * recovery data | ||
1207 | * size: non-zero length of C string in @buf | ||
1208 | * Output: | ||
1209 | * On success: passed-in buffer filled with '\n'-terminated C string | ||
1210 | * containing the current recovery pathname setting; | ||
1211 | * return code is the size in bytes of the string | ||
1212 | * On error: return code is zero or a negative errno value | ||
1213 | */ | ||
791 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) | 1214 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) |
792 | { | 1215 | { |
793 | ssize_t rv; | 1216 | ssize_t rv; |