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 NULL
39 };
40
41 static int minix_follow_link(struct inode * dir, struct inode * inode,
42 int flag, int mode, struct inode ** res_inode)
43 {
44 int error;
45 unsigned short fs;
46 struct buffer_head * bh;
47
48 *res_inode = NULL;
49 if (!dir) {
50 dir = current->root;
51 dir->i_count++;
52 }
53 if (!inode) {
54 iput(dir);
55 return -ENOENT;
56 }
57 if (!S_ISLNK(inode->i_mode)) {
58 iput(dir);
59 *res_inode = inode;
60 return 0;
61 }
62 if (current->link_count > 5) {
63 iput(inode);
64 iput(dir);
65 return -ELOOP;
66 }
67 if (!(bh = minix_bread(inode, 0, 0))) {
68 iput(inode);
69 iput(dir);
70 return -EIO;
71 }
72 iput(inode);
73 __asm__("mov %%fs,%0":"=r" (fs));
74 __asm__("mov %0,%%fs"::"r" ((unsigned short) 0x10));
75 current->link_count++;
76 error = open_namei(bh->b_data,flag,mode,res_inode,dir);
77 current->link_count--;
78 __asm__("mov %0,%%fs"::"r" (fs));
79 brelse(bh);
80 return error;
81 }
82
83 static int minix_readlink(struct inode * inode, char * buffer, int buflen)
84 {
85 struct buffer_head * bh;
86 int i;
87 char c;
88
89 if (!S_ISLNK(inode->i_mode)) {
90 iput(inode);
91 return -EINVAL;
92 }
93 if (buflen > 1023)
94 buflen = 1023;
95 bh = minix_bread(inode, 0, 0);
96 iput(inode);
97 if (!bh)
98 return 0;
99 i = 0;
100 while (i<buflen && (c = bh->b_data[i])) {
101 i++;
102 put_fs_byte(c,buffer++);
103 }
104 brelse(bh);
105 return i;
106 }