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