Ejemplo n.º 1
0
int hmfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
{
	struct inode *inode;
	struct hmfs_sb_info *sbi = HMFS_SB(dir->i_sb);
	void *data_blk;
	size_t symlen = strlen(symname) + 1;
	int ilock;

	if (symlen > HMFS_MAX_SYMLINK_NAME_LEN)
		return -ENAMETOOLONG;

	ilock = mutex_lock_op(sbi);
	inode = hmfs_make_dentry(dir, dentry, S_IFLNK | S_IRWXUGO);

	if (IS_ERR(inode))
		return PTR_ERR(inode);

	inode->i_op = &hmfs_symlink_inode_operations;
	inode->i_mapping->a_ops = &hmfs_dblock_aops;

	data_blk = alloc_new_data_block(inode, 0);
	if (IS_ERR(data_blk))
		return PTR_ERR(data_blk);
	hmfs_memcpy(data_blk, (void *)symname, symlen);

	mutex_unlock_op(sbi, ilock);

	d_instantiate(dentry, inode);
	unlock_new_inode(inode);

	return 0;
}
Ejemplo n.º 2
0
static int hmfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
{
	struct inode *inode;

	inode = hmfs_make_dentry(dir, dentry, S_IFDIR | mode);
	if (IS_ERR(inode))
		return PTR_ERR(inode);

	inode->i_op = &hmfs_dir_inode_operations;
	inode->i_fop = &hmfs_dir_operations;
	inode->i_mapping->a_ops = &hmfs_aops_xip;

	d_instantiate(dentry, inode);
	unlock_new_inode(inode);

	return 0;
}
Ejemplo n.º 3
0
static int hmfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
				bool excl)
{
	struct inode *inode;

	inode = hmfs_make_dentry(dir, dentry, mode);
	if (IS_ERR(inode))
		return PTR_ERR(inode);
	inode->i_op = &hmfs_file_inode_operations;
	inode->i_fop = &hmfs_file_operations;
	inode->i_mapping->a_ops = &hmfs_aops_xip;

	d_instantiate(dentry, inode);
	unlock_new_inode(inode);

	return 0;
}
Ejemplo n.º 4
0
static int hmfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
				dev_t rdev)
{
	struct inode *inode;

	if (!new_valid_dev(rdev))
		return -EINVAL;

	inode = hmfs_make_dentry(dir, dentry, mode);
	if (IS_ERR(inode))
		return PTR_ERR(inode);

	init_special_inode(inode, inode->i_mode, rdev);
	inode->i_op = &hmfs_special_inode_operations;

	d_instantiate(dentry, inode);
	unlock_new_inode(inode);

	return 0;
}