This source file includes following definitions.
- ext_readdir
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #include <asm/segment.h>
16
17 #include <linux/errno.h>
18 #include <linux/fs.h>
19 #include <linux/ext_fs.h>
20 #include <linux/stat.h>
21
22 static int ext_readdir(struct inode *, struct file *, struct dirent *, int);
23
24 static struct file_operations ext_dir_operations = {
25 NULL,
26 NULL,
27 NULL,
28 ext_readdir,
29 NULL,
30 NULL,
31 NULL,
32 NULL
33 };
34
35
36
37
38 struct inode_operations ext_dir_inode_operations = {
39 &ext_dir_operations,
40 ext_create,
41 ext_lookup,
42 ext_link,
43 ext_unlink,
44 ext_symlink,
45 ext_mkdir,
46 ext_rmdir,
47 ext_mknod,
48 ext_rename,
49 NULL,
50 NULL,
51 ext_bmap,
52 ext_truncate
53 };
54
55 static int ext_readdir(struct inode * inode, struct file * filp,
56 struct dirent * dirent, int count)
57 {
58 unsigned int block,offset,i;
59 char c;
60 struct buffer_head * bh;
61 struct ext_dir_entry * de;
62
63 if (!inode || !S_ISDIR(inode->i_mode))
64 return -EBADF;
65
66
67 while (filp->f_pos < inode->i_size) {
68 offset = filp->f_pos & 1023;
69 block = ext_bmap(inode,(filp->f_pos)>>BLOCK_SIZE_BITS);
70 if (!block || !(bh = bread(inode->i_dev, block, BLOCK_SIZE))) {
71 filp->f_pos += 1024-offset;
72 continue;
73 }
74 de = (struct ext_dir_entry *) (offset + bh->b_data);
75 while (offset < 1024 && filp->f_pos < inode->i_size) {
76 offset += de->rec_len;
77 filp->f_pos += de->rec_len;
78 if (de->inode) {
79 for (i = 0; i < de->name_len; i++)
80 if (c = de->name[i])
81 put_fs_byte(c,i+dirent->d_name);
82 else
83 break;
84 if (i) {
85 put_fs_long(de->inode,&dirent->d_ino);
86 put_fs_byte(0,i+dirent->d_name);
87 put_fs_word(i,&dirent->d_reclen);
88 brelse(bh);
89 return i;
90 }
91 }
92
93 de = (struct ext_dir_entry *) ((char *) de + de->rec_len);
94 }
95 brelse(bh);
96 }
97 return 0;
98 }