aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/Makefile2
-rw-r--r--fs/nfs/getroot.c50
-rw-r--r--fs/nfs/nfs4getroot.c49
3 files changed, 50 insertions, 51 deletions
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index e882a389b2ed..ec13afe2619a 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -15,7 +15,7 @@ nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o
15nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ 15nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
16 nfs4super.o nfs4file.o delegation.o idmap.o \ 16 nfs4super.o nfs4file.o delegation.o idmap.o \
17 callback.o callback_xdr.o callback_proc.o \ 17 callback.o callback_xdr.o callback_proc.o \
18 nfs4namespace.o 18 nfs4namespace.o nfs4getroot.o
19nfs-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o 19nfs-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o
20 20
21ifeq ($(CONFIG_SYSCTL), y) 21ifeq ($(CONFIG_SYSCTL), y)
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index a67990f90bd7..4654ced096a6 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -23,21 +23,15 @@
23#include <linux/sunrpc/stats.h> 23#include <linux/sunrpc/stats.h>
24#include <linux/nfs_fs.h> 24#include <linux/nfs_fs.h>
25#include <linux/nfs_mount.h> 25#include <linux/nfs_mount.h>
26#include <linux/nfs4_mount.h>
27#include <linux/lockd/bind.h> 26#include <linux/lockd/bind.h>
28#include <linux/seq_file.h> 27#include <linux/seq_file.h>
29#include <linux/mount.h> 28#include <linux/mount.h>
30#include <linux/nfs_idmap.h>
31#include <linux/vfs.h> 29#include <linux/vfs.h>
32#include <linux/namei.h> 30#include <linux/namei.h>
33#include <linux/security.h> 31#include <linux/security.h>
34 32
35#include <asm/uaccess.h> 33#include <asm/uaccess.h>
36 34
37#include "nfs4_fs.h"
38#include "delegation.h"
39#include "internal.h"
40
41#define NFSDBG_FACILITY NFSDBG_CLIENT 35#define NFSDBG_FACILITY NFSDBG_CLIENT
42 36
43/* 37/*
@@ -135,47 +129,3 @@ out:
135 nfs_free_fattr(fsinfo.fattr); 129 nfs_free_fattr(fsinfo.fattr);
136 return ret; 130 return ret;
137} 131}
138
139#ifdef CONFIG_NFS_V4
140
141int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh)
142{
143 struct nfs_fsinfo fsinfo;
144 int ret = -ENOMEM;
145
146 dprintk("--> nfs4_get_rootfh()\n");
147
148 fsinfo.fattr = nfs_alloc_fattr();
149 if (fsinfo.fattr == NULL)
150 goto out;
151
152 /* Start by getting the root filehandle from the server */
153 ret = nfs4_proc_get_rootfh(server, mntfh, &fsinfo);
154 if (ret < 0) {
155 dprintk("nfs4_get_rootfh: getroot error = %d\n", -ret);
156 goto out;
157 }
158
159 if (!(fsinfo.fattr->valid & NFS_ATTR_FATTR_TYPE)
160 || !S_ISDIR(fsinfo.fattr->mode)) {
161 printk(KERN_ERR "nfs4_get_rootfh:"
162 " getroot encountered non-directory\n");
163 ret = -ENOTDIR;
164 goto out;
165 }
166
167 if (fsinfo.fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) {
168 printk(KERN_ERR "nfs4_get_rootfh:"
169 " getroot obtained referral\n");
170 ret = -EREMOTE;
171 goto out;
172 }
173
174 memcpy(&server->fsid, &fsinfo.fattr->fsid, sizeof(server->fsid));
175out:
176 nfs_free_fattr(fsinfo.fattr);
177 dprintk("<-- nfs4_get_rootfh() = %d\n", ret);
178 return ret;
179}
180
181#endif /* CONFIG_NFS_V4 */
diff --git a/fs/nfs/nfs4getroot.c b/fs/nfs/nfs4getroot.c
new file mode 100644
index 000000000000..6a83780e0ce6
--- /dev/null
+++ b/fs/nfs/nfs4getroot.c
@@ -0,0 +1,49 @@
1/*
2* Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
3* Written by David Howells (dhowells@redhat.com)
4*/
5
6#include <linux/nfs_fs.h>
7#include "nfs4_fs.h"
8
9#define NFSDBG_FACILITY NFSDBG_CLIENT
10
11int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh)
12{
13 struct nfs_fsinfo fsinfo;
14 int ret = -ENOMEM;
15
16 dprintk("--> nfs4_get_rootfh()\n");
17
18 fsinfo.fattr = nfs_alloc_fattr();
19 if (fsinfo.fattr == NULL)
20 goto out;
21
22 /* Start by getting the root filehandle from the server */
23 ret = nfs4_proc_get_rootfh(server, mntfh, &fsinfo);
24 if (ret < 0) {
25 dprintk("nfs4_get_rootfh: getroot error = %d\n", -ret);
26 goto out;
27 }
28
29 if (!(fsinfo.fattr->valid & NFS_ATTR_FATTR_TYPE)
30 || !S_ISDIR(fsinfo.fattr->mode)) {
31 printk(KERN_ERR "nfs4_get_rootfh:"
32 " getroot encountered non-directory\n");
33 ret = -ENOTDIR;
34 goto out;
35 }
36
37 if (fsinfo.fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) {
38 printk(KERN_ERR "nfs4_get_rootfh:"
39 " getroot obtained referral\n");
40 ret = -EREMOTE;
41 goto out;
42 }
43
44 memcpy(&server->fsid, &fsinfo.fattr->fsid, sizeof(server->fsid));
45out:
46 nfs_free_fattr(fsinfo.fattr);
47 dprintk("<-- nfs4_get_rootfh() = %d\n", ret);
48 return ret;
49}