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