2 * Syscall interface to knfsd.
4 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 #include <linux/slab.h>
8 #include <linux/namei.h>
9 #include <linux/ctype.h>
11 #include <linux/sunrpc/svcsock.h>
12 #include <linux/lockd/lockd.h>
13 #include <linux/sunrpc/clnt.h>
14 #include <linux/sunrpc/gss_api.h>
15 #include <linux/sunrpc/gss_krb5_enctypes.h>
16 #include <linux/module.h>
21 #include "fault_inject.h"
24 * We have a single directory with several nodes in it.
39 NFSD_SupportedEnctypes
,
41 * The below MUST come last. Otherwise we leave a hole in nfsd_files[]
42 * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops
52 * write() for these nodes.
54 static ssize_t
write_filehandle(struct file
*file
, char *buf
, size_t size
);
55 static ssize_t
write_unlock_ip(struct file
*file
, char *buf
, size_t size
);
56 static ssize_t
write_unlock_fs(struct file
*file
, char *buf
, size_t size
);
57 static ssize_t
write_threads(struct file
*file
, char *buf
, size_t size
);
58 static ssize_t
write_pool_threads(struct file
*file
, char *buf
, size_t size
);
59 static ssize_t
write_versions(struct file
*file
, char *buf
, size_t size
);
60 static ssize_t
write_ports(struct file
*file
, char *buf
, size_t size
);
61 static ssize_t
write_maxblksize(struct file
*file
, char *buf
, size_t size
);
63 static ssize_t
write_leasetime(struct file
*file
, char *buf
, size_t size
);
64 static ssize_t
write_gracetime(struct file
*file
, char *buf
, size_t size
);
65 static ssize_t
write_recoverydir(struct file
*file
, char *buf
, size_t size
);
68 static ssize_t (*write_op
[])(struct file
*, char *, size_t) = {
69 [NFSD_Fh
] = write_filehandle
,
70 [NFSD_FO_UnlockIP
] = write_unlock_ip
,
71 [NFSD_FO_UnlockFS
] = write_unlock_fs
,
72 [NFSD_Threads
] = write_threads
,
73 [NFSD_Pool_Threads
] = write_pool_threads
,
74 [NFSD_Versions
] = write_versions
,
75 [NFSD_Ports
] = write_ports
,
76 [NFSD_MaxBlkSize
] = write_maxblksize
,
78 [NFSD_Leasetime
] = write_leasetime
,
79 [NFSD_Gracetime
] = write_gracetime
,
80 [NFSD_RecoveryDir
] = write_recoverydir
,
84 static ssize_t
nfsctl_transaction_write(struct file
*file
, const char __user
*buf
, size_t size
, loff_t
*pos
)
86 ino_t ino
= file
->f_path
.dentry
->d_inode
->i_ino
;
90 if (ino
>= ARRAY_SIZE(write_op
) || !write_op
[ino
])
93 data
= simple_transaction_get(file
, buf
, size
);
97 rv
= write_op
[ino
](file
, data
, size
);
99 simple_transaction_set(file
, rv
);
105 static ssize_t
nfsctl_transaction_read(struct file
*file
, char __user
*buf
, size_t size
, loff_t
*pos
)
107 if (! file
->private_data
) {
108 /* An attempt to read a transaction file without writing
109 * causes a 0-byte write so that the file can return
112 ssize_t rv
= nfsctl_transaction_write(file
, buf
, 0, pos
);
116 return simple_transaction_read(file
, buf
, size
, pos
);
119 static const struct file_operations transaction_ops
= {
120 .write
= nfsctl_transaction_write
,
121 .read
= nfsctl_transaction_read
,
122 .release
= simple_transaction_release
,
123 .llseek
= default_llseek
,
126 static int exports_open(struct inode
*inode
, struct file
*file
)
128 return seq_open(file
, &nfs_exports_op
);
131 static const struct file_operations exports_operations
= {
132 .open
= exports_open
,
135 .release
= seq_release
,
136 .owner
= THIS_MODULE
,
139 static int export_features_show(struct seq_file
*m
, void *v
)
141 seq_printf(m
, "0x%x 0x%x\n", NFSEXP_ALLFLAGS
, NFSEXP_SECINFO_FLAGS
);
145 static int export_features_open(struct inode
*inode
, struct file
*file
)
147 return single_open(file
, export_features_show
, NULL
);
150 static struct file_operations export_features_operations
= {
151 .open
= export_features_open
,
154 .release
= single_release
,
157 #if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE)
158 static int supported_enctypes_show(struct seq_file
*m
, void *v
)
160 seq_printf(m
, KRB5_SUPPORTED_ENCTYPES
);
164 static int supported_enctypes_open(struct inode
*inode
, struct file
*file
)
166 return single_open(file
, supported_enctypes_show
, NULL
);
169 static struct file_operations supported_enctypes_ops
= {
170 .open
= supported_enctypes_open
,
173 .release
= single_release
,
175 #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */
177 extern int nfsd_pool_stats_open(struct inode
*inode
, struct file
*file
);
178 extern int nfsd_pool_stats_release(struct inode
*inode
, struct file
*file
);
180 static const struct file_operations pool_stats_operations
= {
181 .open
= nfsd_pool_stats_open
,
184 .release
= nfsd_pool_stats_release
,
185 .owner
= THIS_MODULE
,
188 /*----------------------------------------------------------------------------*/
190 * payload - write methods
195 * write_unlock_ip - Release all locks used by a client
200 * buf: '\n'-terminated C string containing a
201 * presentation format IP address
202 * size: length of C string in @buf
204 * On success: returns zero if all specified locks were released;
205 * returns one if one or more locks were not released
206 * On error: return code is negative errno value
208 static ssize_t
write_unlock_ip(struct file
*file
, char *buf
, size_t size
)
210 struct sockaddr_storage address
;
211 struct sockaddr
*sap
= (struct sockaddr
*)&address
;
212 size_t salen
= sizeof(address
);
219 if (buf
[size
-1] != '\n')
223 if (qword_get(&buf
, fo_path
, size
) < 0)
226 if (rpc_pton(fo_path
, size
, sap
, salen
) == 0)
229 return nlmsvc_unlock_all_by_ip(sap
);
233 * write_unlock_fs - Release all locks on a local file system
238 * buf: '\n'-terminated C string containing the
239 * absolute pathname of a local file system
240 * size: length of C string in @buf
242 * On success: returns zero if all specified locks were released;
243 * returns one if one or more locks were not released
244 * On error: return code is negative errno value
246 static ssize_t
write_unlock_fs(struct file
*file
, char *buf
, size_t size
)
256 if (buf
[size
-1] != '\n')
260 if (qword_get(&buf
, fo_path
, size
) < 0)
263 error
= kern_path(fo_path
, 0, &path
);
268 * XXX: Needs better sanity checking. Otherwise we could end up
269 * releasing locks on the wrong file system.
272 * 1. Does the path refer to a directory?
273 * 2. Is that directory a mount point, or
274 * 3. Is that directory the root of an exported file system?
276 error
= nlmsvc_unlock_all_by_sb(path
.dentry
->d_sb
);
283 * write_filehandle - Get a variable-length NFS file handle by path
285 * On input, the buffer contains a '\n'-terminated C string comprised of
286 * three alphanumeric words separated by whitespace. The string may
287 * contain escape sequences.
291 * domain: client domain name
292 * path: export pathname
293 * maxsize: numeric maximum size of
295 * size: length of C string in @buf
297 * On success: passed-in buffer filled with '\n'-terminated C
298 * string containing a ASCII hex text version
299 * of the NFS file handle;
300 * return code is the size in bytes of the string
301 * On error: return code is negative errno value
303 static ssize_t
write_filehandle(struct file
*file
, char *buf
, size_t size
)
306 int uninitialized_var(maxsize
);
309 struct auth_domain
*dom
;
315 if (buf
[size
-1] != '\n')
320 len
= qword_get(&mesg
, dname
, size
);
325 len
= qword_get(&mesg
, path
, size
);
329 len
= get_int(&mesg
, &maxsize
);
333 if (maxsize
< NFS_FHSIZE
)
335 if (maxsize
> NFS3_FHSIZE
)
336 maxsize
= NFS3_FHSIZE
;
338 if (qword_get(&mesg
, mesg
, size
)>0)
341 /* we have all the words, they are in buf.. */
342 dom
= unix_domain_find(dname
);
346 len
= exp_rootfh(dom
, path
, &fh
, maxsize
);
347 auth_domain_put(dom
);
352 len
= SIMPLE_TRANSACTION_LIMIT
;
353 qword_addhex(&mesg
, &len
, (char*)&fh
.fh_base
, fh
.fh_size
);
359 * write_threads - Start NFSD, or report the current number of running threads
365 * On success: passed-in buffer filled with '\n'-terminated C
366 * string numeric value representing the number of
367 * running NFSD threads;
368 * return code is the size in bytes of the string
369 * On error: return code is zero
374 * buf: C string containing an unsigned
375 * integer value representing the
376 * number of NFSD threads to start
377 * size: non-zero length of C string in @buf
379 * On success: NFS service is started;
380 * passed-in buffer filled with '\n'-terminated C
381 * string numeric value representing the number of
382 * running NFSD threads;
383 * return code is the size in bytes of the string
384 * On error: return code is zero or a negative errno value
386 static ssize_t
write_threads(struct file
*file
, char *buf
, size_t size
)
392 rv
= get_int(&mesg
, &newthreads
);
397 rv
= nfsd_svc(NFS_PORT
, newthreads
);
401 rv
= nfsd_nrthreads();
403 return scnprintf(buf
, SIMPLE_TRANSACTION_LIMIT
, "%d\n", rv
);
407 * write_pool_threads - Set or report the current number of threads per pool
416 * buf: C string containing whitespace-
417 * separated unsigned integer values
418 * representing the number of NFSD
419 * threads to start in each pool
420 * size: non-zero length of C string in @buf
422 * On success: passed-in buffer filled with '\n'-terminated C
423 * string containing integer values representing the
424 * number of NFSD threads in each pool;
425 * return code is the size in bytes of the string
426 * On error: return code is zero or a negative errno value
428 static ssize_t
write_pool_threads(struct file
*file
, char *buf
, size_t size
)
430 /* if size > 0, look for an array of number of threads per node
431 * and apply them then write out number of threads per node as reply
440 mutex_lock(&nfsd_mutex
);
441 npools
= nfsd_nrpools();
444 * NFS is shut down. The admin can start it by
445 * writing to the threads file but NOT the pool_threads
446 * file, sorry. Report zero threads.
448 mutex_unlock(&nfsd_mutex
);
453 nthreads
= kcalloc(npools
, sizeof(int), GFP_KERNEL
);
455 if (nthreads
== NULL
)
459 for (i
= 0; i
< npools
; i
++) {
460 rv
= get_int(&mesg
, &nthreads
[i
]);
462 break; /* fewer numbers than pools */
464 goto out_free
; /* syntax error */
469 rv
= nfsd_set_nrthreads(i
, nthreads
);
474 rv
= nfsd_get_nrthreads(npools
, nthreads
);
479 size
= SIMPLE_TRANSACTION_LIMIT
;
480 for (i
= 0; i
< npools
&& size
> 0; i
++) {
481 snprintf(mesg
, size
, "%d%c", nthreads
[i
], (i
== npools
-1 ? '\n' : ' '));
489 mutex_unlock(&nfsd_mutex
);
493 static ssize_t
__write_versions(struct file
*file
, char *buf
, size_t size
)
496 char *vers
, *minorp
, sign
;
497 int len
, num
, remaining
;
504 /* Cannot change versions without updating
505 * nfsd_serv->sv_xdrsize, and reallocing
506 * rq_argp and rq_resp
509 if (buf
[size
-1] != '\n')
514 len
= qword_get(&mesg
, vers
, size
);
515 if (len
<= 0) return -EINVAL
;
518 if (sign
== '+' || sign
== '-')
519 num
= simple_strtol((vers
+1), &minorp
, 0);
521 num
= simple_strtol(vers
, &minorp
, 0);
522 if (*minorp
== '.') {
525 minor
= simple_strtoul(minorp
+1, NULL
, 0);
528 if (nfsd_minorversion(minor
, sign
== '-' ?
529 NFSD_CLEAR
: NFSD_SET
) < 0)
537 nfsd_vers(num
, sign
== '-' ? NFSD_CLEAR
: NFSD_SET
);
544 } while ((len
= qword_get(&mesg
, vers
, size
)) > 0);
545 /* If all get turned off, turn them back on, as
546 * having no versions is BAD
548 nfsd_reset_versions();
551 /* Now write current state into reply buffer */
554 remaining
= SIMPLE_TRANSACTION_LIMIT
;
555 for (num
=2 ; num
<= 4 ; num
++)
556 if (nfsd_vers(num
, NFSD_AVAIL
)) {
557 len
= snprintf(buf
, remaining
, "%s%c%d", sep
,
558 nfsd_vers(num
, NFSD_TEST
)?'+':'-',
568 if (nfsd_vers(4, NFSD_AVAIL
))
569 for (minor
= 1; minor
<= NFSD_SUPPORTED_MINOR_VERSION
;
571 len
= snprintf(buf
, remaining
, " %c4.%u",
572 (nfsd_vers(4, NFSD_TEST
) &&
573 nfsd_minorversion(minor
, NFSD_TEST
)) ?
584 len
= snprintf(buf
, remaining
, "\n");
591 * write_versions - Set or report the available NFS protocol versions
597 * On success: passed-in buffer filled with '\n'-terminated C
598 * string containing positive or negative integer
599 * values representing the current status of each
601 * return code is the size in bytes of the string
602 * On error: return code is zero or a negative errno value
607 * buf: C string containing whitespace-
608 * separated positive or negative
609 * integer values representing NFS
610 * protocol versions to enable ("+n")
612 * size: non-zero length of C string in @buf
614 * On success: status of zero or more protocol versions has
615 * been updated; passed-in buffer filled with
616 * '\n'-terminated C string containing positive
617 * or negative integer values representing the
618 * current status of each protocol version;
619 * return code is the size in bytes of the string
620 * On error: return code is zero or a negative errno value
622 static ssize_t
write_versions(struct file
*file
, char *buf
, size_t size
)
626 mutex_lock(&nfsd_mutex
);
627 rv
= __write_versions(file
, buf
, size
);
628 mutex_unlock(&nfsd_mutex
);
633 * Zero-length write. Return a list of NFSD's current listener
636 static ssize_t
__write_ports_names(char *buf
)
638 if (nfsd_serv
== NULL
)
640 return svc_xprt_names(nfsd_serv
, buf
, SIMPLE_TRANSACTION_LIMIT
);
644 * A single 'fd' number was written, in which case it must be for
645 * a socket of a supported family/protocol, and we use it as an
648 static ssize_t
__write_ports_addfd(char *buf
)
653 err
= get_int(&mesg
, &fd
);
654 if (err
!= 0 || fd
< 0)
657 err
= nfsd_create_serv();
661 err
= svc_addsock(nfsd_serv
, fd
, buf
, SIMPLE_TRANSACTION_LIMIT
);
663 svc_destroy(nfsd_serv
);
667 /* Decrease the count, but don't shut down the service */
668 nfsd_serv
->sv_nrthreads
--;
673 * A '-' followed by the 'name' of a socket means we close the socket.
675 static ssize_t
__write_ports_delfd(char *buf
)
680 toclose
= kstrdup(buf
+ 1, GFP_KERNEL
);
684 if (nfsd_serv
!= NULL
)
685 len
= svc_sock_names(nfsd_serv
, buf
,
686 SIMPLE_TRANSACTION_LIMIT
, toclose
);
692 * A transport listener is added by writing it's transport name and
695 static ssize_t
__write_ports_addxprt(char *buf
)
698 struct svc_xprt
*xprt
;
701 if (sscanf(buf
, "%15s %4u", transport
, &port
) != 2)
704 if (port
< 1 || port
> USHRT_MAX
)
707 err
= nfsd_create_serv();
711 err
= svc_create_xprt(nfsd_serv
, transport
, &init_net
,
712 PF_INET
, port
, SVC_SOCK_ANONYMOUS
);
716 err
= svc_create_xprt(nfsd_serv
, transport
, &init_net
,
717 PF_INET6
, port
, SVC_SOCK_ANONYMOUS
);
718 if (err
< 0 && err
!= -EAFNOSUPPORT
)
721 /* Decrease the count, but don't shut down the service */
722 nfsd_serv
->sv_nrthreads
--;
725 xprt
= svc_find_xprt(nfsd_serv
, transport
, PF_INET
, port
);
727 svc_close_xprt(xprt
);
731 svc_destroy(nfsd_serv
);
736 * A transport listener is removed by writing a "-", it's transport
737 * name, and it's port number.
739 static ssize_t
__write_ports_delxprt(char *buf
)
741 struct svc_xprt
*xprt
;
745 if (sscanf(&buf
[1], "%15s %4u", transport
, &port
) != 2)
748 if (port
< 1 || port
> USHRT_MAX
|| nfsd_serv
== NULL
)
751 xprt
= svc_find_xprt(nfsd_serv
, transport
, AF_UNSPEC
, port
);
755 svc_close_xprt(xprt
);
760 static ssize_t
__write_ports(struct file
*file
, char *buf
, size_t size
)
763 return __write_ports_names(buf
);
766 return __write_ports_addfd(buf
);
768 if (buf
[0] == '-' && isdigit(buf
[1]))
769 return __write_ports_delfd(buf
);
772 return __write_ports_addxprt(buf
);
774 if (buf
[0] == '-' && isalpha(buf
[1]))
775 return __write_ports_delxprt(buf
);
781 * write_ports - Pass a socket file descriptor or transport name to listen on
787 * On success: passed-in buffer filled with a '\n'-terminated C
788 * string containing a whitespace-separated list of
789 * named NFSD listeners;
790 * return code is the size in bytes of the string
791 * On error: return code is zero or a negative errno value
796 * buf: C string containing an unsigned
797 * integer value representing a bound
798 * but unconnected socket that is to be
799 * used as an NFSD listener; listen(3)
800 * must be called for a SOCK_STREAM
801 * socket, otherwise it is ignored
802 * size: non-zero length of C string in @buf
804 * On success: NFS service is started;
805 * passed-in buffer filled with a '\n'-terminated C
806 * string containing a unique alphanumeric name of
808 * return code is the size in bytes of the string
809 * On error: return code is a negative errno value
814 * buf: C string containing a "-" followed
815 * by an integer value representing a
816 * previously passed in socket file
818 * size: non-zero length of C string in @buf
820 * On success: NFS service no longer listens on that socket;
821 * passed-in buffer filled with a '\n'-terminated C
822 * string containing a unique name of the listener;
823 * return code is the size in bytes of the string
824 * On error: return code is a negative errno value
829 * buf: C string containing a transport
830 * name and an unsigned integer value
831 * representing the port to listen on,
832 * separated by whitespace
833 * size: non-zero length of C string in @buf
835 * On success: returns zero; NFS service is started
836 * On error: return code is a negative errno value
841 * buf: C string containing a "-" followed
842 * by a transport name and an unsigned
843 * integer value representing the port
844 * to listen on, separated by whitespace
845 * size: non-zero length of C string in @buf
847 * On success: returns zero; NFS service no longer listens
849 * On error: return code is a negative errno value
851 static ssize_t
write_ports(struct file
*file
, char *buf
, size_t size
)
855 mutex_lock(&nfsd_mutex
);
856 rv
= __write_ports(file
, buf
, size
);
857 mutex_unlock(&nfsd_mutex
);
862 int nfsd_max_blksize
;
865 * write_maxblksize - Set or report the current NFS blksize
874 * buf: C string containing an unsigned
875 * integer value representing the new
877 * size: non-zero length of C string in @buf
879 * On success: passed-in buffer filled with '\n'-terminated C string
880 * containing numeric value of the current NFS blksize
882 * return code is the size in bytes of the string
883 * On error: return code is zero or a negative errno value
885 static ssize_t
write_maxblksize(struct file
*file
, char *buf
, size_t size
)
890 int rv
= get_int(&mesg
, &bsize
);
893 /* force bsize into allowed range and
894 * required alignment.
898 if (bsize
> NFSSVC_MAXBLKSIZE
)
899 bsize
= NFSSVC_MAXBLKSIZE
;
901 mutex_lock(&nfsd_mutex
);
903 mutex_unlock(&nfsd_mutex
);
906 nfsd_max_blksize
= bsize
;
907 mutex_unlock(&nfsd_mutex
);
910 return scnprintf(buf
, SIMPLE_TRANSACTION_LIMIT
, "%d\n",
914 #ifdef CONFIG_NFSD_V4
915 static ssize_t
__nfsd4_write_time(struct file
*file
, char *buf
, size_t size
, time_t *time
)
923 rv
= get_int(&mesg
, &i
);
927 * Some sanity checking. We don't have a reason for
928 * these particular numbers, but problems with the
930 * - Too short: the briefest network outage may
931 * cause clients to lose all their locks. Also,
932 * the frequent polling may be wasteful.
933 * - Too long: do you really want reboot recovery
934 * to take more than an hour? Or to make other
935 * clients wait an hour before being able to
936 * revoke a dead client's locks?
938 if (i
< 10 || i
> 3600)
943 return scnprintf(buf
, SIMPLE_TRANSACTION_LIMIT
, "%ld\n", *time
);
946 static ssize_t
nfsd4_write_time(struct file
*file
, char *buf
, size_t size
, time_t *time
)
950 mutex_lock(&nfsd_mutex
);
951 rv
= __nfsd4_write_time(file
, buf
, size
, time
);
952 mutex_unlock(&nfsd_mutex
);
957 * write_leasetime - Set or report the current NFSv4 lease time
966 * buf: C string containing an unsigned
967 * integer value representing the new
968 * NFSv4 lease expiry time
969 * size: non-zero length of C string in @buf
971 * On success: passed-in buffer filled with '\n'-terminated C
972 * string containing unsigned integer value of the
973 * current lease expiry time;
974 * return code is the size in bytes of the string
975 * On error: return code is zero or a negative errno value
977 static ssize_t
write_leasetime(struct file
*file
, char *buf
, size_t size
)
979 return nfsd4_write_time(file
, buf
, size
, &nfsd4_lease
);
983 * write_gracetime - Set or report current NFSv4 grace period time
985 * As above, but sets the time of the NFSv4 grace period.
987 * Note this should never be set to less than the *previous*
988 * lease-period time, but we don't try to enforce this. (In the common
989 * case (a new boot), we don't know what the previous lease time was
992 static ssize_t
write_gracetime(struct file
*file
, char *buf
, size_t size
)
994 return nfsd4_write_time(file
, buf
, size
, &nfsd4_grace
);
997 extern char *nfs4_recoverydir(void);
999 static ssize_t
__write_recoverydir(struct file
*file
, char *buf
, size_t size
)
1008 if (size
> PATH_MAX
|| buf
[size
-1] != '\n')
1013 len
= qword_get(&mesg
, recdir
, size
);
1017 status
= nfs4_reset_recoverydir(recdir
);
1022 return scnprintf(buf
, SIMPLE_TRANSACTION_LIMIT
, "%s\n",
1023 nfs4_recoverydir());
1027 * write_recoverydir - Set or report the pathname of the recovery directory
1036 * buf: C string containing the pathname
1037 * of the directory on a local file
1038 * system containing permanent NFSv4
1040 * size: non-zero length of C string in @buf
1042 * On success: passed-in buffer filled with '\n'-terminated C string
1043 * containing the current recovery pathname setting;
1044 * return code is the size in bytes of the string
1045 * On error: return code is zero or a negative errno value
1047 static ssize_t
write_recoverydir(struct file
*file
, char *buf
, size_t size
)
1051 mutex_lock(&nfsd_mutex
);
1052 rv
= __write_recoverydir(file
, buf
, size
);
1053 mutex_unlock(&nfsd_mutex
);
1059 /*----------------------------------------------------------------------------*/
1061 * populating the filesystem.
1064 static int nfsd_fill_super(struct super_block
* sb
, void * data
, int silent
)
1066 static struct tree_descr nfsd_files
[] = {
1067 [NFSD_List
] = {"exports", &exports_operations
, S_IRUGO
},
1068 [NFSD_Export_features
] = {"export_features",
1069 &export_features_operations
, S_IRUGO
},
1070 [NFSD_FO_UnlockIP
] = {"unlock_ip",
1071 &transaction_ops
, S_IWUSR
|S_IRUSR
},
1072 [NFSD_FO_UnlockFS
] = {"unlock_filesystem",
1073 &transaction_ops
, S_IWUSR
|S_IRUSR
},
1074 [NFSD_Fh
] = {"filehandle", &transaction_ops
, S_IWUSR
|S_IRUSR
},
1075 [NFSD_Threads
] = {"threads", &transaction_ops
, S_IWUSR
|S_IRUSR
},
1076 [NFSD_Pool_Threads
] = {"pool_threads", &transaction_ops
, S_IWUSR
|S_IRUSR
},
1077 [NFSD_Pool_Stats
] = {"pool_stats", &pool_stats_operations
, S_IRUGO
},
1078 [NFSD_Versions
] = {"versions", &transaction_ops
, S_IWUSR
|S_IRUSR
},
1079 [NFSD_Ports
] = {"portlist", &transaction_ops
, S_IWUSR
|S_IRUGO
},
1080 [NFSD_MaxBlkSize
] = {"max_block_size", &transaction_ops
, S_IWUSR
|S_IRUGO
},
1081 #if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE)
1082 [NFSD_SupportedEnctypes
] = {"supported_krb5_enctypes", &supported_enctypes_ops
, S_IRUGO
},
1083 #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */
1084 #ifdef CONFIG_NFSD_V4
1085 [NFSD_Leasetime
] = {"nfsv4leasetime", &transaction_ops
, S_IWUSR
|S_IRUSR
},
1086 [NFSD_Gracetime
] = {"nfsv4gracetime", &transaction_ops
, S_IWUSR
|S_IRUSR
},
1087 [NFSD_RecoveryDir
] = {"nfsv4recoverydir", &transaction_ops
, S_IWUSR
|S_IRUSR
},
1091 return simple_fill_super(sb
, 0x6e667364, nfsd_files
);
1094 static struct dentry
*nfsd_mount(struct file_system_type
*fs_type
,
1095 int flags
, const char *dev_name
, void *data
)
1097 return mount_single(fs_type
, flags
, data
, nfsd_fill_super
);
1100 static struct file_system_type nfsd_fs_type
= {
1101 .owner
= THIS_MODULE
,
1103 .mount
= nfsd_mount
,
1104 .kill_sb
= kill_litter_super
,
1107 #ifdef CONFIG_PROC_FS
1108 static int create_proc_exports_entry(void)
1110 struct proc_dir_entry
*entry
;
1112 entry
= proc_mkdir("fs/nfs", NULL
);
1115 entry
= proc_create("exports", 0, entry
, &exports_operations
);
1120 #else /* CONFIG_PROC_FS */
1121 static int create_proc_exports_entry(void)
1127 static int __init
init_nfsd(void)
1130 printk(KERN_INFO
"Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
1132 retval
= nfsd4_init_slabs();
1136 retval
= nfsd_fault_inject_init(); /* nfsd fault injection controls */
1138 goto out_free_slabs
;
1139 nfsd_stat_init(); /* Statistics */
1140 retval
= nfsd_reply_cache_init();
1143 retval
= nfsd_export_init();
1145 goto out_free_cache
;
1146 nfsd_lockd_init(); /* lockd->nfsd callbacks */
1147 retval
= nfsd_idmap_init();
1149 goto out_free_lockd
;
1150 retval
= create_proc_exports_entry();
1152 goto out_free_idmap
;
1153 retval
= register_filesystem(&nfsd_fs_type
);
1158 remove_proc_entry("fs/nfs/exports", NULL
);
1159 remove_proc_entry("fs/nfs", NULL
);
1161 nfsd_idmap_shutdown();
1163 nfsd_lockd_shutdown();
1164 nfsd_export_shutdown();
1166 nfsd_reply_cache_shutdown();
1168 nfsd_stat_shutdown();
1169 nfsd_fault_inject_cleanup();
1175 static void __exit
exit_nfsd(void)
1177 nfsd_export_shutdown();
1178 nfsd_reply_cache_shutdown();
1179 remove_proc_entry("fs/nfs/exports", NULL
);
1180 remove_proc_entry("fs/nfs", NULL
);
1181 nfsd_stat_shutdown();
1182 nfsd_lockd_shutdown();
1183 nfsd_idmap_shutdown();
1185 nfsd_fault_inject_cleanup();
1186 unregister_filesystem(&nfsd_fs_type
);
1189 MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
1190 MODULE_LICENSE("GPL");
1191 module_init(init_nfsd
)
1192 module_exit(exit_nfsd
)