2 #include <linux/quota.h>
3 #include <linux/export.h>
6 * qid_eq - Test to see if to kquid values are the same
8 * @right: Another quid value
10 * Return true if the two qid values are equal and false otherwise.
12 bool qid_eq(struct kqid left, struct kqid right)
14 if (left.type != right.type)
18 return uid_eq(left.uid, right.uid);
20 return gid_eq(left.gid, right.gid);
22 return projid_eq(left.projid, right.projid);
27 EXPORT_SYMBOL(qid_eq);
30 * qid_lt - Test to see if one qid value is less than another
31 * @left: The possibly lesser qid value
32 * @right: The possibly greater qid value
34 * Return true if left is less than right and false otherwise.
36 bool qid_lt(struct kqid left, struct kqid right)
38 if (left.type < right.type)
40 if (left.type > right.type)
44 return uid_lt(left.uid, right.uid);
46 return gid_lt(left.gid, right.gid);
48 return projid_lt(left.projid, right.projid);
53 EXPORT_SYMBOL(qid_lt);
56 * from_kqid - Create a qid from a kqid user-namespace pair.
57 * @targ: The user namespace we want a qid in.
58 * @kuid: The kernel internal quota identifier to start with.
60 * Map @kqid into the user-namespace specified by @targ and
61 * return the resulting qid.
63 * There is always a mapping into the initial user_namespace.
65 * If @kqid has no mapping in @targ (qid_t)-1 is returned.
67 qid_t from_kqid(struct user_namespace *targ, struct kqid kqid)
71 return from_kuid(targ, kqid.uid);
73 return from_kgid(targ, kqid.gid);
75 return from_kprojid(targ, kqid.projid);
80 EXPORT_SYMBOL(from_kqid);
83 * from_kqid_munged - Create a qid from a kqid user-namespace pair.
84 * @targ: The user namespace we want a qid in.
85 * @kqid: The kernel internal quota identifier to start with.
87 * Map @kqid into the user-namespace specified by @targ and
88 * return the resulting qid.
90 * There is always a mapping into the initial user_namespace.
92 * Unlike from_kqid from_kqid_munged never fails and always
93 * returns a valid projid. This makes from_kqid_munged
94 * appropriate for use in places where failing to provide
95 * a qid_t is not a good option.
97 * If @kqid has no mapping in @targ the kqid.type specific
98 * overflow identifier is returned.
100 qid_t from_kqid_munged(struct user_namespace *targ, struct kqid kqid)
104 return from_kuid_munged(targ, kqid.uid);
106 return from_kgid_munged(targ, kqid.gid);
108 return from_kprojid_munged(targ, kqid.projid);
113 EXPORT_SYMBOL(from_kqid_munged);
116 * qid_valid - Report if a valid value is stored in a kqid.
117 * @qid: The kernel internal quota identifier to test.
119 bool qid_valid(struct kqid qid)
123 return uid_valid(qid.uid);
125 return gid_valid(qid.gid);
127 return projid_valid(qid.projid);
132 EXPORT_SYMBOL(qid_valid);