示例#1
0
static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
                        struct nameidata *nd)
{
    struct jffs2_raw_inode *ri;
    struct jffs2_inode_info *f, *dir_f;
    struct jffs2_sb_info *c;
    struct inode *inode;
    int ret;

#ifdef CONFIG_ARCH_EZX
    if (dentry->d_name.len > JFFS2_MAX_NAME_LEN)
        return -ENAMETOOLONG;
#endif
    ri = jffs2_alloc_raw_inode();
    if (!ri)
        return -ENOMEM;

    c = JFFS2_SB_INFO(dir_i->i_sb);

    D1(printk(KERN_DEBUG "jffs2_create()\n"));

    inode = jffs2_new_inode(dir_i, mode, ri);

    if (IS_ERR(inode)) {
        D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n"));
        jffs2_free_raw_inode(ri);
        return PTR_ERR(inode);
    }

    inode->i_op = &jffs2_file_inode_operations;
    inode->i_fop = &jffs2_file_operations;
    inode->i_mapping->a_ops = &jffs2_file_address_operations;
    inode->i_mapping->nrpages = 0;

    f = JFFS2_INODE_INFO(inode);
    dir_f = JFFS2_INODE_INFO(dir_i);

    ret = jffs2_do_create(c, dir_f, f, ri,
                          dentry->d_name.name, dentry->d_name.len);

    if (ret) {
        make_bad_inode(inode);
        iput(inode);
        jffs2_free_raw_inode(ri);
        return ret;
    }

    dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime));

    jffs2_free_raw_inode(ri);
    d_instantiate(dentry, inode);

    D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n",
              inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages));
    return 0;
}
示例#2
0
int jffs2_create(struct inode *dir_i, struct qstr *d_name, int mode,
                 struct inode **new_i)
{
    struct jffs2_raw_inode *ri;
    struct jffs2_inode_info *f, *dir_f;
    struct jffs2_sb_info *c;
    struct inode *inode;
    int ret;

    ri = jffs2_alloc_raw_inode();
    if (!ri)
        return -ENOMEM;

    c = JFFS2_SB_INFO(dir_i->i_sb);

    D1(printk(KERN_DEBUG "jffs2_create()\n"));

    inode = jffs2_new_inode(dir_i, mode, ri);

    if (IS_ERR(inode)) {
        D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n"));
        jffs2_free_raw_inode(ri);
        return PTR_ERR(inode);
    }

    f = JFFS2_INODE_INFO(inode);
    dir_f = JFFS2_INODE_INFO(dir_i);

    ret = jffs2_do_create(c, dir_f, f, ri,
                          d_name->name, d_name->len);

    if (ret) {
        jffs2_clear_inode(inode);
        make_bad_inode(inode);
        iput(inode);
        jffs2_free_raw_inode(ri);
        return ret;
    }

    jffs2_free_raw_inode(ri);

    D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d)\n",
              inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink));
    *new_i = inode;
    return 0;
}
示例#3
0
int jffs2_create(struct _inode *dir_i, const unsigned char *d_name,
									int mode, struct _inode **new_i) {
	struct jffs2_raw_inode *ri;
	struct jffs2_inode_info *f, *dir_f;
	struct jffs2_sb_info *c;
	struct _inode *inode;
	int ret;

	ri = jffs2_alloc_raw_inode();
	if (!ri) {
		return -ENOMEM;
	}

	c = &dir_i->i_sb->jffs2_sb;

	D1(printk( "jffs2_create()\n"));

	inode = jffs2_new_inode(dir_i, mode, ri);

	if (IS_ERR(inode)) {
		D1(printk( "jffs2_new_inode() failed\n"));
		jffs2_free_raw_inode(ri);
		return PTR_ERR(inode);
	}

	f = JFFS2_INODE_INFO(inode);
	dir_f = JFFS2_INODE_INFO(dir_i);

	ret = jffs2_do_create(c, dir_f, f, ri,
			      (const char *)d_name,
                              strlen((char *)d_name));

	if (ret) {
		inode->i_nlink = 0;
		jffs2_iput(inode);
		jffs2_free_raw_inode(ri);
		return ret;
	}

	jffs2_free_raw_inode(ri);

	D1(printk("jffs2_create: Created ino #%d with mode %o, nlink %d(%d)\n",
		  inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink));
    *new_i = inode;
	return 0;
}
示例#4
0
static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
			struct nameidata *nd)
{
	struct jffs2_raw_inode *ri;
	struct jffs2_inode_info *f, *dir_f;
	struct jffs2_sb_info *c;
	struct inode *inode;
	int ret;

	ri = jffs2_alloc_raw_inode();
	if (!ri)
		return -ENOMEM;

	c = JFFS2_SB_INFO(dir_i->i_sb);

;

	inode = jffs2_new_inode(dir_i, mode, ri);

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

	inode->i_op = &jffs2_file_inode_operations;
	inode->i_fop = &jffs2_file_operations;
	inode->i_mapping->a_ops = &jffs2_file_address_operations;
	inode->i_mapping->nrpages = 0;

	f = JFFS2_INODE_INFO(inode);
	dir_f = JFFS2_INODE_INFO(dir_i);

	/* jffs2_do_create() will want to lock it, _after_ reserving
	   space and taking c-alloc_sem. If we keep it locked here,
	   lockdep gets unhappy (although it's a false positive;
	   nothing else will be looking at this inode yet so there's
	   no chance of AB-BA deadlock involving its f->sem). */
	mutex_unlock(&f->sem);

	ret = jffs2_do_create(c, dir_f, f, ri, &dentry->d_name);
	if (ret)
		goto fail;

	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime));

	jffs2_free_raw_inode(ri);

//	D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n",
//		  inode->i_ino, inode->i_mode, inode->i_nlink,
;

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

 fail:
	iget_failed(inode);
	jffs2_free_raw_inode(ri);
	return ret;
}