Blame view
fs/qnx4/dir.c
2.26 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 |
/* * 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 |
13 |
#include <linux/buffer_head.h> |
964f53696 fs/qnx4: sanitize... |
14 |
#include "qnx4.h" |
1da177e4c Linux-2.6.12-rc2 |
15 16 17 |
static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir) { |
24e23c24e [PATCH] struct pa... |
18 |
struct inode *inode = filp->f_path.dentry->d_inode; |
1da177e4c Linux-2.6.12-rc2 |
19 20 21 22 23 24 25 |
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... |
26 27 28 29 |
QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld ", (long) inode->i_size)); QNX4DEBUG((KERN_INFO "filp->f_pos = %ld ", (long) filp->f_pos)); |
1da177e4c Linux-2.6.12-rc2 |
30 |
|
1da177e4c Linux-2.6.12-rc2 |
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
while (filp->f_pos < inode->i_size) { blknum = qnx4_block_map( inode, filp->f_pos >> QNX4_BLOCK_SIZE_BITS ); bh = sb_bread(inode->i_sb, blknum); if(bh==NULL) { printk(KERN_ERR "qnx4_readdir: bread failed (%ld) ", blknum); break; } ix = (int)(filp->f_pos >> QNX4_DIR_ENTRY_SIZE_BITS) % QNX4_INODES_PER_BLOCK; while (ix < QNX4_INODES_PER_BLOCK) { offset = ix * QNX4_DIR_ENTRY_SIZE; de = (struct qnx4_inode_entry *) (bh->b_data + offset); size = strlen(de->di_fname); if (size) { if ( !( de->di_status & QNX4_FILE_LINK ) && size > QNX4_SHORT_NAME_MAX ) size = QNX4_SHORT_NAME_MAX; else if ( size > QNX4_NAME_MAX ) size = QNX4_NAME_MAX; if ( ( de->di_status & (QNX4_FILE_USED|QNX4_FILE_LINK) ) != 0 ) { |
891ddb95d qnx4fs: add missi... |
51 52 |
QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s ", size, de->di_fname)); |
1da177e4c Linux-2.6.12-rc2 |
53 54 55 56 |
if ( ( de->di_status & QNX4_FILE_LINK ) == 0 ) ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1; else { le = (struct qnx4_link_info*)de; |
75043cb5b [PATCH] fs/qnx4/*... |
57 |
ino = ( le32_to_cpu(le->dl_inode_blk) - 1 ) * |
1da177e4c Linux-2.6.12-rc2 |
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
QNX4_INODES_PER_BLOCK + le->dl_inode_ndx; } if (filldir(dirent, de->di_fname, size, filp->f_pos, ino, DT_UNKNOWN) < 0) { brelse(bh); goto out; } } } ix++; filp->f_pos += QNX4_DIR_ENTRY_SIZE; } brelse(bh); } out: |
1da177e4c Linux-2.6.12-rc2 |
73 74 |
return 0; } |
4b6f5d20b [PATCH] Make most... |
75 |
const struct file_operations qnx4_dir_operations = |
1da177e4c Linux-2.6.12-rc2 |
76 |
{ |
ca572727d fs/: do not fallb... |
77 |
.llseek = generic_file_llseek, |
1da177e4c Linux-2.6.12-rc2 |
78 79 |
.read = generic_read_dir, .readdir = qnx4_readdir, |
1b061d924 rename the generi... |
80 |
.fsync = generic_file_fsync, |
1da177e4c Linux-2.6.12-rc2 |
81 |
}; |
c5ef1c42c [PATCH] mark stru... |
82 |
const struct inode_operations qnx4_dir_inode_operations = |
1da177e4c Linux-2.6.12-rc2 |
83 84 |
{ .lookup = qnx4_lookup, |
1da177e4c Linux-2.6.12-rc2 |
85 |
}; |