group/pintos/src/filesys/directory.c
/* Searches DIR for a file with the given NAME.
   If successful, returns true, sets *EP to the directory entry
   if EP is non-null, and sets *OFSP to the byte offset of the
   directory entry if OFSP is non-null.
   otherwise, returns false and ignores EP and OFSP. */
Searches DIR for a file with the given NAME.
If successful, returns true, sets *EP to the directory entry
if EP is non-null, and sets *OFSP to the byte offset of the
directory entry if OFSP is non-null.
otherwise, returns false and ignores EP and OFSP.
Searches DIR for a file with the given NAME . If successful returns true sets * EP to the directory entry if EP is non - null and sets * OFSP to the byte offset of the directory entry if OFSP is non - null . otherwise returns false and ignores EP and OFSP .
static bool
lookup (const struct dir *dir, const char *name,
        struct dir_entry *ep, off_t *ofsp)
{
  struct dir_entry e;
  size_t ofs;
  ASSERT (dir != NULL);
  ASSERT (name != NULL);
  for (ofs = 0; inode_read_at (dir->inode, &e, sizeof e, ofs) == sizeof e;
       ofs += sizeof e)
    if (e.in_use && !strcmp (name, e.name))
      {
        if (ep != NULL)
          *ep = e;
        if (ofsp != NULL)
          *ofsp = ofs;
        return true;
      }
  return false;
}
static bool lookup ( const struct dir * dir , const char * name , struct dir_entry * ep , off_t * ofsp ) { struct dir_entry e ; size_t ofs ; ASSERT ( dir != NULL ) ; ASSERT ( name != NULL ) ; for ( ofs = 0 ; inode_read_at ( dir -> inode , & e , sizeof e , ofs ) == sizeof e ; ofs += sizeof e ) if ( e . in_use && ! strcmp ( name , e . name ) ) { if ( ep != NULL ) * ep = e ; if ( ofsp != NULL ) * ofsp = ofs ; return true ; } return false ; }
Searches DIR for a file with the given NAME.
Searches DIR for a file with the given NAME .