Import 2.3.30pre7
[davej-history.git] / fs / qnx4 / dir.c
blob810c3accd860ebcc83a63f5572898b0662e8e832
1 /*
2 * QNX4 file system, Linux implementation.
3 *
4 * Version : 0.1
5 *
6 * Using parts of the xiafs filesystem.
7 *
8 * History :
9 *
10 * 28-05-1998 by Richard Frowijn : first release.
11 * 20-06-1998 by Frank Denis : Linux 2.1.99+ & dcache support.
14 #include <linux/config.h>
15 #include <linux/string.h>
16 #include <linux/errno.h>
17 #include <linux/fs.h>
18 #include <linux/qnx4_fs.h>
19 #include <linux/stat.h>
21 #include <asm/segment.h>
23 static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir);
25 static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir)
27 struct inode *inode = filp->f_dentry->d_inode;
28 unsigned int offset;
29 struct buffer_head *bh;
30 struct qnx4_inode_entry *de;
31 long blknum;
32 int i;
33 int size;
35 blknum = inode->u.qnx4_i.i_first_xtnt.xtnt_blk - 1 +
36 ((filp->f_pos >> 6) >> 3);
38 QNX4DEBUG(("qnx4_readdir:i_size = %ld\n", (long) inode->i_size));
39 QNX4DEBUG(("filp->f_pos = %ld\n", (long) filp->f_pos));
40 QNX4DEBUG(("BlkNum = %ld\n", (long) blknum));
42 while (filp->f_pos < inode->i_size) {
43 bh = bread(inode->i_dev, blknum, QNX4_BLOCK_SIZE);
44 if(bh==NULL)
46 printk(KERN_ERR "qnx4_readdir: bread failed (%ld)\n", blknum);
47 break;
49 i = (filp->f_pos - (((filp->f_pos >> 6) >> 3) << 9)) & 0x3f;
50 while (i < QNX4_INODES_PER_BLOCK) {
51 offset = i * QNX4_DIR_ENTRY_SIZE;
52 de = (struct qnx4_inode_entry *) (bh->b_data + offset);
53 size = strlen(de->di_fname);
54 if (size) {
56 QNX4DEBUG(("qnx4_readdir:%s\n", de->di_fname));
58 if ((de->di_mode) || (de->di_status == QNX4_FILE_LINK)) {
59 if (de->di_status) {
60 if (filldir(dirent, de->di_fname, size, filp->f_pos, de->di_first_xtnt.xtnt_blk) < 0) {
61 brelse(bh);
62 return 0;
67 i++;
68 filp->f_pos += QNX4_DIR_ENTRY_SIZE;
70 brelse(bh);
71 blknum++;
73 UPDATE_ATIME(inode);
75 return 0;
78 static struct file_operations qnx4_dir_operations =
80 NULL, /* lseek - default */
81 NULL, /* read */
82 NULL, /* write - bad */
83 qnx4_readdir, /* readdir */
84 NULL, /* poll - default */
85 NULL, /* ioctl - default */
86 NULL, /* mmap */
87 NULL, /* no special open code */
88 NULL, /* no special flush code */
89 NULL, /* no special release code */
90 file_fsync, /* default fsync */
91 NULL, /* default fasync */
92 NULL, /* default check_media_change */
93 NULL, /* default revalidate */
96 struct inode_operations qnx4_dir_inode_operations =
98 &qnx4_dir_operations,
99 #ifdef CONFIG_QNX4FS_RW
100 qnx4_create,
101 #else
102 NULL, /* create */
103 #endif
104 qnx4_lookup,
105 NULL, /* link */
106 #ifdef CONFIG_QNX4FS_RW
107 qnx4_unlink, /* unlink */
108 #else
109 NULL,
110 #endif
111 NULL, /* symlink */
112 NULL, /* mkdir */
113 #ifdef CONFIG_QNX4FS_RW
114 qnx4_rmdir, /* rmdir */
115 #else
116 NULL,
117 #endif
118 NULL, /* mknod */
119 NULL, /* rename */
120 NULL, /* readlink */
121 NULL, /* follow_link */
122 NULL, /* get_block */
123 NULL, /* readpage */
124 NULL, /* writepage */
125 NULL, /* truncate */
126 NULL, /* permission */
127 NULL /* revalidate */