sysctl.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * linux/fs/nfs/sysctl.c
  3. *
  4. * Sysctl interface to NFS parameters
  5. */
  6. #include <linux/config.h>
  7. #include <linux/types.h>
  8. #include <linux/linkage.h>
  9. #include <linux/ctype.h>
  10. #include <linux/fs.h>
  11. #include <linux/sysctl.h>
  12. #include <linux/module.h>
  13. #include <linux/nfs4.h>
  14. #include "callback.h"
  15. static const int nfs_set_port_min = 0;
  16. static const int nfs_set_port_max = 65535;
  17. static struct ctl_table_header *nfs_callback_sysctl_table;
  18. /*
  19. * Something that isn't CTL_ANY, CTL_NONE or a value that may clash.
  20. * Use the same values as fs/lockd/svc.c
  21. */
  22. #define CTL_UNNUMBERED -2
  23. static ctl_table nfs_cb_sysctls[] = {
  24. #ifdef CONFIG_NFS_V4
  25. {
  26. .ctl_name = CTL_UNNUMBERED,
  27. .procname = "nfs_callback_tcpport",
  28. .data = &nfs_callback_set_tcpport,
  29. .maxlen = sizeof(int),
  30. .mode = 0644,
  31. .proc_handler = &proc_dointvec_minmax,
  32. .extra1 = (int *)&nfs_set_port_min,
  33. .extra2 = (int *)&nfs_set_port_max,
  34. },
  35. #endif
  36. { .ctl_name = 0 }
  37. };
  38. static ctl_table nfs_cb_sysctl_dir[] = {
  39. {
  40. .ctl_name = CTL_UNNUMBERED,
  41. .procname = "nfs",
  42. .mode = 0555,
  43. .child = nfs_cb_sysctls,
  44. },
  45. { .ctl_name = 0 }
  46. };
  47. static ctl_table nfs_cb_sysctl_root[] = {
  48. {
  49. .ctl_name = CTL_FS,
  50. .procname = "fs",
  51. .mode = 0555,
  52. .child = nfs_cb_sysctl_dir,
  53. },
  54. { .ctl_name = 0 }
  55. };
  56. int nfs_register_sysctl(void)
  57. {
  58. nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root, 0);
  59. if (nfs_callback_sysctl_table == NULL)
  60. return -ENOMEM;
  61. return 0;
  62. }
  63. void nfs_unregister_sysctl(void)
  64. {
  65. unregister_sysctl_table(nfs_callback_sysctl_table);
  66. nfs_callback_sysctl_table = NULL;
  67. }