2 * linux/fs/nfs/symlink.c
4 * Copyright (C) 1992 Rick Sladkey
6 * Optimization changes Copyright (C) 1994 Florian La Roche
8 * nfs symlink handling code
11 #include <linux/sched.h>
12 #include <linux/errno.h>
13 #include <linux/nfs_fs.h>
14 #include <linux/stat.h>
16 #include <linux/malloc.h>
17 #include <linux/string.h>
19 #include <asm/uaccess.h>
21 static int nfs_readlink(struct dentry
*, char *, int);
22 static struct dentry
*nfs_follow_link(struct dentry
*, struct dentry
*, unsigned int);
25 * symlinks can't do much...
27 struct inode_operations nfs_symlink_inode_operations
= {
28 NULL
, /* no file-operations */
38 nfs_readlink
, /* readlink */
39 nfs_follow_link
, /* follow_link */
47 static int nfs_readlink(struct dentry
*dentry
, char *buffer
, int buflen
)
54 dfprintk(VFS
, "nfs: readlink(%s/%s)\n",
55 dentry
->d_parent
->d_name
.name
, dentry
->d_name
.name
);
57 error
= nfs_proc_readlink(NFS_DSERVER(dentry
), NFS_FH(dentry
),
58 &mem
, &res
, &len
, NFS_MAXPATHLEN
);
62 copy_to_user(buffer
, res
, len
);
69 static struct dentry
*
70 nfs_follow_link(struct dentry
* dentry
, struct dentry
*base
, unsigned int follow
)
77 struct dentry
*result
;
79 dfprintk(VFS
, "nfs: follow_link(%s/%s)\n",
80 dentry
->d_parent
->d_name
.name
, dentry
->d_name
.name
);
82 error
= nfs_proc_readlink(NFS_DSERVER(dentry
), NFS_FH(dentry
),
83 &mem
, &res
, &len
, NFS_MAXPATHLEN
);
84 result
= ERR_PTR(error
);
88 result
= ERR_PTR(-ENOMEM
);
89 path
= kmalloc(len
+ 1, GFP_KERNEL
);
92 memcpy(path
, res
, len
);
96 result
= lookup_dentry(path
, base
, follow
);