This source file includes following definitions.
- sysv_dir_read
- sysv_readdir
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #ifdef MODULE
17 #include <linux/module.h>
18 #endif
19
20 #include <asm/segment.h>
21
22 #include <linux/errno.h>
23 #include <linux/fs.h>
24 #include <linux/sysv_fs.h>
25 #include <linux/stat.h>
26
27 static int sysv_dir_read(struct inode * inode, struct file * filp, char * buf, int count)
28 {
29 return -EISDIR;
30 }
31
32 static int sysv_readdir(struct inode *, struct file *, void *, filldir_t);
33
34 static struct file_operations sysv_dir_operations = {
35 NULL,
36 sysv_dir_read,
37 NULL,
38 sysv_readdir,
39 NULL,
40 NULL,
41 NULL,
42 NULL,
43 NULL,
44 file_fsync
45 };
46
47
48
49
50 struct inode_operations sysv_dir_inode_operations = {
51 &sysv_dir_operations,
52 sysv_create,
53 sysv_lookup,
54 sysv_link,
55 sysv_unlink,
56 sysv_symlink,
57 sysv_mkdir,
58 sysv_rmdir,
59 sysv_mknod,
60 sysv_rename,
61 NULL,
62 NULL,
63 NULL,
64 sysv_truncate,
65 NULL
66 };
67
68 static int sysv_readdir(struct inode * inode, struct file * filp,
69 void * dirent, filldir_t filldir)
70 {
71 struct super_block * sb;
72 unsigned int offset,i;
73 struct buffer_head * bh;
74 char* bh_data;
75 struct sysv_dir_entry * de, sde;
76
77 if (!inode || !(sb = inode->i_sb) || !S_ISDIR(inode->i_mode))
78 return -EBADF;
79 if ((unsigned long)(filp->f_pos) % SYSV_DIRSIZE)
80 return -EBADF;
81 while (filp->f_pos < inode->i_size) {
82 offset = filp->f_pos & sb->sv_block_size_1;
83 bh = sysv_file_bread(inode, filp->f_pos >> sb->sv_block_size_bits, 0);
84 if (!bh) {
85 filp->f_pos += sb->sv_block_size - offset;
86 continue;
87 }
88 bh_data = bh->b_data;
89 while (offset < sb->sv_block_size && filp->f_pos < inode->i_size) {
90 de = (struct sysv_dir_entry *) (offset + bh_data);
91 if (de->inode) {
92
93
94
95 memcpy(&sde, de, sizeof(struct sysv_dir_entry));
96
97 if (sde.inode > inode->i_sb->sv_ninodes)
98 printk("sysv_readdir: Bad inode number on dev 0x%04x, ino %ld, offset 0x%04lx: %d is out of range\n",
99 inode->i_dev, inode->i_ino, (off_t) filp->f_pos, sde.inode);
100
101 i = strnlen(sde.name, SYSV_NAMELEN);
102 if (filldir(dirent, sde.name, i, filp->f_pos, sde.inode) < 0) {
103 brelse(bh);
104 return 0;
105 }
106 }
107 offset += SYSV_DIRSIZE;
108 filp->f_pos += SYSV_DIRSIZE;
109 }
110 brelse(bh);
111 }
112 return 0;
113 }