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