sysctl.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 <linux/nfs_idmap.h>
  15. #include <linux/nfs_fs.h>
  16. #include "callback.h"
  17. static const int nfs_set_port_min = 0;
  18. static const int nfs_set_port_max = 65535;
  19. static struct ctl_table_header *nfs_callback_sysctl_table;
  20. /*
  21. * Something that isn't CTL_ANY, CTL_NONE or a value that may clash.
  22. * Use the same values as fs/lockd/svc.c
  23. */
  24. #define CTL_UNNUMBERED -2
  25. static ctl_table nfs_cb_sysctls[] = {
  26. #ifdef CONFIG_NFS_V4
  27. {
  28. .ctl_name = CTL_UNNUMBERED,
  29. .procname = "nfs_callback_tcpport",
  30. .data = &nfs_callback_set_tcpport,
  31. .maxlen = sizeof(int),
  32. .mode = 0644,
  33. .proc_handler = &proc_dointvec_minmax,
  34. .extra1 = (int *)&nfs_set_port_min,
  35. .extra2 = (int *)&nfs_set_port_max,
  36. },
  37. {
  38. .ctl_name = CTL_UNNUMBERED,
  39. .procname = "idmap_cache_timeout",
  40. .data = &nfs_idmap_cache_timeout,
  41. .maxlen = sizeof(int),
  42. .mode = 0644,
  43. .proc_handler = &proc_dointvec_jiffies,
  44. .strategy = &sysctl_jiffies,
  45. },
  46. #endif
  47. {
  48. .ctl_name = CTL_UNNUMBERED,
  49. .procname = "nfs_mountpoint_timeout",
  50. .data = &nfs_mountpoint_expiry_timeout,
  51. .maxlen = sizeof(nfs_mountpoint_expiry_timeout),
  52. .mode = 0644,
  53. .proc_handler = &proc_dointvec_jiffies,
  54. .strategy = &sysctl_jiffies,
  55. },
  56. { .ctl_name = 0 }
  57. };
  58. static ctl_table nfs_cb_sysctl_dir[] = {
  59. {
  60. .ctl_name = CTL_UNNUMBERED,
  61. .procname = "nfs",
  62. .mode = 0555,
  63. .child = nfs_cb_sysctls,
  64. },
  65. { .ctl_name = 0 }
  66. };
  67. static ctl_table nfs_cb_sysctl_root[] = {
  68. {
  69. .ctl_name = CTL_FS,
  70. .procname = "fs",
  71. .mode = 0555,
  72. .child = nfs_cb_sysctl_dir,
  73. },
  74. { .ctl_name = 0 }
  75. };
  76. int nfs_register_sysctl(void)
  77. {
  78. nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root, 0);
  79. if (nfs_callback_sysctl_table == NULL)
  80. return -ENOMEM;
  81. return 0;
  82. }
  83. void nfs_unregister_sysctl(void)
  84. {
  85. unregister_sysctl_table(nfs_callback_sysctl_table);
  86. nfs_callback_sysctl_table = NULL;
  87. }