Beispiel #1
0
static int quota_setxquota(struct super_block *sb, int type, qid_t id,
                           void __user *addr)
{
    struct fs_disk_quota fdq;
    struct qc_dqblk qdq;
    struct kqid qid;

    if (copy_from_user(&fdq, addr, sizeof(fdq)))
        return -EFAULT;
    if (!sb->s_qcop->set_dqblk)
        return -ENOSYS;
    qid = make_kqid(current_user_ns(), type, id);
    if (!qid_valid(qid))
        return -EINVAL;
    /* Are we actually setting timer / warning limits for all users? */
    if (from_kqid(&init_user_ns, qid) == 0 &&
            fdq.d_fieldmask & (FS_DQ_WARNS_MASK | FS_DQ_TIMER_MASK)) {
        struct qc_info qinfo;
        int ret;

        if (!sb->s_qcop->set_info)
            return -EINVAL;
        copy_qcinfo_from_xfs_dqblk(&qinfo, &fdq);
        ret = sb->s_qcop->set_info(sb, type, &qinfo);
        if (ret)
            return ret;
        /* These are already done */
        fdq.d_fieldmask &= ~(FS_DQ_WARNS_MASK | FS_DQ_TIMER_MASK);
    }
    copy_from_xfs_dqblk(&qdq, &fdq);
    return sb->s_qcop->set_dqblk(sb, qid, &qdq);
}
Beispiel #2
0
static int quota_setxquota(struct super_block *sb, int type, qid_t id,
			   void __user *addr)
{
	struct fs_disk_quota fdq;
	struct kqid qid;

	if (copy_from_user(&fdq, addr, sizeof(fdq)))
		return -EFAULT;
	if (!sb->s_qcop->set_dqblk)
		return -ENOSYS;
	qid = make_kqid(current_user_ns(), type, id);
	if (!qid_valid(qid))
		return -EINVAL;
	return sb->s_qcop->set_dqblk(sb, qid, &fdq);
}
Beispiel #3
0
static int quota_getquota(struct super_block *sb, int type, qid_t id,
			  void __user *addr)
{
	struct kqid qid;
	struct fs_disk_quota fdq;
	struct if_dqblk idq;
	int ret;

	if (!sb->s_qcop->get_dqblk)
		return -ENOSYS;
	qid = make_kqid(current_user_ns(), type, id);
	if (!qid_valid(qid))
		return -EINVAL;
	ret = sb->s_qcop->get_dqblk(sb, qid, &fdq);
	if (ret)
		return ret;
	copy_to_if_dqblk(&idq, &fdq);
	if (copy_to_user(addr, &idq, sizeof(idq)))
		return -EFAULT;
	return 0;
}
Beispiel #4
0
/*
 * Return quota for next active quota >= this id, if any exists,
 * otherwise return -ENOENT via ->get_nextdqblk.
 */
static int quota_getnextxquota(struct super_block *sb, int type, qid_t id,
                               void __user *addr)
{
    struct fs_disk_quota fdq;
    struct qc_dqblk qdq;
    struct kqid qid;
    qid_t id_out;
    int ret;

    if (!sb->s_qcop->get_nextdqblk)
        return -ENOSYS;
    qid = make_kqid(current_user_ns(), type, id);
    if (!qid_valid(qid))
        return -EINVAL;
    ret = sb->s_qcop->get_nextdqblk(sb, &qid, &qdq);
    if (ret)
        return ret;
    id_out = from_kqid(current_user_ns(), qid);
    copy_to_xfs_dqblk(&fdq, &qdq, type, id_out);
    if (copy_to_user(addr, &fdq, sizeof(fdq)))
        return -EFAULT;
    return ret;
}
Beispiel #5
0
/*
 * Return quota for next active quota >= this id, if any exists,
 * otherwise return -ENOENT via ->get_nextdqblk
 */
static int quota_getnextquota(struct super_block *sb, int type, qid_t id,
                              void __user *addr)
{
    struct kqid qid;
    struct qc_dqblk fdq;
    struct if_nextdqblk idq;
    int ret;

    if (!sb->s_qcop->get_nextdqblk)
        return -ENOSYS;
    qid = make_kqid(current_user_ns(), type, id);
    if (!qid_valid(qid))
        return -EINVAL;
    ret = sb->s_qcop->get_nextdqblk(sb, &qid, &fdq);
    if (ret)
        return ret;
    /* struct if_nextdqblk is a superset of struct if_dqblk */
    copy_to_if_dqblk((struct if_dqblk *)&idq, &fdq);
    idq.dqb_id = from_kqid(current_user_ns(), qid);
    if (copy_to_user(addr, &idq, sizeof(idq)))
        return -EFAULT;
    return 0;
}