Merge git://1984.lsi.us.es/nf-next
[cascardo/linux.git] / fs / nfs / nfs4sysctl.c
1 /*
2  * linux/fs/nfs/nfs4sysctl.c
3  *
4  * Sysctl interface to NFS v4 parameters
5  *
6  * Copyright (c) 2006 Trond Myklebust <Trond.Myklebust@netapp.com>
7  */
8 #include <linux/sysctl.h>
9 #include <linux/nfs_idmap.h>
10 #include <linux/nfs_fs.h>
11
12 #include "callback.h"
13
14 static const int nfs_set_port_min = 0;
15 static const int nfs_set_port_max = 65535;
16 static struct ctl_table_header *nfs4_callback_sysctl_table;
17
18 static ctl_table nfs4_cb_sysctls[] = {
19         {
20                 .procname = "nfs_callback_tcpport",
21                 .data = &nfs_callback_set_tcpport,
22                 .maxlen = sizeof(int),
23                 .mode = 0644,
24                 .proc_handler = proc_dointvec_minmax,
25                 .extra1 = (int *)&nfs_set_port_min,
26                 .extra2 = (int *)&nfs_set_port_max,
27         },
28         {
29                 .procname = "idmap_cache_timeout",
30                 .data = &nfs_idmap_cache_timeout,
31                 .maxlen = sizeof(int),
32                 .mode = 0644,
33                 .proc_handler = proc_dointvec_jiffies,
34         },
35         { }
36 };
37
38 static ctl_table nfs4_cb_sysctl_dir[] = {
39         {
40                 .procname = "nfs",
41                 .mode = 0555,
42                 .child = nfs4_cb_sysctls,
43         },
44         { }
45 };
46
47 static ctl_table nfs4_cb_sysctl_root[] = {
48         {
49                 .procname = "fs",
50                 .mode = 0555,
51                 .child = nfs4_cb_sysctl_dir,
52         },
53         { }
54 };
55
56 int nfs4_register_sysctl(void)
57 {
58         nfs4_callback_sysctl_table = register_sysctl_table(nfs4_cb_sysctl_root);
59         if (nfs4_callback_sysctl_table == NULL)
60                 return -ENOMEM;
61         return 0;
62 }
63
64 void nfs4_unregister_sysctl(void)
65 {
66         unregister_sysctl_table(nfs4_callback_sysctl_table);
67         nfs4_callback_sysctl_table = NULL;
68 }