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
22 #include "xfs_mount.h"
23 #include "xfs_quota.h"
24 #include "xfs_trans.h"
25 #include "xfs_bmap_btree.h"
26 #include "xfs_inode.h"
28 #include <linux/quota.h>
32 xfs_quota_type(int type
)
46 struct super_block
*sb
,
47 struct fs_quota_stat
*fqs
)
49 struct xfs_mount
*mp
= XFS_M(sb
);
51 if (!XFS_IS_QUOTA_RUNNING(mp
))
53 return -xfs_qm_scall_getqstat(mp
, fqs
);
58 struct super_block
*sb
,
62 struct xfs_mount
*mp
= XFS_M(sb
);
63 unsigned int flags
= 0;
65 if (sb
->s_flags
& MS_RDONLY
)
67 if (op
!= Q_XQUOTARM
&& !XFS_IS_QUOTA_RUNNING(mp
))
70 if (uflags
& FS_QUOTA_UDQ_ACCT
)
71 flags
|= XFS_UQUOTA_ACCT
;
72 if (uflags
& FS_QUOTA_PDQ_ACCT
)
73 flags
|= XFS_PQUOTA_ACCT
;
74 if (uflags
& FS_QUOTA_GDQ_ACCT
)
75 flags
|= XFS_GQUOTA_ACCT
;
76 if (uflags
& FS_QUOTA_UDQ_ENFD
)
77 flags
|= XFS_UQUOTA_ENFD
;
78 if (uflags
& (FS_QUOTA_PDQ_ENFD
|FS_QUOTA_GDQ_ENFD
))
79 flags
|= XFS_OQUOTA_ENFD
;
83 return -xfs_qm_scall_quotaon(mp
, flags
);
85 if (!XFS_IS_QUOTA_ON(mp
))
87 return -xfs_qm_scall_quotaoff(mp
, flags
);
89 if (XFS_IS_QUOTA_ON(mp
))
91 return -xfs_qm_scall_trunc_qfiles(mp
, flags
);
99 struct super_block
*sb
,
101 struct fs_disk_quota
*fdq
)
103 struct xfs_mount
*mp
= XFS_M(sb
);
105 if (!XFS_IS_QUOTA_RUNNING(mp
))
107 if (!XFS_IS_QUOTA_ON(mp
))
110 return -xfs_qm_scall_getquota(mp
, from_kqid(&init_user_ns
, qid
),
111 xfs_quota_type(qid
.type
), fdq
);
116 struct super_block
*sb
,
118 struct fs_disk_quota
*fdq
)
120 struct xfs_mount
*mp
= XFS_M(sb
);
122 if (sb
->s_flags
& MS_RDONLY
)
124 if (!XFS_IS_QUOTA_RUNNING(mp
))
126 if (!XFS_IS_QUOTA_ON(mp
))
129 return -xfs_qm_scall_setqlim(mp
, from_kqid(&init_user_ns
, qid
),
130 xfs_quota_type(qid
.type
), fdq
);
133 const struct quotactl_ops xfs_quotactl_operations
= {
134 .get_xstate
= xfs_fs_get_xstate
,
135 .set_xstate
= xfs_fs_set_xstate
,
136 .get_dqblk
= xfs_fs_get_dqblk
,
137 .set_dqblk
= xfs_fs_set_dqblk
,