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