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