This source file includes following definitions.
- xiafs_readlink
- xiafs_follow_link
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/xia_fs.h>
18 #include <linux/stat.h>
19
20 static int
21 xiafs_readlink(struct inode *, char *, int);
22
23 static int
24 xiafs_follow_link(struct inode *, struct inode *, int, int, struct inode **);
25
26
27
28
29 struct inode_operations xiafs_symlink_inode_operations = {
30 NULL,
31 NULL,
32 NULL,
33 NULL,
34 NULL,
35 NULL,
36 NULL,
37 NULL,
38 NULL,
39 NULL,
40 xiafs_readlink,
41 xiafs_follow_link,
42 NULL,
43 NULL,
44 NULL
45 };
46
47 static int xiafs_readlink(struct inode * inode, char * buffer, int buflen)
48 {
49 struct buffer_head * bh;
50 int i;
51 char c;
52
53 if (!S_ISLNK(inode->i_mode)) {
54 iput(inode);
55 return -EINVAL;
56 }
57 if (buflen > BLOCK_SIZE)
58 buflen = BLOCK_SIZE;
59 bh = xiafs_bread(inode, 0, 0);
60 if (!IS_RDONLY (inode)) {
61 inode->i_atime=CURRENT_TIME;
62 inode->i_dirt=1;
63 }
64 iput(inode);
65 if (!bh)
66 return 0;
67 for (i=0; i < buflen && (c=bh->b_data[i]); i++)
68 put_fs_byte(c, buffer++);
69 if (i < buflen-1)
70 put_fs_byte((char)0, buffer);
71 brelse(bh);
72 return i;
73 }
74
75 static int xiafs_follow_link(struct inode * dir, struct inode * inode,
76 int flag, int mode, struct inode ** res_inode)
77 {
78 int error;
79 struct buffer_head * bh;
80
81 *res_inode = NULL;
82 if (!dir) {
83 dir = current->fs->root;
84 dir->i_count++;
85 }
86 if (!inode) {
87 iput(dir);
88 return -ENOENT;
89 }
90 if (!S_ISLNK(inode->i_mode)) {
91 iput(dir);
92 *res_inode = inode;
93 return 0;
94 }
95 if (!IS_RDONLY (inode)) {
96 inode->i_atime=CURRENT_TIME;
97 inode->i_dirt=1;
98 }
99 if (current->link_count > 5) {
100 iput(inode);
101 iput(dir);
102 return -ELOOP;
103 }
104 if (!(bh = xiafs_bread(inode, 0, 0))) {
105 iput(inode);
106 iput(dir);
107 return -EIO;
108 }
109 iput(inode);
110 current->link_count++;
111 error = open_namei(bh->b_data,flag,mode,res_inode,dir);
112 current->link_count--;
113 brelse(bh);
114 return error;
115 }
116
117
118