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 minix_truncate,
55 NULL
56 };
57
58 static int minix_readdir(struct inode * inode, struct file * filp,
59 void * dirent, filldir_t filldir)
60 {
61 unsigned int offset;
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 do {
79 de = (struct minix_dir_entry *) (offset + bh->b_data);
80 if (de->inode) {
81 int size = strnlen(de->name, info->s_namelen);
82 if (filldir(dirent, de->name, size, filp->f_pos, de->inode) < 0) {
83 brelse(bh);
84 return 0;
85 }
86 }
87 offset += info->s_dirsize;
88 filp->f_pos += info->s_dirsize;
89 } while (offset < 1024 && filp->f_pos < inode->i_size);
90 brelse(bh);
91 }
92 return 0;
93 }