Exemple #1
0
static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
{
	struct inode *inode = dentry->d_inode;
	struct nilfs_transaction_info ti;
	int err;

	err = nilfs_transaction_begin(dir->i_sb, &ti, 0);
	if (err)
		return err;

	err = -ENOTEMPTY;
	if (nilfs_empty_dir(inode)) {
		err = nilfs_unlink(dir, dentry);
		if (!err) {
			inode->i_size = 0;
			inode_dec_link_count(inode);
			inode_dec_link_count(dir);
		}
	}
	if (!err)
		err = nilfs_transaction_commit(dir->i_sb);
	else
		nilfs_transaction_abort(dir->i_sb);

	return err;
}
Exemple #2
0
static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode)
{
	struct inode * inode;
	int err;

	inode_inc_link_count(dir);

	inode = minix_new_inode(dir, S_IFDIR | mode, &err);
	if (!inode)
		goto out_dir;

	minix_set_inode(inode, 0);

	inode_inc_link_count(inode);

	err = minix_make_empty(inode, dir);
	if (err)
		goto out_fail;

	err = minix_add_link(dentry, inode);
	if (err)
		goto out_fail;

	d_instantiate(dentry, inode);
out:
	return err;

out_fail:
	inode_dec_link_count(inode);
	inode_dec_link_count(inode);
	iput(inode);
out_dir:
	inode_dec_link_count(dir);
	goto out;
}
Exemple #3
0
static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{
	struct inode *inode;
	struct nilfs_transaction_info ti;
	int err;

	if (dir->i_nlink >= NILFS_LINK_MAX)
		return -EMLINK;

	err = nilfs_transaction_begin(dir->i_sb, &ti, 1);
	if (err)
		return err;

	inode_inc_link_count(dir);

	inode = nilfs_new_inode(dir, S_IFDIR | mode);
	err = PTR_ERR(inode);
	if (IS_ERR(inode))
		goto out_dir;

	inode->i_op = &nilfs_dir_inode_operations;
	inode->i_fop = &nilfs_dir_operations;
	inode->i_mapping->a_ops = &nilfs_aops;

	inode_inc_link_count(inode);

	err = nilfs_make_empty(inode, dir);
	if (err)
		goto out_fail;

	err = nilfs_add_link(dentry, inode);
	if (err)
		goto out_fail;

	d_instantiate(dentry, inode);
out:
	if (!err)
		err = nilfs_transaction_commit(dir->i_sb);
	else
		nilfs_transaction_abort(dir->i_sb);

	return err;

out_fail:
	inode_dec_link_count(inode);
	inode_dec_link_count(inode);
	iput(inode);
out_dir:
	inode_dec_link_count(dir);
	goto out;
}
Exemple #4
0
static int minix_rmdir(struct inode * dir, struct dentry *dentry)
{
	struct inode * inode = dentry->d_inode;
	int err = -ENOTEMPTY;

	if (minix_empty_dir(inode)) {
		err = minix_unlink(dir, dentry);
		if (!err) {
			inode_dec_link_count(dir);
			inode_dec_link_count(inode);
		}
	}
	return err;
}
Exemple #5
0
static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
{
    struct inode * inode = dentry->d_inode;
    int err = -ENOTEMPTY;

    if (ext2_empty_dir(inode)) {
        err = ext2_unlink(dir, dentry);
        if (!err) {
            inode->i_size = 0;
            inode_dec_link_count(inode);
            inode_dec_link_count(dir);
        }
    }
    return err;
}
Exemple #6
0
static int tux3_link(struct dentry *old_dentry, struct inode *dir,
		     struct dentry *dentry)
{
	if(DEBUG_MODE_K==1)
	{
		printf("\t\t\t\t%25s[K]  %25s  %4d  #in\n",__FILE__,__func__,__LINE__);
	}
	struct inode *inode = old_dentry->d_inode;
	struct sb *sb = tux_sb(inode->i_sb);
	int err;

	if (inode->i_nlink >= TUX_LINK_MAX)
		return -EMLINK;

	change_begin(sb);
	tux3_iattrdirty(inode);
	inode->i_ctime = gettime();
	inode_inc_link_count(inode);
	ihold(inode);
	err = tux_add_dirent(dir, dentry, inode);
	if (err) {
		inode_dec_link_count(inode);
		iput(inode);
	}
	change_end(sb);

	return err;
}
Exemple #7
0
static int __tux3_symlink(struct inode *dir, struct dentry *dentry,
			  struct tux_iattr *iattr, const char *symname)
{
	struct sb *sb = tux_sb(dir->i_sb);
	struct inode *inode;
	unsigned len = strlen(symname) + 1;
	int err;

	/* FIXME: We want more length? */
	if (len > PAGE_CACHE_SIZE)
		return -ENAMETOOLONG;

	change_begin(sb);
	inode = tux_create_inode(dir, iattr, 0);
	err = PTR_ERR(inode);
	if (!IS_ERR(inode)) {
		err = page_symlink(inode, symname, len);
		if (!err) {
			err = tux_add_dirent(dir, dentry, inode);
			if (!err)
				goto out;
		}
		inode_dec_link_count(inode);
		iput(inode);
	}
out:
	change_end(sb);

	return err;
}
Exemple #8
0
static int simplefs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) {
	struct inode *inode = NULL;
	long ino;
	int err = 0;

	ino = bitmap_alloc_inode(dir->i_sb);
	if (ino < 0)
		return -EIO;
	inode = simplefs_iget(dir->i_sb, ino);
	if (IS_ERR(inode))
		return -EIO;

	inode->i_state = 0;
	inode->i_mode = mode | S_IFREG;
	inode->i_nlink = 1;
	inode->i_size = inode->i_blocks = inode->i_bytes = 0;
	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
	mark_inode_dirty(inode);
	err = simplefs_insert_dentry(dentry, inode);
	if (!err) {
		//dentry->d_op = &d_op;
		d_instantiate(dentry, inode);
		if (inode) {
			printk(KERN_INFO "simplefs_create: dentry %d", dentry->d_count.counter);
			printk(KERN_INFO "simplefs_create: inode %ld %ld %d %d", inode->i_ino, inode->i_state, inode->i_count.counter, inode->i_nlink);
		}

		return 0;
	}
	inode_dec_link_count(inode);
	iput(inode);
	return err;
}
Exemple #9
0
int uxfs_dirdel(struct inode *dip, char *name)
{
	struct uxfs_inode *uip = (struct uxfs_inode *)
	    dip->i_private;
	struct buffer_head *bh;
	struct super_block *sb = dip->i_sb;
	struct uxfs_dirent *dirent;
	__u32 blk = 0;
	int i;

	while (blk < uip->i_blocks) {
		bh = sb_bread(sb, uip->i_addr[blk]);
		blk++;
		dirent = (struct uxfs_dirent *)bh->b_data;
		for (i = 0; i < UXFS_DIRS_PER_BLOCK; i++) {
			if (strcmp(dirent->d_name, name) != 0) {
				dirent++;
				continue;
			} else {
				dirent->d_ino = 0;
				dirent->d_name[0] = '\0';
				mark_buffer_dirty(bh);	//unnecessary??
				inode_dec_link_count(dip);
				//      mark_inode_dirty(dip); redundant
				break;
			}
		}
		brelse(bh);
	}
	return 0;
}
Exemple #10
0
static int nilfs_link(struct dentry *old_dentry, struct inode *dir,
		      struct dentry *dentry)
{
	struct inode *inode = d_inode(old_dentry);
	struct nilfs_transaction_info ti;
	int err;

	err = nilfs_transaction_begin(dir->i_sb, &ti, 1);
	if (err)
		return err;

	inode->i_ctime = current_time(inode);
	inode_inc_link_count(inode);
	ihold(inode);

	err = nilfs_add_link(dentry, inode);
	if (!err) {
		d_instantiate(dentry, inode);
		err = nilfs_transaction_commit(dir->i_sb);
	} else {
		inode_dec_link_count(inode);
		iput(inode);
		nilfs_transaction_abort(dir->i_sb);
	}

	return err;
}
Exemple #11
0
static int sysv_symlink(struct inode * dir, struct dentry * dentry,
                        const char * symname)
{
    int err = -ENAMETOOLONG;
    int l = strlen(symname)+1;
    struct inode * inode;

    if (l > dir->i_sb->s_blocksize)
        goto out;

    inode = sysv_new_inode(dir, S_IFLNK|0777);
    err = PTR_ERR(inode);
    if (IS_ERR(inode))
        goto out;

    sysv_set_inode(inode, 0);
    err = page_symlink(inode, symname, l);
    if (err)
        goto out_fail;

    mark_inode_dirty(inode);
    err = add_nondir(dentry, inode);
out:
    return err;

out_fail:
    inode_dec_link_count(inode);
    iput(inode);
    goto out;
}
Exemple #12
0
static int minix_symlink(struct inode * dir, struct dentry *dentry,
	  const char * symname)
{
	int err = -ENAMETOOLONG;
	int i = strlen(symname)+1;
	struct inode * inode;

	if (i > dir->i_sb->s_blocksize)
		goto out;

	inode = minix_new_inode(dir, S_IFLNK | 0777, &err);
	if (!inode)
		goto out;

	minix_set_inode(inode, 0);
	err = page_symlink(inode, symname, i);
	if (err)
		goto out_fail;

	err = add_nondir(dentry, inode);
out:
	return err;

out_fail:
	inode_dec_link_count(inode);
	iput(inode);
	goto out;
}
/*
==================================================================================
	Function	:me2fsUnlink
	Input		:struct inode *dir
				 < vfs inode of parent >
				 struct dentry *dentry
				 < name of file >
	Output		:void
	Return		:int
				 < result >

	Description	:unlink a file
==================================================================================
*/
static int
me2fsUnlink( struct inode *dir, struct dentry *dentry )
{
	struct inode			*inode;
	struct ext2_dir_entry	*dent;
	struct page				*page;
	int						err;

	if( !( dent = me2fsFindDirEntry( dir, &dentry->d_name, &page ) ) )
	{
		return( -ENOENT );
	}

	if( ( err = me2fsDeleteDirEntry( dent, page ) ) )
	{
		return( err );
	}

	inode			= dentry->d_inode;
	inode->i_ctime	= dir->i_ctime;
	inode_dec_link_count( inode );

	return( 0 );


}
Exemple #14
0
static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
{
	struct inode * inode = dentry->d_inode;
	int err= -ENOTEMPTY;

	lock_kernel();
	if (ufs_empty_dir (inode)) {
		err = ufs_unlink(dir, dentry);
		if (!err) {
			inode->i_size = 0;
			inode_dec_link_count(inode);
			inode_dec_link_count(dir);
		}
	}
	unlock_kernel();
	return err;
}
static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
{
	struct inode * inode;
	int err = -EMLINK;

	if (dir->i_nlink >= UFS_LINK_MAX)
		goto out;

	dquot_initialize(dir);

	lock_kernel();
	inode_inc_link_count(dir);

	inode = ufs_new_inode(dir, S_IFDIR|mode);
	err = PTR_ERR(inode);
	if (IS_ERR(inode))
		goto out_dir;

	inode->i_op = &ufs_dir_inode_operations;
	inode->i_fop = &ufs_dir_operations;
	inode->i_mapping->a_ops = &ufs_aops;

	inode_inc_link_count(inode);

	err = ufs_make_empty(inode, dir);
	if (err)
		goto out_fail;

	err = ufs_add_link(dentry, inode);
	if (err)
		goto out_fail;
	unlock_kernel();

	d_instantiate(dentry, inode);
out:
	return err;

out_fail:
	inode_dec_link_count(inode);
	inode_dec_link_count(inode);
	iput (inode);
out_dir:
	inode_dec_link_count(dir);
	unlock_kernel();
	goto out;
}
Exemple #16
0
static int ext2_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
{
    struct inode * inode;
    int err;

    dquot_initialize(dir);

    inode_inc_link_count(dir);

    inode = ext2_new_inode(dir, S_IFDIR | mode, &dentry->d_name);
    err = PTR_ERR(inode);
    if (IS_ERR(inode))
        goto out_dir;

    inode->i_op = &ext2_dir_inode_operations;
    inode->i_fop = &ext2_dir_operations;
    if (test_opt(inode->i_sb, NOBH))
        inode->i_mapping->a_ops = &ext2_nobh_aops;
    else
        inode->i_mapping->a_ops = &ext2_aops;

    inode_inc_link_count(inode);

    err = ext2_make_empty(inode, dir);
    if (err)
        goto out_fail;

    err = ext2_add_link(dentry, inode);
    if (err)
        goto out_fail;

    unlock_new_inode(inode);
    d_instantiate(dentry, inode);
out:
    return err;

out_fail:
    inode_dec_link_count(inode);
    inode_dec_link_count(inode);
    unlock_new_inode(inode);
    iput(inode);
out_dir:
    inode_dec_link_count(dir);
    goto out;
}
Exemple #17
0
static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
{
    struct inode * inode;
    int err = -EMLINK;

    if (dir->i_nlink >= EXT2_LINK_MAX)
        goto out;

    inode_inc_link_count(dir);

    inode = ext2_new_inode (dir, S_IFDIR | mode);
    err = PTR_ERR(inode);
    if (IS_ERR(inode))
        goto out_dir;

    inode->i_op = &ext2_dir_inode_operations;
    inode->i_fop = &ext2_dir_operations;
    if (test_opt(inode->i_sb, NOBH))
        inode->i_mapping->a_ops = &ext2_nobh_aops;
    else
        inode->i_mapping->a_ops = &ext2_aops;

    inode_inc_link_count(inode);

    err = ext2_make_empty(inode, dir);
    if (err)
        goto out_fail;

    err = ext2_add_link(dentry, inode);
    if (err)
        goto out_fail;

    d_instantiate(dentry, inode);
out:
    return err;

out_fail:
    inode_dec_link_count(inode);
    inode_dec_link_count(inode);
    iput(inode);
out_dir:
    inode_dec_link_count(dir);
    goto out;
}
static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
{
	struct inode * inode;
	int err;

	lock_ufs(dir->i_sb);
	inode_inc_link_count(dir);

	inode = ufs_new_inode(dir, S_IFDIR|mode);
	err = PTR_ERR(inode);
	if (IS_ERR(inode))
		goto out_dir;

	inode->i_op = &ufs_dir_inode_operations;
	inode->i_fop = &ufs_dir_operations;
	inode->i_mapping->a_ops = &ufs_aops;

	inode_inc_link_count(inode);

	err = ufs_make_empty(inode, dir);
	if (err)
		goto out_fail;

	err = ufs_add_link(dentry, inode);
	if (err)
		goto out_fail;
	unlock_ufs(dir->i_sb);

	unlock_new_inode(inode);
	d_instantiate(dentry, inode);
out:
	return err;

out_fail:
	inode_dec_link_count(inode);
	inode_dec_link_count(inode);
	unlock_new_inode(inode);
	iput (inode);
out_dir:
	inode_dec_link_count(dir);
	unlock_ufs(dir->i_sb);
	goto out;
}
/*
==================================================================================
	Function	:me2fsSymlink
	Input		:struct inode *dir
				 < vfs inode of parent >
				 struct dentry *dentry
				 < new linked file >
				 const char *symname
				 < symbolic link path >
	Output		:void
	Return		:void

	Description	:make a symbolic link
==================================================================================
*/
static int
me2fsSymlink( struct inode *dir,
			  struct dentry *dentry,
			  const char *symname )
{
	struct super_block	*sb;
	int					err;
	unsigned			len;
	struct inode		*inode;

	sb	= dir->i_sb;
	len	= strlen( symname ) + 1;

	if( sb->s_blocksize < len )
	{
		return( -ENAMETOOLONG );
	}

	inode = me2fsAllocNewInode( dir, S_IFLNK | S_IRWXUGO, &dentry->d_name );

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

	/* ------------------------------------------------------------------------ */
	/* slow symlink																*/
	/* ------------------------------------------------------------------------ */
	if( sizeof( ME2FS_I( inode )->i_data ) < len )
	{
		inode->i_op				= &me2fs_symlink_inode_operations;
		inode->i_mapping->a_ops	= &me2fs_aops;
		if( ( err = page_symlink( inode, symname, len ) ) )
		{
			inode_dec_link_count( inode );
			unlock_new_inode( inode );
			iput( inode );
			return( err );
		}
	}
	/* ------------------------------------------------------------------------ */
	/* fast symlink																*/
	/* ------------------------------------------------------------------------ */
	else
	{
		inode->i_op				= &me2fs_fast_symlink_inode_operations;
		memcpy( ( char* )( ME2FS_I( inode )->i_data ), symname, len );
		inode->i_size = len - 1;
	}

	mark_inode_dirty( inode );

	return( addNonDir( dentry, inode ) );
}
Exemple #20
0
static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
{
	int err = ufs_add_link(dentry, inode);
	if (!err) {
		d_instantiate(dentry, inode);
		return 0;
	}
	inode_dec_link_count(inode);
	iput(inode);
	return err;
}
Exemple #21
0
static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode)
{
	struct inode * inode;
	int err = -EMLINK;

	if (dir->i_nlink >= minix_sb(dir->i_sb)->s_link_max)
		goto out;

	inode_inc_link_count(dir);

	inode = minix_new_inode(dir, &err);
	if (!inode)
		goto out_dir;

	inode->i_mode = S_IFDIR | mode;
	if (dir->i_mode & S_ISGID)
		inode->i_mode |= S_ISGID;
	minix_set_inode(inode, 0);

	inode_inc_link_count(inode);

	err = minix_make_empty(inode, dir);
	if (err)
		goto out_fail;

	err = minix_add_link(dentry, inode);
	if (err)
		goto out_fail;

	d_instantiate(dentry, inode);
out:
	return err;

out_fail:
	inode_dec_link_count(inode);
	inode_dec_link_count(inode);
	iput(inode);
out_dir:
	inode_dec_link_count(dir);
	goto out;
}
/*
==================================================================================
	Function	:me2fsRmdir
	Input		:struct inode *dir
				 < vfs inode of parent >
				 struct dentry *dentry
				 < name of directory >
	Output		:void
	Return		:int
				 < result >

	Description	:remove directory
==================================================================================
*/
static int
me2fsRmdir( struct inode *dir, struct dentry *dentry )
{
	struct inode	*inode;
	int				err;

	err		= -ENOTEMPTY;
	inode	= dentry->d_inode;

	if( me2fsIsEmptyDir( inode ) )
	{
		if( !( err = me2fsUnlink( dir, dentry ) ) )
		{
			inode->i_size = 0;
			inode_dec_link_count( inode );
			inode_dec_link_count( dir );
		}
	}

	return( err );
}
Exemple #23
0
static int tux3_unlink(struct inode *dir, struct dentry *dentry)
{
	struct inode *inode = dentry->d_inode;

	change_begin(tux_sb(inode->i_sb));
	int err = tux_del_dirent(dir, dentry);
	if (!err) {
		inode->i_ctime = dir->i_ctime;
		inode_dec_link_count(inode);
	}
	change_end(tux_sb(inode->i_sb));
	return err;
}
Exemple #24
0
static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
{
    int err = ext2_add_link(dentry, inode);
    if (!err) {
        unlock_new_inode(inode);
        d_instantiate(dentry, inode);
        return 0;
    }
    inode_dec_link_count(inode);
    unlock_new_inode(inode);
    iput(inode);
    return err;
}
Exemple #25
0
static int replayfs_rmdir(struct inode *dir, struct dentry *dentry) {
	struct inode *inode;
	int err;

	inode = dentry->d_inode;
	err = -ENOTEMPTY;
	
	/* NOTE: Don't need to start log operation here, that is handled in unlink */

	if (replayfs_dir_is_empty(inode)) {
		err = replayfs_unlink(dir, dentry);
		/* If we were successful */
		if (!err) {
			/* Clear this inode, and decrement our link counts */
			inode->i_size = 0;
			inode_dec_link_count(inode);
			inode_dec_link_count(dir);
		}
	}

	return err;
}
Exemple #26
0
static int simplefs_mkdir(struct inode *dir, struct dentry *dentry, int mode) {
	struct inode *inode = NULL;
	long ino;
	int err = 0;

	printk(KERN_INFO "simplefs_mkdir: %s %d\n", dentry->d_name.name, mode);
	inode_inc_link_count(dir);
	
	ino = bitmap_alloc_inode(dir->i_sb);
	if (ino < 0)
		return -EIO;
	inode = simplefs_iget(dir->i_sb, ino);
	if (IS_ERR(inode))
		return -EIO;

	// set inode operations
	inode->i_op = &simplefs_file_inode_operations;
	inode->i_fop = &simplefs_file_operations;
	inode->i_mapping->a_ops = &simplefs_aops;

	inode->i_mode = mode | S_IFDIR;
	inode->i_nlink = 2;
	inode->i_size = inode->i_blocks = inode->i_bytes = 0;
	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;

	mark_inode_dirty(inode);
	err = simplefs_insert_dentry(dentry, inode);
	if (!err) {
		d_instantiate(dentry, inode);
		return 0;
	}

	inode_dec_link_count(inode);
	inode_dec_link_count(inode);
	iput(inode);
	inode_dec_link_count(dir);
	return err;
}
Exemple #27
0
static int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode)
{
    struct inode * inode;
    int err = -EMLINK;

    if (dir->i_nlink >= SYSV_SB(dir->i_sb)->s_link_max)
        goto out;
    inode_inc_link_count(dir);

    inode = sysv_new_inode(dir, S_IFDIR|mode);
    err = PTR_ERR(inode);
    if (IS_ERR(inode))
        goto out_dir;

    sysv_set_inode(inode, 0);

    inode_inc_link_count(inode);

    err = sysv_make_empty(inode, dir);
    if (err)
        goto out_fail;

    err = sysv_add_link(dentry, inode);
    if (err)
        goto out_fail;

    d_instantiate(dentry, inode);
out:
    return err;

out_fail:
    inode_dec_link_count(inode);
    inode_dec_link_count(inode);
    iput(inode);
out_dir:
    inode_dec_link_count(dir);
    goto out;
}
Exemple #28
0
static int simplefs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) {
	struct inode *inode = old_dentry->d_inode;
	int err;

	inode->i_ctime = CURRENT_TIME_SEC;
	inode_inc_link_count(inode);
	atomic_inc(&inode->i_count);
	err = simplefs_insert_dentry(dentry, inode);
	if (!err) {
		d_instantiate(dentry, inode);
		return 0;
	}
	inode_dec_link_count(inode);
	iput(inode);
	return err;
}
Exemple #29
0
int qnx4_rmdir(struct inode *dir, struct dentry *dentry)
{
    struct buffer_head *bh;
    struct qnx4_inode_entry *de;
    struct inode *inode;
    int retval;
    int ino;

    QNX4DEBUG(("qnx4: qnx4_rmdir [%s]\n", dentry->d_name.name));
    lock_kernel();
    bh = qnx4_find_entry(dentry->d_name.len, dir, dentry->d_name.name,
                         &de, &ino);
    if (bh == NULL) {
        unlock_kernel();
        return -ENOENT;
    }
    inode = dentry->d_inode;
    if (inode->i_ino != ino) {
        retval = -EIO;
        goto end_rmdir;
    }
#if 0
    if (!empty_dir(inode)) {
        retval = -ENOTEMPTY;
        goto end_rmdir;
    }
#endif
    if (inode->i_nlink != 2) {
        QNX4DEBUG(("empty directory has nlink!=2 (%d)\n", inode->i_nlink));
    }
    QNX4DEBUG(("qnx4: deleting directory\n"));
    de->di_status = 0;
    memset(de->di_fname, 0, sizeof de->di_fname);
    de->di_mode = 0;
    mark_buffer_dirty(bh);
    clear_nlink(inode);
    mark_inode_dirty(inode);
    inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
    inode_dec_link_count(dir);
    retval = 0;

end_rmdir:
    brelse(bh);

    unlock_kernel();
    return retval;
}
Exemple #30
0
static int ext2_symlink (struct inode * dir, struct dentry * dentry,
                         const char * symname)
{
    struct super_block * sb = dir->i_sb;
    int err = -ENAMETOOLONG;
    unsigned l = strlen(symname)+1;
    struct inode * inode;

    if (l > sb->s_blocksize)
        goto out;

    dquot_initialize(dir);

    inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO, &dentry->d_name);
    err = PTR_ERR(inode);
    if (IS_ERR(inode))
        goto out;

    if (l > sizeof (EXT2_I(inode)->i_data)) {
        /* slow symlink */
        inode->i_op = &ext2_symlink_inode_operations;
        if (test_opt(inode->i_sb, NOBH))
            inode->i_mapping->a_ops = &ext2_nobh_aops;
        else
            inode->i_mapping->a_ops = &ext2_aops;
        err = page_symlink(inode, symname, l);
        if (err)
            goto out_fail;
    } else {
        /* fast symlink */
        inode->i_op = &ext2_fast_symlink_inode_operations;
        memcpy((char*)(EXT2_I(inode)->i_data),symname,l);
        inode->i_size = l-1;
    }
    mark_inode_dirty(inode);

    err = ext2_add_nondir(dentry, inode);
out:
    return err;

out_fail:
    inode_dec_link_count(inode);
    unlock_new_inode(inode);
    iput (inode);
    goto out;
}