nfsctl.c 17 KB

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