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 NULL,
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 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 while (filp->f_pos < inode->i_size) {
66 offset = filp->f_pos & 1023;
67 bh = ext_bread(inode,(filp->f_pos)>>BLOCK_SIZE_BITS,0);
68 if (!bh) {
69 filp->f_pos += 1024-offset;
70 continue;
71 }
72 de = (struct ext_dir_entry *) (offset + bh->b_data);
73 while (offset < 1024 && filp->f_pos < inode->i_size) {
74 offset += de->rec_len;
75 filp->f_pos += de->rec_len;
76 if (de->inode) {
77 for (i = 0; i < de->name_len; i++)
78 if (c = de->name[i])
79 put_fs_byte(c,i+dirent->d_name);
80 else
81 break;
82 if (i) {
83 put_fs_long(de->inode,&dirent->d_ino);
84 put_fs_byte(0,i+dirent->d_name);
85 put_fs_word(i,&dirent->d_reclen);
86 brelse(bh);
87 return i;
88 }
89 }
90 de = (struct ext_dir_entry *) ((char *) de
91 + de->rec_len);
92 }
93 brelse(bh);
94 }
95 return 0;
96 }