]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - quota/linux.c
xfs_quota: Fix range for -U.
[thirdparty/xfsprogs-dev.git] / quota / linux.c
CommitLineData
5aead01d 1/*
da23017d
NS
2 * Copyright (c) 2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
5aead01d 4 *
da23017d
NS
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
5aead01d
NS
7 * published by the Free Software Foundation.
8 *
da23017d
NS
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.
5aead01d 13 *
da23017d
NS
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
5aead01d
NS
17 */
18
19#include "quota.h"
20#include <sys/quota.h>
21
22#ifndef PRJQUOTA
23#define PRJQUOTA 2
24#endif
25
26static int
27xtype_to_qtype(
28 uint type)
29{
30 switch (type) {
31 case XFS_USER_QUOTA:
32 return USRQUOTA;
33 case XFS_GROUP_QUOTA:
34 return GRPQUOTA;
35 case XFS_PROJ_QUOTA:
36 return PRJQUOTA;
37 }
38 return 0;
39}
40
41static int
42xcommand_to_qcommand(
43 uint command)
44{
45 switch (command) {
46 case XFS_QUOTAON:
47 return Q_XQUOTAON;
48 case XFS_QUOTAOFF:
49 return Q_XQUOTAOFF;
50 case XFS_GETQUOTA:
51 return Q_XGETQUOTA;
52 case XFS_SETQLIM:
53 return Q_XSETQLIM;
54 case XFS_GETQSTAT:
55 return Q_XGETQSTAT;
56 case XFS_QUOTARM:
57 return Q_XQUOTARM;
546bedf4
NS
58 case XFS_QSYNC:
59 return Q_XQUOTASYNC;
5aead01d
NS
60 }
61 return 0;
62}
63
64int
65xfsquotactl(
66 int command,
67 const char *device,
68 uint type,
69 uint id,
70 void *addr)
71{
72 int qcommand, qtype;
73
74 qtype = xtype_to_qtype(type);
75 qcommand = xcommand_to_qcommand(command);
76
77 return quotactl(QCMD(qcommand, qtype), device, id, addr);
78}