2 * linux/fs/nfs/namespace.c
4 * Copyright (C) 2005 Trond Myklebust <Trond.Myklebust@netapp.com>
9 #include <linux/config.h>
11 #include <linux/dcache.h>
12 #include <linux/mount.h>
13 #include <linux/namei.h>
14 #include <linux/nfs_fs.h>
15 #include <linux/string.h>
16 #include <linux/sunrpc/clnt.h>
17 #include <linux/vfs.h>
19 #define NFSDBG_FACILITY NFSDBG_VFS
22 * nfs_follow_mountpoint - handle crossing a mountpoint on the server
23 * @dentry - dentry of mountpoint
24 * @nd - nameidata info
26 * When we encounter a mountpoint on the server, we want to set up
27 * a mountpoint on the client too, to prevent inode numbers from
28 * colliding, and to allow "df" to work properly.
29 * On NFSv4, we also want to allow for the fact that different
30 * filesystems may be migrated to different servers in a failover
31 * situation, and that different filesystems may want to use
32 * different security flavours.
34 static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
37 struct nfs_server *server = NFS_SERVER(dentry->d_inode);
38 struct dentry *parent;
40 struct nfs_fattr fattr;
43 BUG_ON(IS_ROOT(dentry));
44 dprintk("%s: enter\n", __FUNCTION__);
46 nd->dentry = dget(dentry);
47 if (d_mountpoint(nd->dentry))
49 /* Look it up again */
50 parent = dget_parent(nd->dentry);
51 err = server->rpc_ops->lookup(parent->d_inode, &nd->dentry->d_name, &fh, &fattr);
56 mnt = nfs_do_submount(nd->mnt, nd->dentry, &fh, &fattr);
62 err = do_add_mount(mnt, nd, nd->mnt->mnt_flags, NULL);
72 nd->dentry = dget(mnt->mnt_root);
74 dprintk("%s: done, returned %d\n", __FUNCTION__, err);
80 while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry))
86 struct inode_operations nfs_mountpoint_inode_operations = {
87 .follow_link = nfs_follow_mountpoint,
88 .getattr = nfs_getattr,