This source file includes following definitions.
- nfs_follow_link
- nfs_readlink
1
2
3
4
5
6
7
8
9
10
11 #ifdef MODULE
12 #include <linux/module.h>
13 #endif
14
15 #include <asm/segment.h>
16
17 #include <linux/sched.h>
18 #include <linux/errno.h>
19 #include <linux/nfs_fs.h>
20 #include <linux/stat.h>
21 #include <linux/mm.h>
22 #include <linux/malloc.h>
23 #include <linux/string.h>
24
25 static int nfs_readlink(struct inode *, char *, int);
26 static int nfs_follow_link(struct inode *, struct inode *, int, int,
27 struct inode **);
28
29
30
31
32 struct inode_operations nfs_symlink_inode_operations = {
33 NULL,
34 NULL,
35 NULL,
36 NULL,
37 NULL,
38 NULL,
39 NULL,
40 NULL,
41 NULL,
42 NULL,
43 nfs_readlink,
44 nfs_follow_link,
45 NULL,
46 NULL,
47 NULL
48 };
49
50 static int nfs_follow_link(struct inode *dir, struct inode *inode,
51 int flag, int mode, struct inode **res_inode)
52 {
53 int error, *mem;
54 unsigned int len;
55 char *res, *res2;
56
57 *res_inode = NULL;
58 if (!dir) {
59 dir = current->fs->root;
60 dir->i_count++;
61 }
62 if (!inode) {
63 iput(dir);
64 return -ENOENT;
65 }
66 if (!S_ISLNK(inode->i_mode)) {
67 iput(dir);
68 *res_inode = inode;
69 return 0;
70 }
71 if (current->link_count > 5) {
72 iput(inode);
73 iput(dir);
74 return -ELOOP;
75 }
76 error = nfs_proc_readlink(NFS_SERVER(inode), NFS_FH(inode), &mem,
77 &res, &len, NFS_MAXPATHLEN);
78 if (error) {
79 iput(inode);
80 iput(dir);
81 kfree(mem);
82 return error;
83 }
84 while ((res2 = (char *) kmalloc(NFS_MAXPATHLEN + 1, GFP_NFS)) == NULL) {
85 schedule();
86 }
87 memcpy(res2, res, len);
88 res2[len] = '\0';
89 kfree(mem);
90 iput(inode);
91 current->link_count++;
92 error = open_namei(res2, flag, mode, res_inode, dir);
93 current->link_count--;
94 kfree_s(res2, NFS_MAXPATHLEN + 1);
95 return error;
96 }
97
98 static int nfs_readlink(struct inode *inode, char *buffer, int buflen)
99 {
100 int error, *mem;
101 unsigned int len;
102 char *res;
103
104 if (!S_ISLNK(inode->i_mode)) {
105 iput(inode);
106 return -EINVAL;
107 }
108 if (buflen > NFS_MAXPATHLEN)
109 buflen = NFS_MAXPATHLEN;
110 error = nfs_proc_readlink(NFS_SERVER(inode), NFS_FH(inode), &mem,
111 &res, &len, buflen);
112 iput(inode);
113 if (! error) {
114 memcpy_tofs(buffer, res, len);
115 put_fs_byte('\0', buffer + len);
116 error = len;
117 }
118 kfree(mem);
119 return error;
120 }