]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - fs/qnx4/dir.c
ext4: zero out the unused memory region in the extent tree block
[mirror_ubuntu-bionic-kernel.git] / fs / qnx4 / dir.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
1da177e4
LT
2/*
3 * QNX4 file system, Linux implementation.
4 *
5 * Version : 0.2.1
6 *
7 * Using parts of the xiafs filesystem.
8 *
9 * History :
10 *
11 * 28-05-1998 by Richard Frowijn : first release.
12 * 20-06-1998 by Frank Denis : Linux 2.1.99+ & dcache support.
13 */
14
1da177e4 15#include <linux/buffer_head.h>
964f5369 16#include "qnx4.h"
1da177e4 17
663f4dec 18static int qnx4_readdir(struct file *file, struct dir_context *ctx)
1da177e4 19{
663f4dec 20 struct inode *inode = file_inode(file);
1da177e4
LT
21 unsigned int offset;
22 struct buffer_head *bh;
23 struct qnx4_inode_entry *de;
24 struct qnx4_link_info *le;
25 unsigned long blknum;
26 int ix, ino;
27 int size;
28
891ddb95 29 QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld\n", (long) inode->i_size));
663f4dec 30 QNX4DEBUG((KERN_INFO "pos = %ld\n", (long) ctx->pos));
1da177e4 31
663f4dec
AV
32 while (ctx->pos < inode->i_size) {
33 blknum = qnx4_block_map(inode, ctx->pos >> QNX4_BLOCK_SIZE_BITS);
1da177e4 34 bh = sb_bread(inode->i_sb, blknum);
663f4dec 35 if (bh == NULL) {
1da177e4 36 printk(KERN_ERR "qnx4_readdir: bread failed (%ld)\n", blknum);
663f4dec 37 return 0;
1da177e4 38 }
663f4dec
AV
39 ix = (ctx->pos >> QNX4_DIR_ENTRY_SIZE_BITS) % QNX4_INODES_PER_BLOCK;
40 for (; ix < QNX4_INODES_PER_BLOCK; ix++, ctx->pos += QNX4_DIR_ENTRY_SIZE) {
1da177e4
LT
41 offset = ix * QNX4_DIR_ENTRY_SIZE;
42 de = (struct qnx4_inode_entry *) (bh->b_data + offset);
663f4dec
AV
43 if (!de->di_fname[0])
44 continue;
45 if (!(de->di_status & (QNX4_FILE_USED|QNX4_FILE_LINK)))
46 continue;
47 if (!(de->di_status & QNX4_FILE_LINK))
48 size = QNX4_SHORT_NAME_MAX;
49 else
50 size = QNX4_NAME_MAX;
51 size = strnlen(de->di_fname, size);
52 QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s\n", size, de->di_fname));
53 if (!(de->di_status & QNX4_FILE_LINK))
54 ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1;
55 else {
56 le = (struct qnx4_link_info*)de;
57 ino = ( le32_to_cpu(le->dl_inode_blk) - 1 ) *
58 QNX4_INODES_PER_BLOCK +
59 le->dl_inode_ndx;
60 }
61 if (!dir_emit(ctx, de->di_fname, size, ino, DT_UNKNOWN)) {
62 brelse(bh);
63 return 0;
1da177e4 64 }
1da177e4
LT
65 }
66 brelse(bh);
67 }
1da177e4
LT
68 return 0;
69}
70
4b6f5d20 71const struct file_operations qnx4_dir_operations =
1da177e4 72{
ca572727 73 .llseek = generic_file_llseek,
1da177e4 74 .read = generic_read_dir,
c51da20c 75 .iterate_shared = qnx4_readdir,
1b061d92 76 .fsync = generic_file_fsync,
1da177e4
LT
77};
78
c5ef1c42 79const struct inode_operations qnx4_dir_inode_operations =
1da177e4
LT
80{
81 .lookup = qnx4_lookup,
1da177e4 82};