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

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

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/efs/dir.c (Version linux-6.12-rc7) and /fs/efs/dir.c (Version linux-3.10.108)


  1 // SPDX-License-Identifier: GPL-2.0            << 
  2 /*                                                  1 /*
  3  * dir.c                                            2  * dir.c
  4  *                                                  3  *
  5  * Copyright (c) 1999 Al Smith                      4  * Copyright (c) 1999 Al Smith
  6  */                                                 5  */
  7                                                     6 
  8 #include <linux/buffer_head.h>                      7 #include <linux/buffer_head.h>
  9 #include "efs.h"                                    8 #include "efs.h"
 10                                                     9 
 11 static int efs_readdir(struct file *, struct d !!  10 static int efs_readdir(struct file *, void *, filldir_t);
 12                                                    11 
 13 const struct file_operations efs_dir_operation     12 const struct file_operations efs_dir_operations = {
 14         .llseek         = generic_file_llseek,     13         .llseek         = generic_file_llseek,
 15         .read           = generic_read_dir,        14         .read           = generic_read_dir,
 16         .iterate_shared = efs_readdir,         !!  15         .readdir        = efs_readdir,
 17 };                                                 16 };
 18                                                    17 
 19 const struct inode_operations efs_dir_inode_op     18 const struct inode_operations efs_dir_inode_operations = {
 20         .lookup         = efs_lookup,              19         .lookup         = efs_lookup,
 21 };                                                 20 };
 22                                                    21 
 23 static int efs_readdir(struct file *file, stru !!  22 static int efs_readdir(struct file *filp, void *dirent, filldir_t filldir) {
 24 {                                              !!  23         struct inode *inode = file_inode(filp);
 25         struct inode *inode = file_inode(file) !!  24         struct buffer_head *bh;
                                                   >>  25 
                                                   >>  26         struct efs_dir          *dirblock;
                                                   >>  27         struct efs_dentry       *dirslot;
                                                   >>  28         efs_ino_t               inodenum;
 26         efs_block_t             block;             29         efs_block_t             block;
 27         int                     slot;          !!  30         int                     slot, namelen;
                                                   >>  31         char                    *nameptr;
 28                                                    32 
 29         if (inode->i_size & (EFS_DIRBSIZE-1))      33         if (inode->i_size & (EFS_DIRBSIZE-1))
 30                 pr_warn("%s(): directory size  !!  34                 printk(KERN_WARNING "EFS: WARNING: readdir(): directory size not a multiple of EFS_DIRBSIZE\n");
 31                         __func__);             << 
 32                                                    35 
 33         /* work out where this entry can be fo     36         /* work out where this entry can be found */
 34         block = ctx->pos >> EFS_DIRBSIZE_BITS; !!  37         block = filp->f_pos >> EFS_DIRBSIZE_BITS;
 35                                                    38 
 36         /* each block contains at most 256 slo     39         /* each block contains at most 256 slots */
 37         slot  = ctx->pos & 0xff;               !!  40         slot  = filp->f_pos & 0xff;
 38                                                    41 
 39         /* look at all blocks */                   42         /* look at all blocks */
 40         while (block < inode->i_blocks) {          43         while (block < inode->i_blocks) {
 41                 struct efs_dir          *dirbl << 
 42                 struct buffer_head *bh;        << 
 43                                                << 
 44                 /* read the dir block */           44                 /* read the dir block */
 45                 bh = sb_bread(inode->i_sb, efs     45                 bh = sb_bread(inode->i_sb, efs_bmap(inode, block));
 46                                                    46 
 47                 if (!bh) {                         47                 if (!bh) {
 48                         pr_err("%s(): failed t !!  48                         printk(KERN_ERR "EFS: readdir(): failed to read dir block %d\n", block);
 49                                __func__, block << 
 50                         break;                     49                         break;
 51                 }                                  50                 }
 52                                                    51 
 53                 dirblock = (struct efs_dir *)      52                 dirblock = (struct efs_dir *) bh->b_data; 
 54                                                    53 
 55                 if (be16_to_cpu(dirblock->magi     54                 if (be16_to_cpu(dirblock->magic) != EFS_DIRBLK_MAGIC) {
 56                         pr_err("%s(): invalid  !!  55                         printk(KERN_ERR "EFS: readdir(): invalid directory block\n");
 57                         brelse(bh);                56                         brelse(bh);
 58                         break;                     57                         break;
 59                 }                                  58                 }
 60                                                    59 
 61                 for (; slot < dirblock->slots; !!  60                 while (slot < dirblock->slots) {
 62                         struct efs_dentry *dir !!  61                         if (dirblock->space[slot] == 0) {
 63                         efs_ino_t inodenum;    !!  62                                 slot++;
 64                         const char *nameptr;   << 
 65                         int namelen;           << 
 66                                                << 
 67                         if (dirblock->space[sl << 
 68                                 continue;          63                                 continue;
                                                   >>  64                         }
 69                                                    65 
 70                         dirslot  = (struct efs     66                         dirslot  = (struct efs_dentry *) (((char *) bh->b_data) + EFS_SLOTAT(dirblock, slot));
 71                                                    67 
 72                         inodenum = be32_to_cpu     68                         inodenum = be32_to_cpu(dirslot->inode);
 73                         namelen  = dirslot->na     69                         namelen  = dirslot->namelen;
 74                         nameptr  = dirslot->na     70                         nameptr  = dirslot->name;
 75                         pr_debug("%s(): block  << 
 76                                  __func__, blo << 
 77                                  inodenum, nam << 
 78                         if (!namelen)          << 
 79                                 continue;      << 
 80                         /* found the next entr << 
 81                         ctx->pos = (block << E << 
 82                                                    71 
 83                         /* sanity check */     !!  72 #ifdef DEBUG
 84                         if (nameptr - (char *) !!  73                         printk(KERN_DEBUG "EFS: readdir(): block %d slot %d/%d: inode %u, name \"%s\", namelen %u\n", block, slot, dirblock->slots-1, inodenum, nameptr, namelen);
 85                                 pr_warn("direc !!  74 #endif
 86                                         slot); !!  75                         if (namelen > 0) {
 87                                 continue;      !!  76                                 /* found the next entry */
 88                         }                      !!  77                                 filp->f_pos = (block << EFS_DIRBSIZE_BITS) | slot;
 89                                                !!  78 
 90                         /* copy filename and d !!  79                                 /* copy filename and data in dirslot */
 91                         if (!dir_emit(ctx, nam !!  80                                 filldir(dirent, nameptr, namelen, filp->f_pos, inodenum, DT_UNKNOWN);
                                                   >>  81 
                                                   >>  82                                 /* sanity check */
                                                   >>  83                                 if (nameptr - (char *) dirblock + namelen > EFS_DIRBSIZE) {
                                                   >>  84                                         printk(KERN_WARNING "EFS: directory entry %d exceeds directory block\n", slot);
                                                   >>  85                                         slot++;
                                                   >>  86                                         continue;
                                                   >>  87                                 }
                                                   >>  88 
                                                   >>  89                                 /* store position of next slot */
                                                   >>  90                                 if (++slot == dirblock->slots) {
                                                   >>  91                                         slot = 0;
                                                   >>  92                                         block++;
                                                   >>  93                                 }
 92                                 brelse(bh);        94                                 brelse(bh);
 93                                 return 0;      !!  95                                 filp->f_pos = (block << EFS_DIRBSIZE_BITS) | slot;
                                                   >>  96                                 goto out;
 94                         }                          97                         }
                                                   >>  98                         slot++;
 95                 }                                  99                 }
 96                 brelse(bh);                       100                 brelse(bh);
 97                                                   101 
 98                 slot = 0;                         102                 slot = 0;
 99                 block++;                          103                 block++;
100         }                                         104         }
101         ctx->pos = (block << EFS_DIRBSIZE_BITS !! 105 
                                                   >> 106         filp->f_pos = (block << EFS_DIRBSIZE_BITS) | slot;
                                                   >> 107 out:
102         return 0;                                 108         return 0;
103 }                                                 109 }
                                                   >> 110 
104                                                   111 

~ [ 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