1
2#include <linux/fs.h>
3#include <linux/quota.h>
4#include <linux/export.h>
5
6
7
8
9
10
11
12
13bool qid_eq(struct kqid left, struct kqid right)
14{
15 if (left.type != right.type)
16 return false;
17 switch(left.type) {
18 case USRQUOTA:
19 return uid_eq(left.uid, right.uid);
20 case GRPQUOTA:
21 return gid_eq(left.gid, right.gid);
22 case PRJQUOTA:
23 return projid_eq(left.projid, right.projid);
24 default:
25 BUG();
26 }
27}
28EXPORT_SYMBOL(qid_eq);
29
30
31
32
33
34
35
36
37bool qid_lt(struct kqid left, struct kqid right)
38{
39 if (left.type < right.type)
40 return true;
41 if (left.type > right.type)
42 return false;
43 switch (left.type) {
44 case USRQUOTA:
45 return uid_lt(left.uid, right.uid);
46 case GRPQUOTA:
47 return gid_lt(left.gid, right.gid);
48 case PRJQUOTA:
49 return projid_lt(left.projid, right.projid);
50 default:
51 BUG();
52 }
53}
54EXPORT_SYMBOL(qid_lt);
55
56
57
58
59
60
61
62
63
64
65
66
67
68qid_t from_kqid(struct user_namespace *targ, struct kqid kqid)
69{
70 switch (kqid.type) {
71 case USRQUOTA:
72 return from_kuid(targ, kqid.uid);
73 case GRPQUOTA:
74 return from_kgid(targ, kqid.gid);
75 case PRJQUOTA:
76 return from_kprojid(targ, kqid.projid);
77 default:
78 BUG();
79 }
80}
81EXPORT_SYMBOL(from_kqid);
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101qid_t from_kqid_munged(struct user_namespace *targ, struct kqid kqid)
102{
103 switch (kqid.type) {
104 case USRQUOTA:
105 return from_kuid_munged(targ, kqid.uid);
106 case GRPQUOTA:
107 return from_kgid_munged(targ, kqid.gid);
108 case PRJQUOTA:
109 return from_kprojid_munged(targ, kqid.projid);
110 default:
111 BUG();
112 }
113}
114EXPORT_SYMBOL(from_kqid_munged);
115
116
117
118
119
120bool qid_valid(struct kqid qid)
121{
122 switch (qid.type) {
123 case USRQUOTA:
124 return uid_valid(qid.uid);
125 case GRPQUOTA:
126 return gid_valid(qid.gid);
127 case PRJQUOTA:
128 return projid_valid(qid.projid);
129 default:
130 BUG();
131 }
132}
133EXPORT_SYMBOL(qid_valid);
134