nfsctl.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. /*
  2. * linux/fs/nfsd/nfsctl.c
  3. *
  4. * Syscall interface to knfsd.
  5. *
  6. * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  7. */
  8. #include <linux/module.h>
  9. #include <linux/linkage.h>
  10. #include <linux/time.h>
  11. #include <linux/errno.h>
  12. #include <linux/fs.h>
  13. #include <linux/fcntl.h>
  14. #include <linux/net.h>
  15. #include <linux/in.h>
  16. #include <linux/syscalls.h>
  17. #include <linux/unistd.h>
  18. #include <linux/slab.h>
  19. #include <linux/proc_fs.h>
  20. #include <linux/seq_file.h>
  21. #include <linux/pagemap.h>
  22. #include <linux/init.h>
  23. #include <linux/string.h>
  24. #include <linux/smp_lock.h>
  25. #include <linux/ctype.h>
  26. #include <linux/nfs.h>
  27. #include <linux/nfsd_idmap.h>
  28. #include <linux/lockd/bind.h>
  29. #include <linux/sunrpc/svc.h>
  30. #include <linux/sunrpc/svcsock.h>
  31. #include <linux/nfsd/nfsd.h>
  32. #include <linux/nfsd/cache.h>
  33. #include <linux/nfsd/xdr.h>
  34. #include <linux/nfsd/syscall.h>
  35. #include <linux/nfsd/interface.h>
  36. #include <asm/uaccess.h>
  37. /*
  38. * We have a single directory with 9 nodes in it.
  39. */
  40. enum {
  41. NFSD_Root = 1,
  42. NFSD_Svc,
  43. NFSD_Add,
  44. NFSD_Del,
  45. NFSD_Export,
  46. NFSD_Unexport,
  47. NFSD_Getfd,
  48. NFSD_Getfs,
  49. NFSD_List,
  50. NFSD_Fh,
  51. NFSD_Threads,
  52. NFSD_Pool_Threads,
  53. NFSD_Versions,
  54. NFSD_Ports,
  55. /*
  56. * The below MUST come last. Otherwise we leave a hole in nfsd_files[]
  57. * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops
  58. */
  59. #ifdef CONFIG_NFSD_V4
  60. NFSD_Leasetime,
  61. NFSD_RecoveryDir,
  62. #endif
  63. };
  64. /*
  65. * write() for these nodes.
  66. */
  67. static ssize_t write_svc(struct file *file, char *buf, size_t size);
  68. static ssize_t write_add(struct file *file, char *buf, size_t size);
  69. static ssize_t write_del(struct file *file, char *buf, size_t size);
  70. static ssize_t write_export(struct file *file, char *buf, size_t size);
  71. static ssize_t write_unexport(struct file *file, char *buf, size_t size);
  72. static ssize_t write_getfd(struct file *file, char *buf, size_t size);
  73. static ssize_t write_getfs(struct file *file, char *buf, size_t size);
  74. static ssize_t write_filehandle(struct file *file, char *buf, size_t size);
  75. static ssize_t write_threads(struct file *file, char *buf, size_t size);
  76. static ssize_t write_pool_threads(struct file *file, char *buf, size_t size);
  77. static ssize_t write_versions(struct file *file, char *buf, size_t size);
  78. static ssize_t write_ports(struct file *file, char *buf, size_t size);
  79. #ifdef CONFIG_NFSD_V4
  80. static ssize_t write_leasetime(struct file *file, char *buf, size_t size);
  81. static ssize_t write_recoverydir(struct file *file, char *buf, size_t size);
  82. #endif
  83. static ssize_t (*write_op[])(struct file *, char *, size_t) = {
  84. [NFSD_Svc] = write_svc,
  85. [NFSD_Add] = write_add,
  86. [NFSD_Del] = write_del,
  87. [NFSD_Export] = write_export,
  88. [NFSD_Unexport] = write_unexport,
  89. [NFSD_Getfd] = write_getfd,
  90. [NFSD_Getfs] = write_getfs,
  91. [NFSD_Fh] = write_filehandle,
  92. [NFSD_Threads] = write_threads,
  93. [NFSD_Pool_Threads] = write_pool_threads,
  94. [NFSD_Versions] = write_versions,
  95. [NFSD_Ports] = write_ports,
  96. #ifdef CONFIG_NFSD_V4
  97. [NFSD_Leasetime] = write_leasetime,
  98. [NFSD_RecoveryDir] = write_recoverydir,
  99. #endif
  100. };
  101. static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos)
  102. {
  103. ino_t ino = file->f_dentry->d_inode->i_ino;
  104. char *data;
  105. ssize_t rv;
  106. if (ino >= ARRAY_SIZE(write_op) || !write_op[ino])
  107. return -EINVAL;
  108. data = simple_transaction_get(file, buf, size);
  109. if (IS_ERR(data))
  110. return PTR_ERR(data);
  111. rv = write_op[ino](file, data, size);
  112. if (rv>0) {
  113. simple_transaction_set(file, rv);
  114. rv = size;
  115. }
  116. return rv;
  117. }
  118. static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
  119. {
  120. if (! file->private_data) {
  121. /* An attempt to read a transaction file without writing
  122. * causes a 0-byte write so that the file can return
  123. * state information
  124. */
  125. ssize_t rv = nfsctl_transaction_write(file, buf, 0, pos);
  126. if (rv < 0)
  127. return rv;
  128. }
  129. return simple_transaction_read(file, buf, size, pos);
  130. }
  131. static const struct file_operations transaction_ops = {
  132. .write = nfsctl_transaction_write,
  133. .read = nfsctl_transaction_read,
  134. .release = simple_transaction_release,
  135. };
  136. extern struct seq_operations nfs_exports_op;
  137. static int exports_open(struct inode *inode, struct file *file)
  138. {
  139. return seq_open(file, &nfs_exports_op);
  140. }
  141. static const struct file_operations exports_operations = {
  142. .open = exports_open,
  143. .read = seq_read,
  144. .llseek = seq_lseek,
  145. .release = seq_release,
  146. };
  147. /*----------------------------------------------------------------------------*/
  148. /*
  149. * payload - write methods
  150. * If the method has a response, the response should be put in buf,
  151. * and the length returned. Otherwise return 0 or and -error.
  152. */
  153. static ssize_t write_svc(struct file *file, char *buf, size_t size)
  154. {
  155. struct nfsctl_svc *data;
  156. if (size < sizeof(*data))
  157. return -EINVAL;
  158. data = (struct nfsctl_svc*) buf;
  159. return nfsd_svc(data->svc_port, data->svc_nthreads);
  160. }
  161. static ssize_t write_add(struct file *file, char *buf, size_t size)
  162. {
  163. struct nfsctl_client *data;
  164. if (size < sizeof(*data))
  165. return -EINVAL;
  166. data = (struct nfsctl_client *)buf;
  167. return exp_addclient(data);
  168. }
  169. static ssize_t write_del(struct file *file, char *buf, size_t size)
  170. {
  171. struct nfsctl_client *data;
  172. if (size < sizeof(*data))
  173. return -EINVAL;
  174. data = (struct nfsctl_client *)buf;
  175. return exp_delclient(data);
  176. }
  177. static ssize_t write_export(struct file *file, char *buf, size_t size)
  178. {
  179. struct nfsctl_export *data;
  180. if (size < sizeof(*data))
  181. return -EINVAL;
  182. data = (struct nfsctl_export*)buf;
  183. return exp_export(data);
  184. }
  185. static ssize_t write_unexport(struct file *file, char *buf, size_t size)
  186. {
  187. struct nfsctl_export *data;
  188. if (size < sizeof(*data))
  189. return -EINVAL;
  190. data = (struct nfsctl_export*)buf;
  191. return exp_unexport(data);
  192. }
  193. static ssize_t write_getfs(struct file *file, char *buf, size_t size)
  194. {
  195. struct nfsctl_fsparm *data;
  196. struct sockaddr_in *sin;
  197. struct auth_domain *clp;
  198. int err = 0;
  199. struct knfsd_fh *res;
  200. if (size < sizeof(*data))
  201. return -EINVAL;
  202. data = (struct nfsctl_fsparm*)buf;
  203. err = -EPROTONOSUPPORT;
  204. if (data->gd_addr.sa_family != AF_INET)
  205. goto out;
  206. sin = (struct sockaddr_in *)&data->gd_addr;
  207. if (data->gd_maxlen > NFS3_FHSIZE)
  208. data->gd_maxlen = NFS3_FHSIZE;
  209. res = (struct knfsd_fh*)buf;
  210. exp_readlock();
  211. if (!(clp = auth_unix_lookup(sin->sin_addr)))
  212. err = -EPERM;
  213. else {
  214. err = exp_rootfh(clp, data->gd_path, res, data->gd_maxlen);
  215. auth_domain_put(clp);
  216. }
  217. exp_readunlock();
  218. if (err == 0)
  219. err = res->fh_size + (int)&((struct knfsd_fh*)0)->fh_base;
  220. out:
  221. return err;
  222. }
  223. static ssize_t write_getfd(struct file *file, char *buf, size_t size)
  224. {
  225. struct nfsctl_fdparm *data;
  226. struct sockaddr_in *sin;
  227. struct auth_domain *clp;
  228. int err = 0;
  229. struct knfsd_fh fh;
  230. char *res;
  231. if (size < sizeof(*data))
  232. return -EINVAL;
  233. data = (struct nfsctl_fdparm*)buf;
  234. err = -EPROTONOSUPPORT;
  235. if (data->gd_addr.sa_family != AF_INET)
  236. goto out;
  237. err = -EINVAL;
  238. if (data->gd_version < 2 || data->gd_version > NFSSVC_MAXVERS)
  239. goto out;
  240. res = buf;
  241. sin = (struct sockaddr_in *)&data->gd_addr;
  242. exp_readlock();
  243. if (!(clp = auth_unix_lookup(sin->sin_addr)))
  244. err = -EPERM;
  245. else {
  246. err = exp_rootfh(clp, data->gd_path, &fh, NFS_FHSIZE);
  247. auth_domain_put(clp);
  248. }
  249. exp_readunlock();
  250. if (err == 0) {
  251. memset(res,0, NFS_FHSIZE);
  252. memcpy(res, &fh.fh_base, fh.fh_size);
  253. err = NFS_FHSIZE;
  254. }
  255. out:
  256. return err;
  257. }
  258. static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
  259. {
  260. /* request is:
  261. * domain path maxsize
  262. * response is
  263. * filehandle
  264. *
  265. * qword quoting is used, so filehandle will be \x....
  266. */
  267. char *dname, *path;
  268. int maxsize;
  269. char *mesg = buf;
  270. int len;
  271. struct auth_domain *dom;
  272. struct knfsd_fh fh;
  273. if (buf[size-1] != '\n')
  274. return -EINVAL;
  275. buf[size-1] = 0;
  276. dname = mesg;
  277. len = qword_get(&mesg, dname, size);
  278. if (len <= 0) return -EINVAL;
  279. path = dname+len+1;
  280. len = qword_get(&mesg, path, size);
  281. if (len <= 0) return -EINVAL;
  282. len = get_int(&mesg, &maxsize);
  283. if (len)
  284. return len;
  285. if (maxsize < NFS_FHSIZE)
  286. return -EINVAL;
  287. if (maxsize > NFS3_FHSIZE)
  288. maxsize = NFS3_FHSIZE;
  289. if (qword_get(&mesg, mesg, size)>0)
  290. return -EINVAL;
  291. /* we have all the words, they are in buf.. */
  292. dom = unix_domain_find(dname);
  293. if (!dom)
  294. return -ENOMEM;
  295. len = exp_rootfh(dom, path, &fh, maxsize);
  296. auth_domain_put(dom);
  297. if (len)
  298. return len;
  299. mesg = buf; len = SIMPLE_TRANSACTION_LIMIT;
  300. qword_addhex(&mesg, &len, (char*)&fh.fh_base, fh.fh_size);
  301. mesg[-1] = '\n';
  302. return mesg - buf;
  303. }
  304. extern int nfsd_nrthreads(void);
  305. static ssize_t write_threads(struct file *file, char *buf, size_t size)
  306. {
  307. /* if size > 0, look for a number of threads and call nfsd_svc
  308. * then write out number of threads as reply
  309. */
  310. char *mesg = buf;
  311. int rv;
  312. if (size > 0) {
  313. int newthreads;
  314. rv = get_int(&mesg, &newthreads);
  315. if (rv)
  316. return rv;
  317. if (newthreads <0)
  318. return -EINVAL;
  319. rv = nfsd_svc(2049, newthreads);
  320. if (rv)
  321. return rv;
  322. }
  323. sprintf(buf, "%d\n", nfsd_nrthreads());
  324. return strlen(buf);
  325. }
  326. extern int nfsd_nrpools(void);
  327. extern int nfsd_get_nrthreads(int n, int *);
  328. extern int nfsd_set_nrthreads(int n, int *);
  329. static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
  330. {
  331. /* if size > 0, look for an array of number of threads per node
  332. * and apply them then write out number of threads per node as reply
  333. */
  334. char *mesg = buf;
  335. int i;
  336. int rv;
  337. int len;
  338. int npools = nfsd_nrpools();
  339. int *nthreads;
  340. if (npools == 0) {
  341. /*
  342. * NFS is shut down. The admin can start it by
  343. * writing to the threads file but NOT the pool_threads
  344. * file, sorry. Report zero threads.
  345. */
  346. strcpy(buf, "0\n");
  347. return strlen(buf);
  348. }
  349. nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL);
  350. if (nthreads == NULL)
  351. return -ENOMEM;
  352. if (size > 0) {
  353. for (i = 0; i < npools; i++) {
  354. rv = get_int(&mesg, &nthreads[i]);
  355. if (rv == -ENOENT)
  356. break; /* fewer numbers than pools */
  357. if (rv)
  358. goto out_free; /* syntax error */
  359. rv = -EINVAL;
  360. if (nthreads[i] < 0)
  361. goto out_free;
  362. }
  363. rv = nfsd_set_nrthreads(i, nthreads);
  364. if (rv)
  365. goto out_free;
  366. }
  367. rv = nfsd_get_nrthreads(npools, nthreads);
  368. if (rv)
  369. goto out_free;
  370. mesg = buf;
  371. size = SIMPLE_TRANSACTION_LIMIT;
  372. for (i = 0; i < npools && size > 0; i++) {
  373. snprintf(mesg, size, "%d%c", nthreads[i], (i == npools-1 ? '\n' : ' '));
  374. len = strlen(mesg);
  375. size -= len;
  376. mesg += len;
  377. }
  378. return (mesg-buf);
  379. out_free:
  380. kfree(nthreads);
  381. return rv;
  382. }
  383. static ssize_t write_versions(struct file *file, char *buf, size_t size)
  384. {
  385. /*
  386. * Format:
  387. * [-/+]vers [-/+]vers ...
  388. */
  389. char *mesg = buf;
  390. char *vers, sign;
  391. int len, num;
  392. ssize_t tlen = 0;
  393. char *sep;
  394. if (size>0) {
  395. if (nfsd_serv)
  396. /* Cannot change versions without updating
  397. * nfsd_serv->sv_xdrsize, and reallocing
  398. * rq_argp and rq_resp
  399. */
  400. return -EBUSY;
  401. if (buf[size-1] != '\n')
  402. return -EINVAL;
  403. buf[size-1] = 0;
  404. vers = mesg;
  405. len = qword_get(&mesg, vers, size);
  406. if (len <= 0) return -EINVAL;
  407. do {
  408. sign = *vers;
  409. if (sign == '+' || sign == '-')
  410. num = simple_strtol((vers+1), NULL, 0);
  411. else
  412. num = simple_strtol(vers, NULL, 0);
  413. switch(num) {
  414. case 2:
  415. case 3:
  416. case 4:
  417. nfsd_vers(num, sign == '-' ? NFSD_CLEAR : NFSD_SET);
  418. break;
  419. default:
  420. return -EINVAL;
  421. }
  422. vers += len + 1;
  423. tlen += len;
  424. } while ((len = qword_get(&mesg, vers, size)) > 0);
  425. /* If all get turned off, turn them back on, as
  426. * having no versions is BAD
  427. */
  428. nfsd_reset_versions();
  429. }
  430. /* Now write current state into reply buffer */
  431. len = 0;
  432. sep = "";
  433. for (num=2 ; num <= 4 ; num++)
  434. if (nfsd_vers(num, NFSD_AVAIL)) {
  435. len += sprintf(buf+len, "%s%c%d", sep,
  436. nfsd_vers(num, NFSD_TEST)?'+':'-',
  437. num);
  438. sep = " ";
  439. }
  440. len += sprintf(buf+len, "\n");
  441. return len;
  442. }
  443. static ssize_t write_ports(struct file *file, char *buf, size_t size)
  444. {
  445. if (size == 0) {
  446. int len = 0;
  447. lock_kernel();
  448. if (nfsd_serv)
  449. len = svc_sock_names(buf, nfsd_serv, NULL);
  450. unlock_kernel();
  451. return len;
  452. }
  453. /* Either a single 'fd' number is written, in which
  454. * case it must be for a socket of a supported family/protocol,
  455. * and we use it as an nfsd socket, or
  456. * A '-' followed by the 'name' of a socket in which case
  457. * we close the socket.
  458. */
  459. if (isdigit(buf[0])) {
  460. char *mesg = buf;
  461. int fd;
  462. int err;
  463. err = get_int(&mesg, &fd);
  464. if (err)
  465. return -EINVAL;
  466. if (fd < 0)
  467. return -EINVAL;
  468. err = nfsd_create_serv();
  469. if (!err) {
  470. int proto = 0;
  471. err = lockd_up(proto);
  472. if (!err) {
  473. err = svc_addsock(nfsd_serv, fd, buf, &proto);
  474. if (err)
  475. lockd_down();
  476. }
  477. /* Decrease the count, but don't shutdown the
  478. * the service
  479. */
  480. nfsd_serv->sv_nrthreads--;
  481. }
  482. return err;
  483. }
  484. if (buf[0] == '-') {
  485. char *toclose = kstrdup(buf+1, GFP_KERNEL);
  486. int len = 0;
  487. if (!toclose)
  488. return -ENOMEM;
  489. lock_kernel();
  490. if (nfsd_serv)
  491. len = svc_sock_names(buf, nfsd_serv, toclose);
  492. unlock_kernel();
  493. kfree(toclose);
  494. return len;
  495. }
  496. return -EINVAL;
  497. }
  498. #ifdef CONFIG_NFSD_V4
  499. extern time_t nfs4_leasetime(void);
  500. static ssize_t write_leasetime(struct file *file, char *buf, size_t size)
  501. {
  502. /* if size > 10 seconds, call
  503. * nfs4_reset_lease() then write out the new lease (seconds) as reply
  504. */
  505. char *mesg = buf;
  506. int rv;
  507. if (size > 0) {
  508. int lease;
  509. rv = get_int(&mesg, &lease);
  510. if (rv)
  511. return rv;
  512. if (lease < 10 || lease > 3600)
  513. return -EINVAL;
  514. nfs4_reset_lease(lease);
  515. }
  516. sprintf(buf, "%ld\n", nfs4_lease_time());
  517. return strlen(buf);
  518. }
  519. static ssize_t write_recoverydir(struct file *file, char *buf, size_t size)
  520. {
  521. char *mesg = buf;
  522. char *recdir;
  523. int len, status;
  524. if (size > PATH_MAX || buf[size-1] != '\n')
  525. return -EINVAL;
  526. buf[size-1] = 0;
  527. recdir = mesg;
  528. len = qword_get(&mesg, recdir, size);
  529. if (len <= 0)
  530. return -EINVAL;
  531. status = nfs4_reset_recoverydir(recdir);
  532. return strlen(buf);
  533. }
  534. #endif
  535. /*----------------------------------------------------------------------------*/
  536. /*
  537. * populating the filesystem.
  538. */
  539. static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
  540. {
  541. static struct tree_descr nfsd_files[] = {
  542. [NFSD_Svc] = {".svc", &transaction_ops, S_IWUSR},
  543. [NFSD_Add] = {".add", &transaction_ops, S_IWUSR},
  544. [NFSD_Del] = {".del", &transaction_ops, S_IWUSR},
  545. [NFSD_Export] = {".export", &transaction_ops, S_IWUSR},
  546. [NFSD_Unexport] = {".unexport", &transaction_ops, S_IWUSR},
  547. [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR},
  548. [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR},
  549. [NFSD_List] = {"exports", &exports_operations, S_IRUGO},
  550. [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR},
  551. [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
  552. [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR},
  553. [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR},
  554. [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO},
  555. #ifdef CONFIG_NFSD_V4
  556. [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR},
  557. [NFSD_RecoveryDir] = {"nfsv4recoverydir", &transaction_ops, S_IWUSR|S_IRUSR},
  558. #endif
  559. /* last one */ {""}
  560. };
  561. return simple_fill_super(sb, 0x6e667364, nfsd_files);
  562. }
  563. static int nfsd_get_sb(struct file_system_type *fs_type,
  564. int flags, const char *dev_name, void *data, struct vfsmount *mnt)
  565. {
  566. return get_sb_single(fs_type, flags, data, nfsd_fill_super, mnt);
  567. }
  568. static struct file_system_type nfsd_fs_type = {
  569. .owner = THIS_MODULE,
  570. .name = "nfsd",
  571. .get_sb = nfsd_get_sb,
  572. .kill_sb = kill_litter_super,
  573. };
  574. static int __init init_nfsd(void)
  575. {
  576. int retval;
  577. printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
  578. nfsd_stat_init(); /* Statistics */
  579. nfsd_cache_init(); /* RPC reply cache */
  580. nfsd_export_init(); /* Exports table */
  581. nfsd_lockd_init(); /* lockd->nfsd callbacks */
  582. nfs4_state_init(); /* NFSv4 locking state */
  583. nfsd_idmap_init(); /* Name to ID mapping */
  584. if (proc_mkdir("fs/nfs", NULL)) {
  585. struct proc_dir_entry *entry;
  586. entry = create_proc_entry("fs/nfs/exports", 0, NULL);
  587. if (entry)
  588. entry->proc_fops = &exports_operations;
  589. }
  590. retval = register_filesystem(&nfsd_fs_type);
  591. if (retval) {
  592. nfsd_export_shutdown();
  593. nfsd_cache_shutdown();
  594. remove_proc_entry("fs/nfs/exports", NULL);
  595. remove_proc_entry("fs/nfs", NULL);
  596. nfsd_stat_shutdown();
  597. nfsd_lockd_shutdown();
  598. }
  599. return retval;
  600. }
  601. static void __exit exit_nfsd(void)
  602. {
  603. nfsd_export_shutdown();
  604. nfsd_cache_shutdown();
  605. remove_proc_entry("fs/nfs/exports", NULL);
  606. remove_proc_entry("fs/nfs", NULL);
  607. nfsd_stat_shutdown();
  608. nfsd_lockd_shutdown();
  609. nfsd_idmap_shutdown();
  610. unregister_filesystem(&nfsd_fs_type);
  611. }
  612. MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
  613. MODULE_LICENSE("GPL");
  614. module_init(init_nfsd)
  615. module_exit(exit_nfsd)