aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfsctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/nfsctl.c')
-rw-r--r--fs/nfsd/nfsctl.c67
1 files changed, 57 insertions, 10 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index b53b1d042f1f..2b1449dd2f49 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -8,20 +8,23 @@
8#include <linux/namei.h> 8#include <linux/namei.h>
9#include <linux/ctype.h> 9#include <linux/ctype.h>
10 10
11#include <linux/nfsd_idmap.h>
12#include <linux/sunrpc/svcsock.h> 11#include <linux/sunrpc/svcsock.h>
13#include <linux/nfsd/syscall.h> 12#include <linux/nfsd/syscall.h>
14#include <linux/lockd/lockd.h> 13#include <linux/lockd/lockd.h>
15#include <linux/sunrpc/clnt.h> 14#include <linux/sunrpc/clnt.h>
15#include <linux/sunrpc/gss_api.h>
16#include <linux/sunrpc/gss_krb5_enctypes.h>
16 17
18#include "idmap.h"
17#include "nfsd.h" 19#include "nfsd.h"
18#include "cache.h" 20#include "cache.h"
19 21
20/* 22/*
21 * We have a single directory with 9 nodes in it. 23 * We have a single directory with several nodes in it.
22 */ 24 */
23enum { 25enum {
24 NFSD_Root = 1, 26 NFSD_Root = 1,
27#ifdef CONFIG_NFSD_DEPRECATED
25 NFSD_Svc, 28 NFSD_Svc,
26 NFSD_Add, 29 NFSD_Add,
27 NFSD_Del, 30 NFSD_Del,
@@ -29,6 +32,7 @@ enum {
29 NFSD_Unexport, 32 NFSD_Unexport,
30 NFSD_Getfd, 33 NFSD_Getfd,
31 NFSD_Getfs, 34 NFSD_Getfs,
35#endif
32 NFSD_List, 36 NFSD_List,
33 NFSD_Export_features, 37 NFSD_Export_features,
34 NFSD_Fh, 38 NFSD_Fh,
@@ -40,6 +44,7 @@ enum {
40 NFSD_Versions, 44 NFSD_Versions,
41 NFSD_Ports, 45 NFSD_Ports,
42 NFSD_MaxBlkSize, 46 NFSD_MaxBlkSize,
47 NFSD_SupportedEnctypes,
43 /* 48 /*
44 * The below MUST come last. Otherwise we leave a hole in nfsd_files[] 49 * The below MUST come last. Otherwise we leave a hole in nfsd_files[]
45 * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops 50 * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops
@@ -54,6 +59,7 @@ enum {
54/* 59/*
55 * write() for these nodes. 60 * write() for these nodes.
56 */ 61 */
62#ifdef CONFIG_NFSD_DEPRECATED
57static ssize_t write_svc(struct file *file, char *buf, size_t size); 63static ssize_t write_svc(struct file *file, char *buf, size_t size);
58static ssize_t write_add(struct file *file, char *buf, size_t size); 64static ssize_t write_add(struct file *file, char *buf, size_t size);
59static ssize_t write_del(struct file *file, char *buf, size_t size); 65static ssize_t write_del(struct file *file, char *buf, size_t size);
@@ -61,6 +67,7 @@ static ssize_t write_export(struct file *file, char *buf, size_t size);
61static ssize_t write_unexport(struct file *file, char *buf, size_t size); 67static ssize_t write_unexport(struct file *file, char *buf, size_t size);
62static ssize_t write_getfd(struct file *file, char *buf, size_t size); 68static ssize_t write_getfd(struct file *file, char *buf, size_t size);
63static ssize_t write_getfs(struct file *file, char *buf, size_t size); 69static ssize_t write_getfs(struct file *file, char *buf, size_t size);
70#endif
64static ssize_t write_filehandle(struct file *file, char *buf, size_t size); 71static ssize_t write_filehandle(struct file *file, char *buf, size_t size);
65static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size); 72static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size);
66static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size); 73static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size);
@@ -76,6 +83,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size);
76#endif 83#endif
77 84
78static ssize_t (*write_op[])(struct file *, char *, size_t) = { 85static ssize_t (*write_op[])(struct file *, char *, size_t) = {
86#ifdef CONFIG_NFSD_DEPRECATED
79 [NFSD_Svc] = write_svc, 87 [NFSD_Svc] = write_svc,
80 [NFSD_Add] = write_add, 88 [NFSD_Add] = write_add,
81 [NFSD_Del] = write_del, 89 [NFSD_Del] = write_del,
@@ -83,6 +91,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = {
83 [NFSD_Unexport] = write_unexport, 91 [NFSD_Unexport] = write_unexport,
84 [NFSD_Getfd] = write_getfd, 92 [NFSD_Getfd] = write_getfd,
85 [NFSD_Getfs] = write_getfs, 93 [NFSD_Getfs] = write_getfs,
94#endif
86 [NFSD_Fh] = write_filehandle, 95 [NFSD_Fh] = write_filehandle,
87 [NFSD_FO_UnlockIP] = write_unlock_ip, 96 [NFSD_FO_UnlockIP] = write_unlock_ip,
88 [NFSD_FO_UnlockFS] = write_unlock_fs, 97 [NFSD_FO_UnlockFS] = write_unlock_fs,
@@ -121,6 +130,16 @@ static ssize_t nfsctl_transaction_write(struct file *file, const char __user *bu
121 130
122static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos) 131static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
123{ 132{
133#ifdef CONFIG_NFSD_DEPRECATED
134 static int warned;
135 if (file->f_dentry->d_name.name[0] == '.' && !warned) {
136 printk(KERN_INFO
137 "Warning: \"%s\" uses deprecated NFSD interface: %s."
138 " This will be removed in 2.6.40\n",
139 current->comm, file->f_dentry->d_name.name);
140 warned = 1;
141 }
142#endif
124 if (! file->private_data) { 143 if (! file->private_data) {
125 /* An attempt to read a transaction file without writing 144 /* An attempt to read a transaction file without writing
126 * causes a 0-byte write so that the file can return 145 * causes a 0-byte write so that the file can return
@@ -137,6 +156,7 @@ static const struct file_operations transaction_ops = {
137 .write = nfsctl_transaction_write, 156 .write = nfsctl_transaction_write,
138 .read = nfsctl_transaction_read, 157 .read = nfsctl_transaction_read,
139 .release = simple_transaction_release, 158 .release = simple_transaction_release,
159 .llseek = default_llseek,
140}; 160};
141 161
142static int exports_open(struct inode *inode, struct file *file) 162static int exports_open(struct inode *inode, struct file *file)
@@ -170,6 +190,26 @@ static struct file_operations export_features_operations = {
170 .release = single_release, 190 .release = single_release,
171}; 191};
172 192
193#if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE)
194static int supported_enctypes_show(struct seq_file *m, void *v)
195{
196 seq_printf(m, KRB5_SUPPORTED_ENCTYPES);
197 return 0;
198}
199
200static int supported_enctypes_open(struct inode *inode, struct file *file)
201{
202 return single_open(file, supported_enctypes_show, NULL);
203}
204
205static struct file_operations supported_enctypes_ops = {
206 .open = supported_enctypes_open,
207 .read = seq_read,
208 .llseek = seq_lseek,
209 .release = single_release,
210};
211#endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */
212
173extern int nfsd_pool_stats_open(struct inode *inode, struct file *file); 213extern int nfsd_pool_stats_open(struct inode *inode, struct file *file);
174extern int nfsd_pool_stats_release(struct inode *inode, struct file *file); 214extern int nfsd_pool_stats_release(struct inode *inode, struct file *file);
175 215
@@ -186,6 +226,7 @@ static const struct file_operations pool_stats_operations = {
186 * payload - write methods 226 * payload - write methods
187 */ 227 */
188 228
229#ifdef CONFIG_NFSD_DEPRECATED
189/** 230/**
190 * write_svc - Start kernel's NFSD server 231 * write_svc - Start kernel's NFSD server
191 * 232 *
@@ -401,7 +442,7 @@ static ssize_t write_getfs(struct file *file, char *buf, size_t size)
401 442
402 ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6); 443 ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6);
403 444
404 clp = auth_unix_lookup(&in6); 445 clp = auth_unix_lookup(&init_net, &in6);
405 if (!clp) 446 if (!clp)
406 err = -EPERM; 447 err = -EPERM;
407 else { 448 else {
@@ -464,7 +505,7 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size)
464 505
465 ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6); 506 ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6);
466 507
467 clp = auth_unix_lookup(&in6); 508 clp = auth_unix_lookup(&init_net, &in6);
468 if (!clp) 509 if (!clp)
469 err = -EPERM; 510 err = -EPERM;
470 else { 511 else {
@@ -481,6 +522,7 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size)
481 out: 522 out:
482 return err; 523 return err;
483} 524}
525#endif /* CONFIG_NFSD_DEPRECATED */
484 526
485/** 527/**
486 * write_unlock_ip - Release all locks used by a client 528 * write_unlock_ip - Release all locks used by a client
@@ -999,12 +1041,12 @@ static ssize_t __write_ports_addxprt(char *buf)
999 if (err != 0) 1041 if (err != 0)
1000 return err; 1042 return err;
1001 1043
1002 err = svc_create_xprt(nfsd_serv, transport, 1044 err = svc_create_xprt(nfsd_serv, transport, &init_net,
1003 PF_INET, port, SVC_SOCK_ANONYMOUS); 1045 PF_INET, port, SVC_SOCK_ANONYMOUS);
1004 if (err < 0) 1046 if (err < 0)
1005 goto out_err; 1047 goto out_err;
1006 1048
1007 err = svc_create_xprt(nfsd_serv, transport, 1049 err = svc_create_xprt(nfsd_serv, transport, &init_net,
1008 PF_INET6, port, SVC_SOCK_ANONYMOUS); 1050 PF_INET6, port, SVC_SOCK_ANONYMOUS);
1009 if (err < 0 && err != -EAFNOSUPPORT) 1051 if (err < 0 && err != -EAFNOSUPPORT)
1010 goto out_close; 1052 goto out_close;
@@ -1355,6 +1397,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size)
1355static int nfsd_fill_super(struct super_block * sb, void * data, int silent) 1397static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
1356{ 1398{
1357 static struct tree_descr nfsd_files[] = { 1399 static struct tree_descr nfsd_files[] = {
1400#ifdef CONFIG_NFSD_DEPRECATED
1358 [NFSD_Svc] = {".svc", &transaction_ops, S_IWUSR}, 1401 [NFSD_Svc] = {".svc", &transaction_ops, S_IWUSR},
1359 [NFSD_Add] = {".add", &transaction_ops, S_IWUSR}, 1402 [NFSD_Add] = {".add", &transaction_ops, S_IWUSR},
1360 [NFSD_Del] = {".del", &transaction_ops, S_IWUSR}, 1403 [NFSD_Del] = {".del", &transaction_ops, S_IWUSR},
@@ -1362,6 +1405,7 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
1362 [NFSD_Unexport] = {".unexport", &transaction_ops, S_IWUSR}, 1405 [NFSD_Unexport] = {".unexport", &transaction_ops, S_IWUSR},
1363 [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, 1406 [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR},
1364 [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, 1407 [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR},
1408#endif
1365 [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, 1409 [NFSD_List] = {"exports", &exports_operations, S_IRUGO},
1366 [NFSD_Export_features] = {"export_features", 1410 [NFSD_Export_features] = {"export_features",
1367 &export_features_operations, S_IRUGO}, 1411 &export_features_operations, S_IRUGO},
@@ -1376,6 +1420,9 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
1376 [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR}, 1420 [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR},
1377 [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO}, 1421 [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO},
1378 [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO}, 1422 [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO},
1423#if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE)
1424 [NFSD_SupportedEnctypes] = {"supported_krb5_enctypes", &supported_enctypes_ops, S_IRUGO},
1425#endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */
1379#ifdef CONFIG_NFSD_V4 1426#ifdef CONFIG_NFSD_V4
1380 [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, 1427 [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR},
1381 [NFSD_Gracetime] = {"nfsv4gracetime", &transaction_ops, S_IWUSR|S_IRUSR}, 1428 [NFSD_Gracetime] = {"nfsv4gracetime", &transaction_ops, S_IWUSR|S_IRUSR},
@@ -1386,16 +1433,16 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
1386 return simple_fill_super(sb, 0x6e667364, nfsd_files); 1433 return simple_fill_super(sb, 0x6e667364, nfsd_files);
1387} 1434}
1388 1435
1389static int nfsd_get_sb(struct file_system_type *fs_type, 1436static struct dentry *nfsd_mount(struct file_system_type *fs_type,
1390 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 1437 int flags, const char *dev_name, void *data)
1391{ 1438{
1392 return get_sb_single(fs_type, flags, data, nfsd_fill_super, mnt); 1439 return mount_single(fs_type, flags, data, nfsd_fill_super);
1393} 1440}
1394 1441
1395static struct file_system_type nfsd_fs_type = { 1442static struct file_system_type nfsd_fs_type = {
1396 .owner = THIS_MODULE, 1443 .owner = THIS_MODULE,
1397 .name = "nfsd", 1444 .name = "nfsd",
1398 .get_sb = nfsd_get_sb, 1445 .mount = nfsd_mount,
1399 .kill_sb = kill_litter_super, 1446 .kill_sb = kill_litter_super,
1400}; 1447};
1401 1448