This source file includes following definitions.
- xiafs_dir_read
- xiafs_readdir
1
2
3
4
5
6
7
8
9
10
11
12 #ifdef MODULE
13 #include <linux/module.h>
14 #endif
15
16 #include <asm/segment.h>
17 #include <linux/sched.h>
18 #include <linux/errno.h>
19 #include <linux/kernel.h>
20 #include <linux/fs.h>
21 #include <linux/xia_fs.h>
22 #include <linux/stat.h>
23
24 #include "xiafs_mac.h"
25
26 static int xiafs_dir_read(struct inode *, struct file *, char *, int);
27 static int xiafs_readdir(struct inode *, struct file *, void *, filldir_t);
28
29 static struct file_operations xiafs_dir_operations = {
30 NULL,
31 xiafs_dir_read,
32 NULL,
33 xiafs_readdir,
34 NULL,
35 NULL,
36 NULL,
37 NULL,
38 NULL,
39 file_fsync
40 };
41
42
43
44
45 struct inode_operations xiafs_dir_inode_operations = {
46 &xiafs_dir_operations,
47 xiafs_create,
48 xiafs_lookup,
49 xiafs_link,
50 xiafs_unlink,
51 xiafs_symlink,
52 xiafs_mkdir,
53 xiafs_rmdir,
54 xiafs_mknod,
55 xiafs_rename,
56 NULL,
57 NULL,
58 NULL,
59 xiafs_truncate,
60 NULL
61 };
62
63 static int xiafs_dir_read(struct inode * inode,
64 struct file * filp, char * buf, int count)
65 {
66 return -EISDIR;
67 }
68
69 static int xiafs_readdir(struct inode * inode, struct file * filp,
70 void * dirent, filldir_t filldir)
71 {
72 u_int offset, i;
73 struct buffer_head * bh;
74 struct xiafs_direct * de;
75
76 if (!inode || !inode->i_sb || !S_ISDIR(inode->i_mode))
77 return -EBADF;
78 if (inode->i_size & (XIAFS_ZSIZE(inode->i_sb) - 1) )
79 return -EBADF;
80 while (filp->f_pos < inode->i_size) {
81 offset = filp->f_pos & (XIAFS_ZSIZE(inode->i_sb) - 1);
82 bh = xiafs_bread(inode, filp->f_pos >> XIAFS_ZSIZE_BITS(inode->i_sb),0);
83 if (!bh) {
84 filp->f_pos += XIAFS_ZSIZE(inode->i_sb)-offset;
85 continue;
86 }
87 for (i = 0; i < XIAFS_ZSIZE(inode->i_sb) && i < offset; ) {
88 de = (struct xiafs_direct *) (bh->b_data + i);
89 if (!de->d_rec_len)
90 break;
91 i += de->d_rec_len;
92 }
93 offset = i;
94 de = (struct xiafs_direct *) (offset + bh->b_data);
95
96 while (offset < XIAFS_ZSIZE(inode->i_sb) && filp->f_pos < inode->i_size) {
97 if (de->d_ino > inode->i_sb->u.xiafs_sb.s_ninodes ||
98 de->d_rec_len < 12 ||
99 (char *)de+de->d_rec_len > XIAFS_ZSIZE(inode->i_sb)+bh->b_data ||
100 de->d_name_len < 1 || de->d_name_len + 8 > de->d_rec_len ||
101 de->d_name_len > _XIAFS_NAME_LEN ||
102 de->d_name[de->d_name_len] ) {
103 printk("XIA-FS: bad directory entry (%s %d)\n", WHERE_ERR);
104 brelse(bh);
105 return 0;
106 }
107 if (de->d_ino) {
108 if (!IS_RDONLY (inode)) {
109 inode->i_atime=CURRENT_TIME;
110 inode->i_dirt=1;
111 }
112 if (filldir(dirent, de->d_name, de->d_name_len, filp->f_pos, de->d_ino) < 0) {
113 brelse(bh);
114 return 0;
115 }
116 }
117 offset += de->d_rec_len;
118 filp->f_pos += de->d_rec_len;
119 de = (struct xiafs_direct *) (offset + bh->b_data);
120 }
121 brelse(bh);
122 if (offset > XIAFS_ZSIZE(inode->i_sb)) {
123 printk("XIA-FS: bad directory (%s %d)\n", WHERE_ERR);
124 return 0;
125 }
126 }
127 if (!IS_RDONLY (inode)) {
128 inode->i_atime=CURRENT_TIME;
129 inode->i_dirt=1;
130 }
131 return 0;
132 }