This source file includes following definitions.
- minix_dir_read
- minix_readdir
1
2
3
4
5
6
7
8
9 #include <asm/segment.h>
10
11 #include <linux/errno.h>
12 #include <linux/fs.h>
13 #include <linux/minix_fs.h>
14 #include <linux/stat.h>
15
16 static int minix_dir_read(struct inode * inode, struct file * filp, char * buf, int count)
17 {
18 return -EISDIR;
19 }
20
21 static int minix_readdir(struct inode *, struct file *, struct dirent *, int);
22
23 static struct file_operations minix_dir_operations = {
24 NULL,
25 minix_dir_read,
26 NULL,
27 minix_readdir,
28 NULL,
29 NULL,
30 NULL,
31 NULL,
32 NULL,
33 NULL
34 };
35
36
37
38
39 struct inode_operations minix_dir_inode_operations = {
40 &minix_dir_operations,
41 minix_create,
42 minix_lookup,
43 minix_link,
44 minix_unlink,
45 minix_symlink,
46 minix_mkdir,
47 minix_rmdir,
48 minix_mknod,
49 minix_rename,
50 NULL,
51 NULL,
52 NULL,
53 minix_truncate,
54 NULL
55 };
56
57 static int minix_readdir(struct inode * inode, struct file * filp,
58 struct dirent * dirent, int count)
59 {
60 unsigned int offset,i;
61 char c;
62 struct buffer_head * bh;
63 struct minix_dir_entry * de;
64 struct minix_sb_info * info;
65
66 if (!inode || !inode->i_sb || !S_ISDIR(inode->i_mode))
67 return -EBADF;
68 info = &inode->i_sb->u.minix_sb;
69 if (filp->f_pos & (info->s_dirsize - 1))
70 return -EBADF;
71 while (filp->f_pos < inode->i_size) {
72 offset = filp->f_pos & 1023;
73 bh = minix_bread(inode,(filp->f_pos)>>BLOCK_SIZE_BITS,0);
74 if (!bh) {
75 filp->f_pos += 1024-offset;
76 continue;
77 }
78 while (offset < 1024 && filp->f_pos < inode->i_size) {
79 de = (struct minix_dir_entry *) (offset + bh->b_data);
80 offset += info->s_dirsize;
81 filp->f_pos += info->s_dirsize;
82 if (de->inode) {
83 for (i = 0; i < info->s_namelen; i++)
84 if ((c = de->name[i]) != 0)
85 put_fs_byte(c,i+dirent->d_name);
86 else
87 break;
88 if (i) {
89 put_fs_long(de->inode,&dirent->d_ino);
90 put_fs_byte(0,i+dirent->d_name);
91 put_fs_word(i,&dirent->d_reclen);
92 brelse(bh);
93 return i;
94 }
95 }
96 }
97 brelse(bh);
98 }
99 return 0;
100 }