Example #1
0
void au_cpup_attr_all(struct inode *inode, int force)
{
	struct inode *h_inode;

	h_inode = au_h_iptr(inode, au_ibstart(inode));
	au_cpup_attr_changeable(inode);
	if (inode->i_nlink > 0)
		au_cpup_attr_nlink(inode, force);
	inode->i_rdev = h_inode->i_rdev;
	inode->i_blkbits = h_inode->i_blkbits;
	au_cpup_igen(inode, h_inode);
}
Example #2
0
void au_cpup_attr_all(struct inode *inode, int force)
{
	struct inode *h_inode;

	LKTRTrace("i%lu\n", inode->i_ino);
	/* todo? IMustLock(inode); */
	h_inode = au_h_iptr(inode, au_ibstart(inode));
	AuDebugOn(!h_inode);

	au_cpup_attr_changeable(inode);
	if (inode->i_nlink > 0)
		au_cpup_attr_nlink(inode, force);

	switch (inode->i_mode & S_IFMT) {
	case S_IFBLK:
	case S_IFCHR:
		inode->i_rdev = au_h_rdev(h_inode, /*h_mnt*/NULL,
					  /*h_dentry*/NULL);
	}
	inode->i_blkbits = h_inode->i_blkbits;
	au_cpup_igen(inode, h_inode);
}
Example #3
0
int au_mvdown(struct dentry *dentry, struct aufs_mvdown __user *uarg)
{
    int err, e;
    unsigned char dmsg;
    struct au_mvd_args *args;

    err = -EPERM;
    if (unlikely(!capable(CAP_SYS_ADMIN)))
        goto out;

    err = -ENOMEM;
    args = kmalloc(sizeof(*args), GFP_NOFS);
    if (unlikely(!args))
        goto out;

    err = copy_from_user(&args->mvdown, uarg, sizeof(args->mvdown));
    if (!err)
        err = !access_ok(VERIFY_WRITE, uarg, sizeof(*uarg));
    if (unlikely(err)) {
        err = -EFAULT;
        AuTraceErr(err);
        goto out_free;
    }
    AuDbg("flags 0x%x\n", args->mvdown.flags);
    args->mvdown.flags &= ~(AUFS_MVDOWN_ROLOWER_R | AUFS_MVDOWN_ROUPPER_R);
    args->mvdown.au_errno = 0;
    args->dentry = dentry;
    args->inode = d_inode(dentry);
    args->sb = dentry->d_sb;

    err = -ENOENT;
    dmsg = !!(args->mvdown.flags & AUFS_MVDOWN_DMSG);
    args->parent = dget_parent(dentry);
    args->dir = d_inode(args->parent);
    mutex_lock_nested(&args->dir->i_mutex, I_MUTEX_PARENT);
    dput(args->parent);
    if (unlikely(args->parent != dentry->d_parent)) {
        AU_MVD_PR(dmsg, "parent dir is moved\n");
        goto out_dir;
    }

    mutex_lock_nested(&args->inode->i_mutex, I_MUTEX_CHILD);
    err = aufs_read_lock(dentry, AuLock_DW | AuLock_FLUSH);
    if (unlikely(err))
        goto out_inode;

    di_write_lock_parent(args->parent);
    err = au_mvd_args(dmsg, args);
    if (unlikely(err))
        goto out_parent;

    err = au_do_mvdown(dmsg, args);
    if (unlikely(err))
        goto out_parent;

    au_cpup_attr_timesizes(args->dir);
    au_cpup_attr_timesizes(args->inode);
    au_cpup_igen(args->inode, au_h_iptr(args->inode, args->mvd_bdst));
    /* au_digen_dec(dentry); */

out_parent:
    di_write_unlock(args->parent);
    aufs_read_unlock(dentry, AuLock_DW);
out_inode:
    mutex_unlock(&args->inode->i_mutex);
out_dir:
    mutex_unlock(&args->dir->i_mutex);
out_free:
    e = copy_to_user(uarg, &args->mvdown, sizeof(args->mvdown));
    if (unlikely(e))
        err = -EFAULT;
    kfree(args);
out:
    AuTraceErr(err);
    return err;
}