2 * QNX4 file system, Linux implementation.
6 * Using parts of the xiafs filesystem.
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>
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 struct inode
*inode
= filp
->f_dentry
->d_inode
;
27 struct buffer_head
*bh
;
28 struct qnx4_inode_entry
*de
;
29 struct qnx4_link_info
*le
;
34 QNX4DEBUG(("qnx4_readdir:i_size = %ld\n", (long) inode
->i_size
));
35 QNX4DEBUG(("filp->f_pos = %ld\n", (long) filp
->f_pos
));
37 while (filp
->f_pos
< inode
->i_size
) {
38 blknum
= qnx4_block_map( inode
, filp
->f_pos
/ QNX4_BLOCK_SIZE
);
39 bh
= bread(inode
->i_dev
, blknum
, QNX4_BLOCK_SIZE
);
42 printk(KERN_ERR
"qnx4_readdir: bread failed (%ld)\n", blknum
);
45 ix
= (filp
->f_pos
/ QNX4_DIR_ENTRY_SIZE
- (filp
->f_pos
/ QNX4_BLOCK_SIZE
) * QNX4_INODES_PER_BLOCK
) % QNX4_INODES_PER_BLOCK
;
46 while (ix
< QNX4_INODES_PER_BLOCK
) {
47 offset
= ix
* QNX4_DIR_ENTRY_SIZE
;
48 de
= (struct qnx4_inode_entry
*) (bh
->b_data
+ offset
);
49 size
= strlen(de
->di_fname
);
51 if ( !( de
->di_status
& QNX4_FILE_LINK
) && size
> QNX4_SHORT_NAME_MAX
)
52 size
= QNX4_SHORT_NAME_MAX
;
53 else if ( size
> QNX4_NAME_MAX
)
56 if ( ( de
->di_status
& (QNX4_FILE_USED
|QNX4_FILE_LINK
) ) != 0 ) {
57 QNX4DEBUG(("qnx4_readdir:%.*s\n", size
, de
->di_fname
));
58 if ( ( de
->di_status
& QNX4_FILE_LINK
) == 0 )
59 ino
= blknum
* QNX4_INODES_PER_BLOCK
+ ix
- 1;
62 le
= (struct qnx4_link_info
*)de
;
63 ino
= ( le
->dl_inode_blk
- 1 ) *
64 QNX4_INODES_PER_BLOCK
+
67 if (filldir(dirent
, de
->di_fname
, size
, filp
->f_pos
, ino
) < 0) {
74 filp
->f_pos
+= QNX4_DIR_ENTRY_SIZE
;
83 static struct file_operations qnx4_dir_operations
=
85 readdir
: qnx4_readdir
,
89 struct inode_operations qnx4_dir_inode_operations
=
91 default_file_ops
: &qnx4_dir_operations
,
92 #ifdef CONFIG_QNX4FS_RW
96 #ifdef CONFIG_QNX4FS_RW