static int gatorfs_fill_super(struct super_block *sb, void *data, int silent) { struct inode *root_inode; struct dentry *root_dentry; sb->s_blocksize = PAGE_CACHE_SIZE; sb->s_blocksize_bits = PAGE_CACHE_SHIFT; sb->s_magic = gatorfs_MAGIC; sb->s_op = &s_ops; sb->s_time_gran = 1; root_inode = gatorfs_get_inode(sb, S_IFDIR | 0755); if (!root_inode) return -ENOMEM; root_inode->i_op = &simple_dir_inode_operations; root_inode->i_fop = &simple_dir_operations; root_dentry = d_make_root(root_inode); if (!root_dentry) { return -ENOMEM; } sb->s_root = root_dentry; gator_op_create_files(sb, root_dentry); return 0; }
struct dentry *gatorfs_mkdir(struct super_block *sb, struct dentry *root, char const *name) { struct dentry *dentry; struct inode *inode; dentry = d_alloc_name(root, name); if (!dentry) return NULL; inode = gatorfs_get_inode(sb, S_IFDIR | 0755); if (!inode) { dput(dentry); return NULL; } inode->i_op = &simple_dir_inode_operations; inode->i_fop = &simple_dir_operations; d_add(dentry, inode); return dentry; }
static struct dentry *__gatorfs_create_file(struct super_block *sb, struct dentry *root, char const *name, const struct file_operations *fops, int perm) { struct dentry *dentry; struct inode *inode; dentry = d_alloc_name(root, name); if (!dentry) return NULL; inode = gatorfs_get_inode(sb, S_IFREG | perm); if (!inode) { dput(dentry); return NULL; } inode->i_fop = fops; d_add(dentry, inode); return dentry; }
static int gatorfs_fill_super(struct super_block *sb, void *data, int silent) { struct inode *root_inode; struct dentry *root_dentry; sb->s_blocksize = PAGE_CACHE_SIZE; sb->s_blocksize_bits = PAGE_CACHE_SHIFT; sb->s_magic = met_gatorfs_MAGIC; sb->s_op = &s_ops; sb->s_time_gran = 1; root_inode = gatorfs_get_inode(sb, S_IFDIR | 0755); if (!root_inode) return -ENOMEM; root_inode->i_op = &simple_dir_inode_operations; root_inode->i_fop = &simple_dir_operations; #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) root_dentry = d_alloc_root(root_inode); #else root_dentry = d_make_root(root_inode); #endif if (!root_dentry) { #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) iput(root_inode); #endif return -ENOMEM; } sb->s_root = root_dentry; gator_op_create_files(sb, root_dentry); return 0; }