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