cfs/test/fsproc/fsRW.cc
/**
 * allocate a new file of certain type
 * @param type
 * @return allocated inode number
 */
allocate a new file of certain type
@param type
@return allocated inode number
allocate a new file of certain type @param type @return allocated inode number
uint32_t ialloc(uint16_t type) {
  uint32_t inum = sb.next_freeinode_no;
  sb.next_freeinode_no++;
  std::cout << "ialloc next_freeinode_no:" << sb.next_freeinode_no << std::endl;
  struct cfs_dinode din;
  char imap[BSIZE];
  rsect(get_imap_start_block(), (uint8_t *)imap);
  block_set_bit(inum, imap);
  wsect(get_imap_start_block(), (uint8_t *)imap);
  bzero(&din, sizeof(din));
  din.type = type;
  din.nlink = 1;
  din.size = 0;
  din.i_no = inum;
  din.i_gid = 0;
  din.i_uid = 0;
  din.i_block_count = 0;
  din.i_dentry_count = 0;
  gettimeofday(&din.ctime, NULL);
  gettimeofday(&din.mtime, NULL);
  winode(inum, &din);
  writesb();
  return inum;
}
uint32_t ialloc ( uint16_t type ) { uint32_t inum = sb . next_freeinode_no ; sb . next_freeinode_no ++ ; std :: cout << " " << sb . next_freeinode_no << std :: endl ; struct cfs_dinode din ; char imap [ BSIZE ] ; rsect ( get_imap_start_block ( ) , ( uint8_t * ) imap ) ; block_set_bit ( inum , imap ) ; wsect ( get_imap_start_block ( ) , ( uint8_t * ) imap ) ; bzero ( & din , sizeof ( din ) ) ; din . type = type ; din . nlink = 1 ; din . size = 0 ; din . i_no = inum ; din . i_gid = 0 ; din . i_uid = 0 ; din . i_block_count = 0 ; din . i_dentry_count = 0 ; gettimeofday ( & din . ctime , NULL ) ; gettimeofday ( & din . mtime , NULL ) ; winode ( inum , & din ) ; writesb ( ) ; return inum ; }
allocate a new file of certain type
 @param type
 @return allocated inode number
allocate a new file of certain type @param type @return allocated inode number
// update imap // write inode to inode table // gettimeofday(&din.atime, NULL);