ACPI: Introduce acpi_get_pci_dev()
[linux-2.6/linux-acpi-2.6.git] / fs / qnx4 / dir.c
blobea9ffefb48add56ddace16e202e80d49b97859c5
1 /*
2 * QNX4 file system, Linux implementation.
4 * Version : 0.2.1
6 * Using parts of the xiafs filesystem.
8 * History :
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/string.h>
15 #include <linux/errno.h>
16 #include <linux/fs.h>
17 #include <linux/qnx4_fs.h>
18 #include <linux/stat.h>
19 #include <linux/smp_lock.h>
20 #include <linux/buffer_head.h>
23 static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir)
25 struct inode *inode = filp->f_path.dentry->d_inode;
26 unsigned int offset;
27 struct buffer_head *bh;
28 struct qnx4_inode_entry *de;
29 struct qnx4_link_info *le;
30 unsigned long blknum;
31 int ix, ino;
32 int size;
34 QNX4DEBUG(("qnx4_readdir:i_size = %ld\n", (long) inode->i_size));
35 QNX4DEBUG(("filp->f_pos = %ld\n", (long) filp->f_pos));
37 lock_kernel();
39 while (filp->f_pos < inode->i_size) {
40 blknum = qnx4_block_map( inode, filp->f_pos >> QNX4_BLOCK_SIZE_BITS );
41 bh = sb_bread(inode->i_sb, blknum);
42 if(bh==NULL) {
43 printk(KERN_ERR "qnx4_readdir: bread failed (%ld)\n", blknum);
44 break;
46 ix = (int)(filp->f_pos >> QNX4_DIR_ENTRY_SIZE_BITS) % QNX4_INODES_PER_BLOCK;
47 while (ix < QNX4_INODES_PER_BLOCK) {
48 offset = ix * QNX4_DIR_ENTRY_SIZE;
49 de = (struct qnx4_inode_entry *) (bh->b_data + offset);
50 size = strlen(de->di_fname);
51 if (size) {
52 if ( !( de->di_status & QNX4_FILE_LINK ) && size > QNX4_SHORT_NAME_MAX )
53 size = QNX4_SHORT_NAME_MAX;
54 else if ( size > QNX4_NAME_MAX )
55 size = QNX4_NAME_MAX;
57 if ( ( de->di_status & (QNX4_FILE_USED|QNX4_FILE_LINK) ) != 0 ) {
58 QNX4DEBUG(("qnx4_readdir:%.*s\n", size, de->di_fname));
59 if ( ( de->di_status & QNX4_FILE_LINK ) == 0 )
60 ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1;
61 else {
62 le = (struct qnx4_link_info*)de;
63 ino = ( le32_to_cpu(le->dl_inode_blk) - 1 ) *
64 QNX4_INODES_PER_BLOCK +
65 le->dl_inode_ndx;
67 if (filldir(dirent, de->di_fname, size, filp->f_pos, ino, DT_UNKNOWN) < 0) {
68 brelse(bh);
69 goto out;
73 ix++;
74 filp->f_pos += QNX4_DIR_ENTRY_SIZE;
76 brelse(bh);
78 out:
79 unlock_kernel();
80 return 0;
83 const struct file_operations qnx4_dir_operations =
85 .read = generic_read_dir,
86 .readdir = qnx4_readdir,
87 .fsync = file_fsync,
90 const struct inode_operations qnx4_dir_inode_operations =
92 .lookup = qnx4_lookup,
93 #ifdef CONFIG_QNX4FS_RW
94 .create = qnx4_create,
95 .unlink = qnx4_unlink,
96 .rmdir = qnx4_rmdir,
97 #endif