2 * Copyright (c) 2008, Christoph Hellwig
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "xfs_format.h"
20 #include "xfs_log_format.h"
21 #include "xfs_trans_resv.h"
24 #include "xfs_mount.h"
25 #include "xfs_inode.h"
26 #include "xfs_quota.h"
27 #include "xfs_trans.h"
29 #include <linux/quota.h>
33 xfs_quota_type(int type)
47 struct super_block *sb,
48 struct fs_quota_stat *fqs)
50 struct xfs_mount *mp = XFS_M(sb);
52 if (!XFS_IS_QUOTA_RUNNING(mp))
54 return -xfs_qm_scall_getqstat(mp, fqs);
59 struct super_block *sb,
60 struct fs_quota_statv *fqs)
62 struct xfs_mount *mp = XFS_M(sb);
64 if (!XFS_IS_QUOTA_RUNNING(mp))
66 return -xfs_qm_scall_getqstatv(mp, fqs);
71 struct super_block *sb,
75 struct xfs_mount *mp = XFS_M(sb);
76 unsigned int flags = 0;
78 if (sb->s_flags & MS_RDONLY)
80 if (op != Q_XQUOTARM && !XFS_IS_QUOTA_RUNNING(mp))
83 if (uflags & FS_QUOTA_UDQ_ACCT)
84 flags |= XFS_UQUOTA_ACCT;
85 if (uflags & FS_QUOTA_PDQ_ACCT)
86 flags |= XFS_PQUOTA_ACCT;
87 if (uflags & FS_QUOTA_GDQ_ACCT)
88 flags |= XFS_GQUOTA_ACCT;
89 if (uflags & FS_QUOTA_UDQ_ENFD)
90 flags |= XFS_UQUOTA_ENFD;
91 if (uflags & FS_QUOTA_GDQ_ENFD)
92 flags |= XFS_GQUOTA_ENFD;
93 if (uflags & FS_QUOTA_PDQ_ENFD)
94 flags |= XFS_PQUOTA_ENFD;
98 return -xfs_qm_scall_quotaon(mp, flags);
100 if (!XFS_IS_QUOTA_ON(mp))
102 return -xfs_qm_scall_quotaoff(mp, flags);
104 if (XFS_IS_QUOTA_ON(mp))
106 return -xfs_qm_scall_trunc_qfiles(mp, flags);
114 struct super_block *sb,
116 struct fs_disk_quota *fdq)
118 struct xfs_mount *mp = XFS_M(sb);
120 if (!XFS_IS_QUOTA_RUNNING(mp))
122 if (!XFS_IS_QUOTA_ON(mp))
125 return -xfs_qm_scall_getquota(mp, from_kqid(&init_user_ns, qid),
126 xfs_quota_type(qid.type), fdq);
131 struct super_block *sb,
133 struct fs_disk_quota *fdq)
135 struct xfs_mount *mp = XFS_M(sb);
137 if (sb->s_flags & MS_RDONLY)
139 if (!XFS_IS_QUOTA_RUNNING(mp))
141 if (!XFS_IS_QUOTA_ON(mp))
144 return -xfs_qm_scall_setqlim(mp, from_kqid(&init_user_ns, qid),
145 xfs_quota_type(qid.type), fdq);
148 const struct quotactl_ops xfs_quotactl_operations = {
149 .get_xstatev = xfs_fs_get_xstatev,
150 .get_xstate = xfs_fs_get_xstate,
151 .set_xstate = xfs_fs_set_xstate,
152 .get_dqblk = xfs_fs_get_dqblk,
153 .set_dqblk = xfs_fs_set_dqblk,