~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/qnx4/dir.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  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 
 15 #include <linux/buffer_head.h>
 16 #include "qnx4.h"
 17 
 18 static int qnx4_readdir(struct file *file, struct dir_context *ctx)
 19 {
 20         struct inode *inode = file_inode(file);
 21         unsigned int offset;
 22         struct buffer_head *bh;
 23         unsigned long blknum;
 24         int ix, ino;
 25         int size;
 26 
 27         QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld\n", (long) inode->i_size));
 28         QNX4DEBUG((KERN_INFO "pos                 = %ld\n", (long) ctx->pos));
 29 
 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);
 33                 if (bh == NULL) {
 34                         printk(KERN_ERR "qnx4_readdir: bread failed (%ld)\n", blknum);
 35                         return 0;
 36                 }
 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;
 40                         const char *fname;
 41 
 42                         offset = ix * QNX4_DIR_ENTRY_SIZE;
 43                         de = (union qnx4_directory_entry *) (bh->b_data + offset);
 44 
 45                         fname = get_entry_fname(de, &size);
 46                         if (!fname)
 47                                 continue;
 48 
 49                         if (!(de->de_status & QNX4_FILE_LINK)) {
 50                                 ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1;
 51                         } else {
 52                                 ino = ( le32_to_cpu(de->link.dl_inode_blk) - 1 ) *
 53                                         QNX4_INODES_PER_BLOCK +
 54                                         de->link.dl_inode_ndx;
 55                         }
 56 
 57                         QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s\n", size, fname));
 58                         if (!dir_emit(ctx, fname, size, ino, DT_UNKNOWN)) {
 59                                 brelse(bh);
 60                                 return 0;
 61                         }
 62                 }
 63                 brelse(bh);
 64         }
 65         return 0;
 66 }
 67 
 68 const struct file_operations qnx4_dir_operations =
 69 {
 70         .llseek         = generic_file_llseek,
 71         .read           = generic_read_dir,
 72         .iterate_shared = qnx4_readdir,
 73         .fsync          = generic_file_fsync,
 74 };
 75 
 76 const struct inode_operations qnx4_dir_inode_operations =
 77 {
 78         .lookup         = qnx4_lookup,
 79 };
 80 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php