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