This source file includes following definitions.
- xiafs_readlink
- xiafs_follow_link
1
2
3
4
5
6
7
8
9
10
11
12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/fs.h>
15 #include <linux/xia_fs.h>
16 #include <linux/stat.h>
17
18 #include <asm/segment.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 NULL,
46 NULL
47 };
48
49 static int xiafs_readlink(struct inode * inode, char * buffer, int buflen)
50 {
51 struct buffer_head * bh;
52 int i;
53 char c;
54
55 if (!S_ISLNK(inode->i_mode)) {
56 iput(inode);
57 return -EINVAL;
58 }
59 if (buflen > BLOCK_SIZE)
60 buflen = BLOCK_SIZE;
61 bh = xiafs_bread(inode, 0, 0);
62 if (!IS_RDONLY (inode)) {
63 inode->i_atime=CURRENT_TIME;
64 inode->i_dirt=1;
65 }
66 iput(inode);
67 if (!bh)
68 return 0;
69 for (i=0; i < buflen && (c=bh->b_data[i]); i++)
70 put_user(c, buffer++);
71 if (i < buflen-1)
72 put_user('\0', buffer);
73 brelse(bh);
74 return i;
75 }
76
77 static int xiafs_follow_link(struct inode * dir, struct inode * inode,
78 int flag, int mode, struct inode ** res_inode)
79 {
80 int error;
81 struct buffer_head * bh;
82
83 *res_inode = NULL;
84 if (!dir) {
85 dir = current->fs->root;
86 dir->i_count++;
87 }
88 if (!inode) {
89 iput(dir);
90 return -ENOENT;
91 }
92 if (!S_ISLNK(inode->i_mode)) {
93 iput(dir);
94 *res_inode = inode;
95 return 0;
96 }
97 if (!IS_RDONLY (inode)) {
98 inode->i_atime=CURRENT_TIME;
99 inode->i_dirt=1;
100 }
101 if (current->link_count > 5) {
102 iput(inode);
103 iput(dir);
104 return -ELOOP;
105 }
106 if (!(bh = xiafs_bread(inode, 0, 0))) {
107 iput(inode);
108 iput(dir);
109 return -EIO;
110 }
111 iput(inode);
112 current->link_count++;
113 error = open_namei(bh->b_data,flag,mode,res_inode,dir);
114 current->link_count--;
115 brelse(bh);
116 return error;
117 }
118
119
120