1 // SPDX-License-Identifier: GPL-2.0
3 * QNX4 file system, Linux implementation.
7 * Using parts of the xiafs filesystem.
11 * 28-05-1998 by Richard Frowijn : first release.
12 * 20-06-1998 by Frank Denis : Linux 2.1.99+ & dcache support.
15 #include <linux/buffer_head.h>
18 static int qnx4_readdir(struct file *file, struct dir_context *ctx)
20 struct inode *inode = file_inode(file);
22 struct buffer_head *bh;
27 QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld\n", (long) inode->i_size));
28 QNX4DEBUG((KERN_INFO "pos = %ld\n", (long) ctx->pos));
30 while (ctx->pos < inode->i_size) {
31 blknum = qnx4_block_map(inode, ctx->pos >> QNX4_BLOCK_SIZE_BITS);
32 bh = sb_bread(inode->i_sb, blknum);
34 printk(KERN_ERR "qnx4_readdir: bread failed (%ld)\n", blknum);
37 ix = (ctx->pos >> QNX4_DIR_ENTRY_SIZE_BITS) % QNX4_INODES_PER_BLOCK;
38 for (; ix < QNX4_INODES_PER_BLOCK; ix++, ctx->pos += QNX4_DIR_ENTRY_SIZE) {
39 union qnx4_directory_entry *de;
42 offset = ix * QNX4_DIR_ENTRY_SIZE;
43 de = (union qnx4_directory_entry *) (bh->b_data + offset);
45 fname = get_entry_fname(de, &size);
49 if (!(de->de_status & QNX4_FILE_LINK)) {
50 ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1;
52 ino = ( le32_to_cpu(de->link.dl_inode_blk) - 1 ) *
53 QNX4_INODES_PER_BLOCK +
54 de->link.dl_inode_ndx;
57 QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s\n", size, fname));
58 if (!dir_emit(ctx, fname, size, ino, DT_UNKNOWN)) {
68 const struct file_operations qnx4_dir_operations =
70 .llseek = generic_file_llseek,
71 .read = generic_read_dir,
72 .iterate_shared = qnx4_readdir,
73 .fsync = generic_file_fsync,
76 const struct inode_operations qnx4_dir_inode_operations =
78 .lookup = qnx4_lookup,