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