Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
kqid.c
Go to the documentation of this file.
1 #include <linux/fs.h>
2 #include <linux/quota.h>
3 #include <linux/export.h>
4 
12 bool qid_eq(struct kqid left, struct kqid right)
13 {
14  if (left.type != right.type)
15  return false;
16  switch(left.type) {
17  case USRQUOTA:
18  return uid_eq(left.uid, right.uid);
19  case GRPQUOTA:
20  return gid_eq(left.gid, right.gid);
21  case PRJQUOTA:
22  return projid_eq(left.projid, right.projid);
23  default:
24  BUG();
25  }
26 }
28 
36 bool qid_lt(struct kqid left, struct kqid right)
37 {
38  if (left.type < right.type)
39  return true;
40  if (left.type > right.type)
41  return false;
42  switch (left.type) {
43  case USRQUOTA:
44  return uid_lt(left.uid, right.uid);
45  case GRPQUOTA:
46  return gid_lt(left.gid, right.gid);
47  case PRJQUOTA:
48  return projid_lt(left.projid, right.projid);
49  default:
50  BUG();
51  }
52 }
54 
67 qid_t from_kqid(struct user_namespace *targ, struct kqid kqid)
68 {
69  switch (kqid.type) {
70  case USRQUOTA:
71  return from_kuid(targ, kqid.uid);
72  case GRPQUOTA:
73  return from_kgid(targ, kqid.gid);
74  case PRJQUOTA:
75  return from_kprojid(targ, kqid.projid);
76  default:
77  BUG();
78  }
79 }
81 
101 {
102  switch (kqid.type) {
103  case USRQUOTA:
104  return from_kuid_munged(targ, kqid.uid);
105  case GRPQUOTA:
106  return from_kgid_munged(targ, kqid.gid);
107  case PRJQUOTA:
108  return from_kprojid_munged(targ, kqid.projid);
109  default:
110  BUG();
111  }
112 }
114 
119 bool qid_valid(struct kqid qid)
120 {
121  switch (qid.type) {
122  case USRQUOTA:
123  return uid_valid(qid.uid);
124  case GRPQUOTA:
125  return gid_valid(qid.gid);
126  case PRJQUOTA:
127  return projid_valid(qid.projid);
128  default:
129  BUG();
130  }
131 }