mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-01 08:04:22 +08:00
74a8a10378
Update the quotactl user space interface to successfull compile with user namespaces support enabled and to hand off quota identifiers to lower layers of the kernel in struct kqid instead of type and qid pairs. The quota on function is not converted because while it takes a quota type and an id. The id is the on disk quota format to use, which is something completely different. The signature of two struct quotactl_ops methods were changed to take struct kqid argumetns get_dqblk and set_dqblk. The dquot, xfs, and ocfs2 implementations of get_dqblk and set_dqblk are minimally changed so that the code continues to work with the change in parameter type. This is the first in a series of changes to always store quota identifiers in the kernel in struct kqid and only use raw type and qid values when interacting with on disk structures or userspace. Always using struct kqid internally makes it hard to miss places that need conversion to or from the kernel internal values. Cc: Jan Kara <jack@suse.cz> Cc: Dave Chinner <david@fromorbit.com> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Ben Myers <bpm@sgi.com> Cc: Alex Elder <elder@kernel.org> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
139 lines
3.1 KiB
C
139 lines
3.1 KiB
C
/*
|
|
* Copyright (c) 2008, Christoph Hellwig
|
|
* All Rights Reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it would be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write the Free Software Foundation,
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
#include "xfs.h"
|
|
#include "xfs_sb.h"
|
|
#include "xfs_log.h"
|
|
#include "xfs_ag.h"
|
|
#include "xfs_mount.h"
|
|
#include "xfs_quota.h"
|
|
#include "xfs_trans.h"
|
|
#include "xfs_bmap_btree.h"
|
|
#include "xfs_inode.h"
|
|
#include "xfs_qm.h"
|
|
#include <linux/quota.h>
|
|
|
|
|
|
STATIC int
|
|
xfs_quota_type(int type)
|
|
{
|
|
switch (type) {
|
|
case USRQUOTA:
|
|
return XFS_DQ_USER;
|
|
case GRPQUOTA:
|
|
return XFS_DQ_GROUP;
|
|
default:
|
|
return XFS_DQ_PROJ;
|
|
}
|
|
}
|
|
|
|
STATIC int
|
|
xfs_fs_get_xstate(
|
|
struct super_block *sb,
|
|
struct fs_quota_stat *fqs)
|
|
{
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
if (!XFS_IS_QUOTA_RUNNING(mp))
|
|
return -ENOSYS;
|
|
return -xfs_qm_scall_getqstat(mp, fqs);
|
|
}
|
|
|
|
STATIC int
|
|
xfs_fs_set_xstate(
|
|
struct super_block *sb,
|
|
unsigned int uflags,
|
|
int op)
|
|
{
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
unsigned int flags = 0;
|
|
|
|
if (sb->s_flags & MS_RDONLY)
|
|
return -EROFS;
|
|
if (op != Q_XQUOTARM && !XFS_IS_QUOTA_RUNNING(mp))
|
|
return -ENOSYS;
|
|
|
|
if (uflags & FS_QUOTA_UDQ_ACCT)
|
|
flags |= XFS_UQUOTA_ACCT;
|
|
if (uflags & FS_QUOTA_PDQ_ACCT)
|
|
flags |= XFS_PQUOTA_ACCT;
|
|
if (uflags & FS_QUOTA_GDQ_ACCT)
|
|
flags |= XFS_GQUOTA_ACCT;
|
|
if (uflags & FS_QUOTA_UDQ_ENFD)
|
|
flags |= XFS_UQUOTA_ENFD;
|
|
if (uflags & (FS_QUOTA_PDQ_ENFD|FS_QUOTA_GDQ_ENFD))
|
|
flags |= XFS_OQUOTA_ENFD;
|
|
|
|
switch (op) {
|
|
case Q_XQUOTAON:
|
|
return -xfs_qm_scall_quotaon(mp, flags);
|
|
case Q_XQUOTAOFF:
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
|
return -EINVAL;
|
|
return -xfs_qm_scall_quotaoff(mp, flags);
|
|
case Q_XQUOTARM:
|
|
if (XFS_IS_QUOTA_ON(mp))
|
|
return -EINVAL;
|
|
return -xfs_qm_scall_trunc_qfiles(mp, flags);
|
|
}
|
|
|
|
return -EINVAL;
|
|
}
|
|
|
|
STATIC int
|
|
xfs_fs_get_dqblk(
|
|
struct super_block *sb,
|
|
struct kqid qid,
|
|
struct fs_disk_quota *fdq)
|
|
{
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
if (!XFS_IS_QUOTA_RUNNING(mp))
|
|
return -ENOSYS;
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
|
return -ESRCH;
|
|
|
|
return -xfs_qm_scall_getquota(mp, from_kqid(&init_user_ns, qid),
|
|
xfs_quota_type(qid.type), fdq);
|
|
}
|
|
|
|
STATIC int
|
|
xfs_fs_set_dqblk(
|
|
struct super_block *sb,
|
|
struct kqid qid,
|
|
struct fs_disk_quota *fdq)
|
|
{
|
|
struct xfs_mount *mp = XFS_M(sb);
|
|
|
|
if (sb->s_flags & MS_RDONLY)
|
|
return -EROFS;
|
|
if (!XFS_IS_QUOTA_RUNNING(mp))
|
|
return -ENOSYS;
|
|
if (!XFS_IS_QUOTA_ON(mp))
|
|
return -ESRCH;
|
|
|
|
return -xfs_qm_scall_setqlim(mp, from_kqid(&init_user_ns, qid),
|
|
xfs_quota_type(qid.type), fdq);
|
|
}
|
|
|
|
const struct quotactl_ops xfs_quotactl_operations = {
|
|
.get_xstate = xfs_fs_get_xstate,
|
|
.set_xstate = xfs_fs_set_xstate,
|
|
.get_dqblk = xfs_fs_get_dqblk,
|
|
.set_dqblk = xfs_fs_set_dqblk,
|
|
};
|