diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2013-02-01 07:56:17 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2013-02-15 11:21:01 -0500 |
commit | 96d851c4d28de8cc83fe2bd5c6bc2eb8f253a6c5 (patch) | |
tree | f019d279e6cd5bf255a81c23f7aac3564397f832 /fs/nfsd/nfsctl.c | |
parent | 11f779421a39b86da8a523d97e5fd3477878d44f (diff) |
nfsd: use proper net while reading "exports" file
Functuon "exports_open" is used for both "/proc/fs/nfs/exports" and
"/proc/fs/nfsd/exports" files.
Now NFSd filesystem is containerised, so proper net can be taken from
superblock for "/proc/fs/nfsd/exports" reader.
But for "/proc/fs/nfsd/exports" only current->nsproxy->net_ns can be used.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfsctl.c')
-rw-r--r-- | fs/nfsd/nfsctl.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index f6d448e6eb28..8ead2c25ce65 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -125,11 +125,11 @@ static const struct file_operations transaction_ops = { | |||
125 | .llseek = default_llseek, | 125 | .llseek = default_llseek, |
126 | }; | 126 | }; |
127 | 127 | ||
128 | static int exports_open(struct inode *inode, struct file *file) | 128 | static int exports_net_open(struct net *net, struct file *file) |
129 | { | 129 | { |
130 | int err; | 130 | int err; |
131 | struct seq_file *seq; | 131 | struct seq_file *seq; |
132 | struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); | 132 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
133 | 133 | ||
134 | err = seq_open(file, &nfs_exports_op); | 134 | err = seq_open(file, &nfs_exports_op); |
135 | if (err) | 135 | if (err) |
@@ -140,8 +140,26 @@ static int exports_open(struct inode *inode, struct file *file) | |||
140 | return 0; | 140 | return 0; |
141 | } | 141 | } |
142 | 142 | ||
143 | static const struct file_operations exports_operations = { | 143 | static int exports_proc_open(struct inode *inode, struct file *file) |
144 | .open = exports_open, | 144 | { |
145 | return exports_net_open(current->nsproxy->net_ns, file); | ||
146 | } | ||
147 | |||
148 | static const struct file_operations exports_proc_operations = { | ||
149 | .open = exports_proc_open, | ||
150 | .read = seq_read, | ||
151 | .llseek = seq_lseek, | ||
152 | .release = seq_release, | ||
153 | .owner = THIS_MODULE, | ||
154 | }; | ||
155 | |||
156 | static int exports_nfsd_open(struct inode *inode, struct file *file) | ||
157 | { | ||
158 | return exports_net_open(inode->i_sb->s_fs_info, file); | ||
159 | } | ||
160 | |||
161 | static const struct file_operations exports_nfsd_operations = { | ||
162 | .open = exports_nfsd_open, | ||
145 | .read = seq_read, | 163 | .read = seq_read, |
146 | .llseek = seq_lseek, | 164 | .llseek = seq_lseek, |
147 | .release = seq_release, | 165 | .release = seq_release, |
@@ -1018,7 +1036,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) | |||
1018 | static int nfsd_fill_super(struct super_block * sb, void * data, int silent) | 1036 | static int nfsd_fill_super(struct super_block * sb, void * data, int silent) |
1019 | { | 1037 | { |
1020 | static struct tree_descr nfsd_files[] = { | 1038 | static struct tree_descr nfsd_files[] = { |
1021 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, | 1039 | [NFSD_List] = {"exports", &exports_nfsd_operations, S_IRUGO}, |
1022 | [NFSD_Export_features] = {"export_features", | 1040 | [NFSD_Export_features] = {"export_features", |
1023 | &export_features_operations, S_IRUGO}, | 1041 | &export_features_operations, S_IRUGO}, |
1024 | [NFSD_FO_UnlockIP] = {"unlock_ip", | 1042 | [NFSD_FO_UnlockIP] = {"unlock_ip", |
@@ -1081,7 +1099,8 @@ static int create_proc_exports_entry(void) | |||
1081 | entry = proc_mkdir("fs/nfs", NULL); | 1099 | entry = proc_mkdir("fs/nfs", NULL); |
1082 | if (!entry) | 1100 | if (!entry) |
1083 | return -ENOMEM; | 1101 | return -ENOMEM; |
1084 | entry = proc_create("exports", 0, entry, &exports_operations); | 1102 | entry = proc_create("exports", 0, entry, |
1103 | &exports_proc_operations); | ||
1085 | if (!entry) | 1104 | if (!entry) |
1086 | return -ENOMEM; | 1105 | return -ENOMEM; |
1087 | return 0; | 1106 | return 0; |