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