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
23 #include "xfs_mount.h"
24 #include "xfs_quota.h"
25 #include "xfs_trans.h"
26 #include "xfs_bmap_btree.h"
27 #include "xfs_inode.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
,
63 struct xfs_mount
*mp
= XFS_M(sb
);
64 unsigned int flags
= 0;
66 if (sb
->s_flags
& MS_RDONLY
)
68 if (op
!= Q_XQUOTARM
&& !XFS_IS_QUOTA_RUNNING(mp
))
71 if (uflags
& FS_QUOTA_UDQ_ACCT
)
72 flags
|= XFS_UQUOTA_ACCT
;
73 if (uflags
& FS_QUOTA_PDQ_ACCT
)
74 flags
|= XFS_PQUOTA_ACCT
;
75 if (uflags
& FS_QUOTA_GDQ_ACCT
)
76 flags
|= XFS_GQUOTA_ACCT
;
77 if (uflags
& FS_QUOTA_UDQ_ENFD
)
78 flags
|= XFS_UQUOTA_ENFD
;
79 if (uflags
& (FS_QUOTA_PDQ_ENFD
|FS_QUOTA_GDQ_ENFD
))
80 flags
|= XFS_OQUOTA_ENFD
;
84 return -xfs_qm_scall_quotaon(mp
, flags
);
86 if (!XFS_IS_QUOTA_ON(mp
))
88 return -xfs_qm_scall_quotaoff(mp
, flags
);
90 if (XFS_IS_QUOTA_ON(mp
))
92 return -xfs_qm_scall_trunc_qfiles(mp
, flags
);
100 struct super_block
*sb
,
103 struct fs_disk_quota
*fdq
)
105 struct xfs_mount
*mp
= XFS_M(sb
);
107 if (!XFS_IS_QUOTA_RUNNING(mp
))
109 if (!XFS_IS_QUOTA_ON(mp
))
112 return -xfs_qm_scall_getquota(mp
, id
, xfs_quota_type(type
), fdq
);
117 struct super_block
*sb
,
120 struct fs_disk_quota
*fdq
)
122 struct xfs_mount
*mp
= XFS_M(sb
);
124 if (sb
->s_flags
& MS_RDONLY
)
126 if (!XFS_IS_QUOTA_RUNNING(mp
))
128 if (!XFS_IS_QUOTA_ON(mp
))
131 return -xfs_qm_scall_setqlim(mp
, id
, xfs_quota_type(type
), fdq
);
134 const struct quotactl_ops xfs_quotactl_operations
= {
135 .get_xstate
= xfs_fs_get_xstate
,
136 .set_xstate
= xfs_fs_set_xstate
,
137 .get_dqblk
= xfs_fs_get_dqblk
,
138 .set_dqblk
= xfs_fs_set_dqblk
,