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"
22 #include "xfs_mount.h"
23 #include "xfs_inode.h"
24 #include "xfs_quota.h"
25 #include "xfs_trans.h"
27 #include <linux/quota.h>
31 xfs_quota_type(int type
)
45 struct super_block
*sb
,
46 struct fs_quota_stat
*fqs
)
48 struct xfs_mount
*mp
= XFS_M(sb
);
50 if (!XFS_IS_QUOTA_RUNNING(mp
))
52 return xfs_qm_scall_getqstat(mp
, fqs
);
57 struct super_block
*sb
,
58 struct fs_quota_statv
*fqs
)
60 struct xfs_mount
*mp
= XFS_M(sb
);
62 if (!XFS_IS_QUOTA_RUNNING(mp
))
64 return xfs_qm_scall_getqstatv(mp
, fqs
);
68 xfs_quota_flags(unsigned int uflags
)
70 unsigned int flags
= 0;
72 if (uflags
& FS_QUOTA_UDQ_ACCT
)
73 flags
|= XFS_UQUOTA_ACCT
;
74 if (uflags
& FS_QUOTA_PDQ_ACCT
)
75 flags
|= XFS_PQUOTA_ACCT
;
76 if (uflags
& FS_QUOTA_GDQ_ACCT
)
77 flags
|= XFS_GQUOTA_ACCT
;
78 if (uflags
& FS_QUOTA_UDQ_ENFD
)
79 flags
|= XFS_UQUOTA_ENFD
;
80 if (uflags
& FS_QUOTA_GDQ_ENFD
)
81 flags
|= XFS_GQUOTA_ENFD
;
82 if (uflags
& FS_QUOTA_PDQ_ENFD
)
83 flags
|= XFS_PQUOTA_ENFD
;
90 struct super_block
*sb
,
93 struct xfs_mount
*mp
= XFS_M(sb
);
95 if (sb
->s_flags
& MS_RDONLY
)
97 if (!XFS_IS_QUOTA_RUNNING(mp
))
100 return xfs_qm_scall_quotaon(mp
, xfs_quota_flags(uflags
));
105 struct super_block
*sb
,
108 struct xfs_mount
*mp
= XFS_M(sb
);
110 if (sb
->s_flags
& MS_RDONLY
)
112 if (!XFS_IS_QUOTA_RUNNING(mp
))
114 if (!XFS_IS_QUOTA_ON(mp
))
117 return xfs_qm_scall_quotaoff(mp
, xfs_quota_flags(uflags
));
122 struct super_block
*sb
,
125 struct xfs_mount
*mp
= XFS_M(sb
);
126 unsigned int flags
= 0;
128 if (sb
->s_flags
& MS_RDONLY
)
131 if (XFS_IS_QUOTA_ON(mp
))
134 if (uflags
& FS_USER_QUOTA
)
135 flags
|= XFS_DQ_USER
;
136 if (uflags
& FS_GROUP_QUOTA
)
137 flags
|= XFS_DQ_GROUP
;
138 if (uflags
& FS_PROJ_QUOTA
)
139 flags
|= XFS_DQ_PROJ
;
141 return xfs_qm_scall_trunc_qfiles(mp
, flags
);
146 struct super_block
*sb
,
148 struct qc_dqblk
*qdq
)
150 struct xfs_mount
*mp
= XFS_M(sb
);
152 if (!XFS_IS_QUOTA_RUNNING(mp
))
154 if (!XFS_IS_QUOTA_ON(mp
))
157 return xfs_qm_scall_getquota(mp
, from_kqid(&init_user_ns
, qid
),
158 xfs_quota_type(qid
.type
), qdq
);
163 struct super_block
*sb
,
165 struct qc_dqblk
*qdq
)
167 struct xfs_mount
*mp
= XFS_M(sb
);
169 if (sb
->s_flags
& MS_RDONLY
)
171 if (!XFS_IS_QUOTA_RUNNING(mp
))
173 if (!XFS_IS_QUOTA_ON(mp
))
176 return xfs_qm_scall_setqlim(mp
, from_kqid(&init_user_ns
, qid
),
177 xfs_quota_type(qid
.type
), qdq
);
180 const struct quotactl_ops xfs_quotactl_operations
= {
181 .get_xstatev
= xfs_fs_get_xstatev
,
182 .get_xstate
= xfs_fs_get_xstate
,
183 .quota_enable
= xfs_quota_enable
,
184 .quota_disable
= xfs_quota_disable
,
185 .rm_xquota
= xfs_fs_rm_xquota
,
186 .get_dqblk
= xfs_fs_get_dqblk
,
187 .set_dqblk
= xfs_fs_set_dqblk
,