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_trans_resv.h"
24 #include "xfs_mount.h"
25 #include "xfs_quota.h"
26 #include "xfs_trans.h"
27 #include "xfs_bmap_btree.h"
28 #include "xfs_inode.h"
30 #include <linux/quota.h>
34 xfs_quota_type(int type)
48 struct super_block *sb,
49 struct fs_quota_stat *fqs)
51 struct xfs_mount *mp = XFS_M(sb);
53 if (!XFS_IS_QUOTA_RUNNING(mp))
55 return -xfs_qm_scall_getqstat(mp, fqs);
60 struct super_block *sb,
61 struct fs_quota_statv *fqs)
63 struct xfs_mount *mp = XFS_M(sb);
65 if (!XFS_IS_QUOTA_RUNNING(mp))
67 return -xfs_qm_scall_getqstatv(mp, fqs);
72 struct super_block *sb,
76 struct xfs_mount *mp = XFS_M(sb);
77 unsigned int flags = 0;
79 if (sb->s_flags & MS_RDONLY)
81 if (op != Q_XQUOTARM && !XFS_IS_QUOTA_RUNNING(mp))
84 if (uflags & FS_QUOTA_UDQ_ACCT)
85 flags |= XFS_UQUOTA_ACCT;
86 if (uflags & FS_QUOTA_PDQ_ACCT)
87 flags |= XFS_PQUOTA_ACCT;
88 if (uflags & FS_QUOTA_GDQ_ACCT)
89 flags |= XFS_GQUOTA_ACCT;
90 if (uflags & FS_QUOTA_UDQ_ENFD)
91 flags |= XFS_UQUOTA_ENFD;
92 if (uflags & FS_QUOTA_GDQ_ENFD)
93 flags |= XFS_GQUOTA_ENFD;
94 if (uflags & FS_QUOTA_PDQ_ENFD)
95 flags |= XFS_PQUOTA_ENFD;
99 return -xfs_qm_scall_quotaon(mp, flags);
101 if (!XFS_IS_QUOTA_ON(mp))
103 return -xfs_qm_scall_quotaoff(mp, flags);
105 if (XFS_IS_QUOTA_ON(mp))
107 return -xfs_qm_scall_trunc_qfiles(mp, flags);
115 struct super_block *sb,
117 struct fs_disk_quota *fdq)
119 struct xfs_mount *mp = XFS_M(sb);
121 if (!XFS_IS_QUOTA_RUNNING(mp))
123 if (!XFS_IS_QUOTA_ON(mp))
126 return -xfs_qm_scall_getquota(mp, from_kqid(&init_user_ns, qid),
127 xfs_quota_type(qid.type), fdq);
132 struct super_block *sb,
134 struct fs_disk_quota *fdq)
136 struct xfs_mount *mp = XFS_M(sb);
138 if (sb->s_flags & MS_RDONLY)
140 if (!XFS_IS_QUOTA_RUNNING(mp))
142 if (!XFS_IS_QUOTA_ON(mp))
145 return -xfs_qm_scall_setqlim(mp, from_kqid(&init_user_ns, qid),
146 xfs_quota_type(qid.type), fdq);
149 const struct quotactl_ops xfs_quotactl_operations = {
150 .get_xstatev = xfs_fs_get_xstatev,
151 .get_xstate = xfs_fs_get_xstate,
152 .set_xstate = xfs_fs_set_xstate,
153 .get_dqblk = xfs_fs_get_dqblk,
154 .set_dqblk = xfs_fs_set_dqblk,