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/buffer_head.h>
17 static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir)
19 struct inode *inode = filp->f_path.dentry->d_inode;
21 struct buffer_head *bh;
22 struct qnx4_inode_entry *de;
23 struct qnx4_link_info *le;
28 QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld\n", (long) inode->i_size));
29 QNX4DEBUG((KERN_INFO "filp->f_pos = %ld\n", (long) filp->f_pos));
31 while (filp->f_pos < inode->i_size) {
32 blknum = qnx4_block_map( inode, filp->f_pos >> QNX4_BLOCK_SIZE_BITS );
33 bh = sb_bread(inode->i_sb, blknum);
35 printk(KERN_ERR "qnx4_readdir: bread failed (%ld)\n", blknum);
38 ix = (int)(filp->f_pos >> QNX4_DIR_ENTRY_SIZE_BITS) % QNX4_INODES_PER_BLOCK;
39 while (ix < QNX4_INODES_PER_BLOCK) {
40 offset = ix * QNX4_DIR_ENTRY_SIZE;
41 de = (struct qnx4_inode_entry *) (bh->b_data + offset);
42 size = strlen(de->di_fname);
44 if ( !( de->di_status & QNX4_FILE_LINK ) && size > QNX4_SHORT_NAME_MAX )
45 size = QNX4_SHORT_NAME_MAX;
46 else if ( size > QNX4_NAME_MAX )
49 if ( ( de->di_status & (QNX4_FILE_USED|QNX4_FILE_LINK) ) != 0 ) {
50 QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s\n", size, de->di_fname));
51 if ( ( de->di_status & QNX4_FILE_LINK ) == 0 )
52 ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1;
54 le = (struct qnx4_link_info*)de;
55 ino = ( le32_to_cpu(le->dl_inode_blk) - 1 ) *
56 QNX4_INODES_PER_BLOCK +
59 if (filldir(dirent, de->di_fname, size, filp->f_pos, ino, DT_UNKNOWN) < 0) {
66 filp->f_pos += QNX4_DIR_ENTRY_SIZE;
74 const struct file_operations qnx4_dir_operations =
76 .llseek = generic_file_llseek,
77 .read = generic_read_dir,
78 .readdir = qnx4_readdir,
79 .fsync = generic_file_fsync,
82 const struct inode_operations qnx4_dir_inode_operations =
84 .lookup = qnx4_lookup,