inode_manager.cc
struct inode* 
inode_manager::get_inode(uint32_t inum)
{
  struct inode *ino, *ino_disk;
  char buf[BLOCK_SIZE];

  printf("\tim: get_inode %d\n", inum);

  if (inum >= INODE_NUM) {
    printf("\tim: inum out of range\n");
    return NULL;

  }

  bm->read_block(IBLOCK(inum, bm->sb.nblocks), buf);
  // printf("%s:%d\n", __FILE__, __LINE__);

  ino_disk = (struct inode*)buf + inum%IPB;
  if (ino_disk->type == 0) {
    printf("\tim: inode not exist\n");
    return NULL;
  }

  ino = (struct inode*)malloc(sizeof(struct inode));
  *ino = *ino_disk;

  return ino;
}
/* Return an inode structure by inum, NULL otherwise.
 * Caller should release the memory. */
Return an inode structure by inum, NULL otherwise.
Caller should release the memory.
Return an inode structure by inum NULL otherwise . Caller should release the memory .
struct inode* 
inode_manager::get_inode(uint32_t inum)
{
  struct inode *ino, *ino_disk;
  char buf[BLOCK_SIZE];
  printf("\tim: get_inode %d\n", inum);
  if (inum >= INODE_NUM) {
    printf("\tim: inum out of range\n");
    return NULL;
  }
  bm->read_block(IBLOCK(inum, bm->sb.nblocks), buf);
  ino_disk = (struct inode*)buf + inum%IPB;
  if (ino_disk->type == 0) {
    printf("\tim: inode not exist\n");
    return NULL;
  }
  ino = (struct inode*)malloc(sizeof(struct inode));
  *ino = *ino_disk;
  return ino;
}
struct inode * inode_manager :: get_inode ( uint32_t inum ) { struct inode * ino , * ino_disk ; char buf [ BLOCK_SIZE ] ; printf ( " \t \n " , inum ) ; if ( inum >= INODE_NUM ) { printf ( " \t \n " ) ; return NULL ; } bm -> read_block ( IBLOCK ( inum , bm -> sb . nblocks ) , buf ) ; ino_disk = ( struct inode * ) buf + inum % IPB ; if ( ino_disk -> type == 0 ) { printf ( " \t \n " ) ; return NULL ; } ino = ( struct inode * ) malloc ( sizeof ( struct inode ) ) ; * ino = * ino_disk ; return ino ; }
Return an inode structure by inum, NULL otherwise.
Return an inode structure by inum NULL otherwise .
// printf("%s:%d\n", __FILE__, __LINE__);