]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - quota/linux.c
xfs: fix maxicount division by zero error
[thirdparty/xfsprogs-dev.git] / quota / linux.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6
7 #include "quota.h"
8 #include <sys/quota.h>
9
10 #ifndef PRJQUOTA
11 #define PRJQUOTA 2
12 #endif
13
14 static int
15 xtype_to_qtype(
16 uint type)
17 {
18 switch (type) {
19 case XFS_USER_QUOTA:
20 return USRQUOTA;
21 case XFS_GROUP_QUOTA:
22 return GRPQUOTA;
23 case XFS_PROJ_QUOTA:
24 return PRJQUOTA;
25 }
26 return 0;
27 }
28
29 static int
30 xcommand_to_qcommand(
31 uint command)
32 {
33 switch (command) {
34 case XFS_QUOTAON:
35 return Q_XQUOTAON;
36 case XFS_QUOTAOFF:
37 return Q_XQUOTAOFF;
38 case XFS_GETQUOTA:
39 return Q_XGETQUOTA;
40 case XFS_GETNEXTQUOTA:
41 return Q_XGETNEXTQUOTA;
42 case XFS_SETQLIM:
43 return Q_XSETQLIM;
44 case XFS_GETQSTAT:
45 return Q_XGETQSTAT;
46 case XFS_GETQSTATV:
47 return Q_XGETQSTATV;
48 case XFS_QUOTARM:
49 return Q_XQUOTARM;
50 case XFS_QSYNC:
51 return Q_XQUOTASYNC;
52 }
53 return 0;
54 }
55
56 int
57 xfsquotactl(
58 int command,
59 const char *device,
60 uint type,
61 uint id,
62 void *addr)
63 {
64 int qcommand, qtype;
65
66 qtype = xtype_to_qtype(type);
67 qcommand = xcommand_to_qcommand(command);
68
69 return quotactl(QCMD(qcommand, qtype), device, id, addr);
70 }