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
);
69 struct super_block
*sb
,
73 struct xfs_mount
*mp
= XFS_M(sb
);
74 unsigned int flags
= 0;
76 if (sb
->s_flags
& MS_RDONLY
)
78 if (op
!= Q_XQUOTARM
&& !XFS_IS_QUOTA_RUNNING(mp
))
81 if (uflags
& FS_QUOTA_UDQ_ACCT
)
82 flags
|= XFS_UQUOTA_ACCT
;
83 if (uflags
& FS_QUOTA_PDQ_ACCT
)
84 flags
|= XFS_PQUOTA_ACCT
;
85 if (uflags
& FS_QUOTA_GDQ_ACCT
)
86 flags
|= XFS_GQUOTA_ACCT
;
87 if (uflags
& FS_QUOTA_UDQ_ENFD
)
88 flags
|= XFS_UQUOTA_ENFD
;
89 if (uflags
& FS_QUOTA_GDQ_ENFD
)
90 flags
|= XFS_GQUOTA_ENFD
;
91 if (uflags
& FS_QUOTA_PDQ_ENFD
)
92 flags
|= XFS_PQUOTA_ENFD
;
96 return xfs_qm_scall_quotaon(mp
, flags
);
98 if (!XFS_IS_QUOTA_ON(mp
))
100 return xfs_qm_scall_quotaoff(mp
, flags
);
108 struct super_block
*sb
,
111 struct xfs_mount
*mp
= XFS_M(sb
);
112 unsigned int flags
= 0;
114 if (sb
->s_flags
& MS_RDONLY
)
117 if (XFS_IS_QUOTA_ON(mp
))
120 if (uflags
& FS_USER_QUOTA
)
121 flags
|= XFS_DQ_USER
;
122 if (uflags
& FS_GROUP_QUOTA
)
123 flags
|= XFS_DQ_GROUP
;
124 if (uflags
& FS_PROJ_QUOTA
)
125 flags
|= XFS_DQ_PROJ
;
127 return xfs_qm_scall_trunc_qfiles(mp
, flags
);
132 struct super_block
*sb
,
134 struct fs_disk_quota
*fdq
)
136 struct xfs_mount
*mp
= XFS_M(sb
);
138 if (!XFS_IS_QUOTA_RUNNING(mp
))
140 if (!XFS_IS_QUOTA_ON(mp
))
143 return xfs_qm_scall_getquota(mp
, from_kqid(&init_user_ns
, qid
),
144 xfs_quota_type(qid
.type
), fdq
);
149 struct super_block
*sb
,
151 struct fs_disk_quota
*fdq
)
153 struct xfs_mount
*mp
= XFS_M(sb
);
155 if (sb
->s_flags
& MS_RDONLY
)
157 if (!XFS_IS_QUOTA_RUNNING(mp
))
159 if (!XFS_IS_QUOTA_ON(mp
))
162 return xfs_qm_scall_setqlim(mp
, from_kqid(&init_user_ns
, qid
),
163 xfs_quota_type(qid
.type
), fdq
);
166 const struct quotactl_ops xfs_quotactl_operations
= {
167 .get_xstatev
= xfs_fs_get_xstatev
,
168 .get_xstate
= xfs_fs_get_xstate
,
169 .set_xstate
= xfs_fs_set_xstate
,
170 .rm_xquota
= xfs_fs_rm_xquota
,
171 .get_dqblk
= xfs_fs_get_dqblk
,
172 .set_dqblk
= xfs_fs_set_dqblk
,