This source file includes following definitions.
- isofs_follow_link
- isofs_readlink
1
2
3
4
5
6
7
8
9
10
11
12 #include <asm/segment.h>
13
14 #include <linux/errno.h>
15 #include <linux/sched.h>
16 #include <linux/fs.h>
17 #include <linux/iso_fs.h>
18 #include <linux/stat.h>
19
20 static int isofs_readlink(struct inode *, char *, int);
21 static int isofs_follow_link(struct inode *, struct inode *, int, int, struct inode **);
22
23
24
25
26 struct inode_operations isofs_symlink_inode_operations = {
27 NULL,
28 NULL,
29 NULL,
30 NULL,
31 NULL,
32 NULL,
33 NULL,
34 NULL,
35 NULL,
36 NULL,
37 isofs_readlink,
38 isofs_follow_link,
39 NULL,
40 NULL,
41 NULL
42 };
43
44 static int isofs_follow_link(struct inode * dir, struct inode * inode,
45 int flag, int mode, struct inode ** res_inode)
46 {
47 int error;
48 char * pnt;
49
50 if (!dir) {
51 dir = current->root;
52 dir->i_count++;
53 }
54 if (!inode) {
55 iput(dir);
56 *res_inode = NULL;
57 return -ENOENT;
58 }
59 if (!S_ISLNK(inode->i_mode)) {
60 iput(dir);
61 *res_inode = inode;
62 return 0;
63 }
64 if ((current->link_count > 5) ||
65 !(pnt = get_rock_ridge_symlink(inode))) {
66 iput(dir);
67 iput(inode);
68 *res_inode = NULL;
69 return -ELOOP;
70 }
71 iput(inode);
72 current->link_count++;
73 error = open_namei(pnt,flag,mode,res_inode,dir);
74 current->link_count--;
75 kfree(pnt);
76 return error;
77 }
78
79 static int isofs_readlink(struct inode * inode, char * buffer, int buflen)
80 {
81 char * pnt;
82 int i;
83 char c;
84
85 if (!S_ISLNK(inode->i_mode)) {
86 iput(inode);
87 return -EINVAL;
88 }
89
90 if (buflen > 1023)
91 buflen = 1023;
92 pnt = get_rock_ridge_symlink(inode);
93
94 iput(inode);
95 if (!pnt)
96 return 0;
97 i = 0;
98
99 while (i<buflen && (c = pnt[i])) {
100 i++;
101 put_fs_byte(c,buffer++);
102 }
103 kfree(pnt);
104 return i;
105 }