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