Blame view
fs/qnx4/dir.c
2.17 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 7 8 9 10 11 12 13 |
/* * QNX4 file system, Linux implementation. * * Version : 0.2.1 * * Using parts of the xiafs filesystem. * * History : * * 28-05-1998 by Richard Frowijn : first release. * 20-06-1998 by Frank Denis : Linux 2.1.99+ & dcache support. */ |
1da177e4c Linux-2.6.12-rc2 |
14 |
#include <linux/buffer_head.h> |
964f53696 fs/qnx4: sanitize... |
15 |
#include "qnx4.h" |
1da177e4c Linux-2.6.12-rc2 |
16 |
|
663f4deca [readdir] convert... |
17 |
static int qnx4_readdir(struct file *file, struct dir_context *ctx) |
1da177e4c Linux-2.6.12-rc2 |
18 |
{ |
663f4deca [readdir] convert... |
19 |
struct inode *inode = file_inode(file); |
1da177e4c Linux-2.6.12-rc2 |
20 21 22 23 24 25 26 |
unsigned int offset; struct buffer_head *bh; struct qnx4_inode_entry *de; struct qnx4_link_info *le; unsigned long blknum; int ix, ino; int size; |
891ddb95d qnx4fs: add missi... |
27 28 |
QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld ", (long) inode->i_size)); |
663f4deca [readdir] convert... |
29 30 |
QNX4DEBUG((KERN_INFO "pos = %ld ", (long) ctx->pos)); |
1da177e4c Linux-2.6.12-rc2 |
31 |
|
663f4deca [readdir] convert... |
32 33 |
while (ctx->pos < inode->i_size) { blknum = qnx4_block_map(inode, ctx->pos >> QNX4_BLOCK_SIZE_BITS); |
1da177e4c Linux-2.6.12-rc2 |
34 |
bh = sb_bread(inode->i_sb, blknum); |
663f4deca [readdir] convert... |
35 |
if (bh == NULL) { |
1da177e4c Linux-2.6.12-rc2 |
36 37 |
printk(KERN_ERR "qnx4_readdir: bread failed (%ld) ", blknum); |
663f4deca [readdir] convert... |
38 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
39 |
} |
663f4deca [readdir] convert... |
40 41 |
ix = (ctx->pos >> QNX4_DIR_ENTRY_SIZE_BITS) % QNX4_INODES_PER_BLOCK; for (; ix < QNX4_INODES_PER_BLOCK; ix++, ctx->pos += QNX4_DIR_ENTRY_SIZE) { |
1da177e4c Linux-2.6.12-rc2 |
42 43 |
offset = ix * QNX4_DIR_ENTRY_SIZE; de = (struct qnx4_inode_entry *) (bh->b_data + offset); |
663f4deca [readdir] convert... |
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
if (!de->di_fname[0]) continue; if (!(de->di_status & (QNX4_FILE_USED|QNX4_FILE_LINK))) continue; if (!(de->di_status & QNX4_FILE_LINK)) size = QNX4_SHORT_NAME_MAX; else size = QNX4_NAME_MAX; size = strnlen(de->di_fname, size); QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s ", size, de->di_fname)); if (!(de->di_status & QNX4_FILE_LINK)) ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1; else { le = (struct qnx4_link_info*)de; ino = ( le32_to_cpu(le->dl_inode_blk) - 1 ) * QNX4_INODES_PER_BLOCK + le->dl_inode_ndx; } if (!dir_emit(ctx, de->di_fname, size, ino, DT_UNKNOWN)) { brelse(bh); return 0; |
1da177e4c Linux-2.6.12-rc2 |
66 |
} |
1da177e4c Linux-2.6.12-rc2 |
67 68 69 |
} brelse(bh); } |
1da177e4c Linux-2.6.12-rc2 |
70 71 |
return 0; } |
4b6f5d20b [PATCH] Make most... |
72 |
const struct file_operations qnx4_dir_operations = |
1da177e4c Linux-2.6.12-rc2 |
73 |
{ |
ca572727d fs/: do not fallb... |
74 |
.llseek = generic_file_llseek, |
1da177e4c Linux-2.6.12-rc2 |
75 |
.read = generic_read_dir, |
c51da20c4 more trivial ->it... |
76 |
.iterate_shared = qnx4_readdir, |
1b061d924 rename the generi... |
77 |
.fsync = generic_file_fsync, |
1da177e4c Linux-2.6.12-rc2 |
78 |
}; |
c5ef1c42c [PATCH] mark stru... |
79 |
const struct inode_operations qnx4_dir_inode_operations = |
1da177e4c Linux-2.6.12-rc2 |
80 81 |
{ .lookup = qnx4_lookup, |
1da177e4c Linux-2.6.12-rc2 |
82 |
}; |