sysctl.c 2.0 KB

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