]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - quota/linux.c
xfsprogs: Release v6.7.0
[thirdparty/xfsprogs-dev.git] / quota / linux.c
CommitLineData
959ef981 1// SPDX-License-Identifier: GPL-2.0
5aead01d 2/*
da23017d
NS
3 * Copyright (c) 2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5aead01d
NS
5 */
6
7#include "quota.h"
8#include <sys/quota.h>
9
10#ifndef PRJQUOTA
11#define PRJQUOTA 2
12#endif
13
14static int
15xtype_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
29static int
30xcommand_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;
513fc424
ES
40 case XFS_GETNEXTQUOTA:
41 return Q_XGETNEXTQUOTA;
5aead01d
NS
42 case XFS_SETQLIM:
43 return Q_XSETQLIM;
44 case XFS_GETQSTAT:
45 return Q_XGETQSTAT;
bb92709f
ES
46 case XFS_GETQSTATV:
47 return Q_XGETQSTATV;
5aead01d
NS
48 case XFS_QUOTARM:
49 return Q_XQUOTARM;
546bedf4
NS
50 case XFS_QSYNC:
51 return Q_XQUOTASYNC;
5aead01d
NS
52 }
53 return 0;
54}
55
56int
57xfsquotactl(
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}