LJ Archive

Listing 2. Creating a New Inode

static struct inode *pcihpfs_get_inode
(struct super_block *sb, int mode, int dev)
{
   struct inode *inode = new_inode(sb);

   if (inode) {
      inode->i_mode = mode;
      inode->i_uid = current->fsuid;
      inode->i_gid = current->fsgid;
      inode->i_blksize = PAGE_CACHE_SIZE;
      inode->i_blocks = 0;
      inode->i_rdev = NODEV;
      inode->i_mapping->a_ops = &pcihpfs_aops;
      inode->i_atime = inode->i_mtime = inode->
             i_ctime = CURRENT_TIME;
      switch (mode & S_IFMT) {
      default:
         init_special_inode(inode, mode, dev);
         break;
      case S_IFREG:
         inode->i_fop = &default_file_operations;
         break;
      case S_IFDIR:
         inode->i_op = &pcihpfs_dir_inode_operations;
         inode->i_fop = &pcihpfs_dir_operations;
         break;
      }
   }
   return inode;
}
LJ Archive