This source file includes following definitions.
- ext_dir_read
- 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/kernel.h>
19 #include <linux/fs.h>
20 #include <linux/ext_fs.h>
21 #include <linux/stat.h>
22
23 static int ext_dir_read(struct inode * inode, struct file * filp, char * buf, int count)
24 {
25 return -EISDIR;
26 }
27
28 static int ext_readdir(struct inode *, struct file *, struct dirent *, int);
29
30 static struct file_operations ext_dir_operations = {
31 NULL,
32 ext_dir_read,
33 NULL,
34 ext_readdir,
35 NULL,
36 NULL,
37 NULL,
38 NULL,
39 NULL
40 };
41
42
43
44
45 struct inode_operations ext_dir_inode_operations = {
46 &ext_dir_operations,
47 ext_create,
48 ext_lookup,
49 ext_link,
50 ext_unlink,
51 ext_symlink,
52 ext_mkdir,
53 ext_rmdir,
54 ext_mknod,
55 ext_rename,
56 NULL,
57 NULL,
58 NULL,
59 ext_truncate,
60 NULL
61 };
62
63 static int ext_readdir(struct inode * inode, struct file * filp,
64 struct dirent * dirent, int count)
65 {
66 unsigned int offset,i;
67 char c;
68 struct buffer_head * bh;
69 struct ext_dir_entry * de;
70
71 if (!inode || !S_ISDIR(inode->i_mode))
72 return -EBADF;
73 if (filp->f_pos % 8 != 0)
74 return -EBADF;
75 while (filp->f_pos < inode->i_size) {
76 offset = filp->f_pos & 1023;
77 bh = ext_bread(inode,(filp->f_pos)>>BLOCK_SIZE_BITS,0);
78 if (!bh) {
79 filp->f_pos += 1024-offset;
80 continue;
81 }
82 de = (struct ext_dir_entry *) (offset + bh->b_data);
83 while (offset < 1024 && filp->f_pos < inode->i_size) {
84 if (de->rec_len < 8 || de->rec_len % 8 != 0 ||
85 de->rec_len < de->name_len + 8 ||
86 (de->rec_len + filp->f_pos - 1) / 1024 > (filp->f_pos / 1024)) {
87 printk ("ext_readdir: bad dir entry, skipping\n");
88 printk ("dev=%d, dir=%d, offset=%d, rec_len=%d, name_len=%d\n",
89 inode->i_dev, inode->i_ino, offset, de->rec_len, de->name_len);
90 filp->f_pos += 1024-offset;
91 if (filp->f_pos > inode->i_size)
92 filp->f_pos = inode->i_size;
93 continue;
94 }
95 offset += de->rec_len;
96 filp->f_pos += de->rec_len;
97 if (de->inode) {
98 for (i = 0; i < de->name_len; i++)
99 if ((c = de->name[i]) != 0)
100 put_fs_byte(c,i+dirent->d_name);
101 else
102 break;
103 if (i) {
104 put_fs_long(de->inode,&dirent->d_ino);
105 put_fs_byte(0,i+dirent->d_name);
106 put_fs_word(i,&dirent->d_reclen);
107 brelse(bh);
108 return i;
109 }
110 }
111 de = (struct ext_dir_entry *) ((char *) de
112 + de->rec_len);
113 }
114 brelse(bh);
115 }
116 return 0;
117 }