This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / linux / vserver / tag.h
1 #ifndef _DX_TAG_H
2 #define _DX_TAG_H
3
4
5 #define DX_TAG(in)      (IS_TAGGED(in))
6
7
8 #ifdef CONFIG_DX_TAG_NFSD
9 #define DX_TAG_NFSD     1
10 #else
11 #define DX_TAG_NFSD     0
12 #endif
13
14
15 #ifdef CONFIG_TAGGING_NONE
16
17 #define MAX_UID         0xFFFFFFFF
18 #define MAX_GID         0xFFFFFFFF
19
20 #define INOTAG_TAG(cond, uid, gid, tag) (0)
21
22 #define TAGINO_UID(cond, uid, tag)      (uid)
23 #define TAGINO_GID(cond, gid, tag)      (gid)
24
25 #endif
26
27
28 #ifdef CONFIG_TAGGING_GID16
29
30 #define MAX_UID         0xFFFFFFFF
31 #define MAX_GID         0x0000FFFF
32
33 #define INOTAG_TAG(cond, uid, gid, tag) \
34         ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
35
36 #define TAGINO_UID(cond, uid, tag)      (uid)
37 #define TAGINO_GID(cond, gid, tag)      \
38         ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
39
40 #endif
41
42
43 #ifdef CONFIG_TAGGING_ID24
44
45 #define MAX_UID         0x00FFFFFF
46 #define MAX_GID         0x00FFFFFF
47
48 #define INOTAG_TAG(cond, uid, gid, tag) \
49         ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
50
51 #define TAGINO_UID(cond, uid, tag)      \
52         ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
53 #define TAGINO_GID(cond, gid, tag)      \
54         ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
55
56 #endif
57
58
59 #ifdef CONFIG_TAGGING_UID16
60
61 #define MAX_UID         0x0000FFFF
62 #define MAX_GID         0xFFFFFFFF
63
64 #define INOTAG_TAG(cond, uid, gid, tag) \
65         ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
66
67 #define TAGINO_UID(cond, uid, tag)      \
68         ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
69 #define TAGINO_GID(cond, gid, tag)      (gid)
70
71 #endif
72
73
74 #ifdef CONFIG_TAGGING_INTERN
75
76 #define MAX_UID         0xFFFFFFFF
77 #define MAX_GID         0xFFFFFFFF
78
79 #define INOTAG_TAG(cond, uid, gid, tag) \
80         ((cond) ? (tag) : 0)
81
82 #define TAGINO_UID(cond, uid, tag)      (uid)
83 #define TAGINO_GID(cond, gid, tag)      (gid)
84
85 #endif
86
87
88 #ifndef CONFIG_TAGGING_NONE
89 #define dx_current_fstag(sb)    \
90         ((sb)->s_flags & MS_TAGGED ? dx_current_tag(): 0)
91 #else
92 #define dx_current_fstag(sb)    (0)
93 #endif
94
95 #ifndef CONFIG_TAGGING_INTERN
96 #define TAGINO_TAG(cond, tag)   (0)
97 #else
98 #define TAGINO_TAG(cond, tag)   ((cond) ? (tag) : 0)
99 #endif
100
101 #define INOTAG_UID(cond, uid, gid)      \
102         ((cond) ? ((uid) & MAX_UID) : (uid))
103 #define INOTAG_GID(cond, uid, gid)      \
104         ((cond) ? ((gid) & MAX_GID) : (gid))
105
106
107 static inline uid_t dx_map_uid(uid_t uid)
108 {
109         if ((uid > MAX_UID) && (uid != -1))
110                 uid = -2;
111         return (uid & MAX_UID);
112 }
113
114 static inline gid_t dx_map_gid(gid_t gid)
115 {
116         if ((gid > MAX_GID) && (gid != -1))
117                 gid = -2;
118         return (gid & MAX_GID);
119 }
120
121
122 #ifdef  CONFIG_VSERVER_LEGACY
123 #define FIOC_GETTAG     _IOR('x', 1, long)
124 #define FIOC_SETTAG     _IOW('x', 2, long)
125 #define FIOC_SETTAGJ    _IOW('x', 3, long)
126 #endif
127
128 #ifdef  CONFIG_PROPAGATE
129
130 int dx_parse_tag(char *string, tag_t *tag, int remove);
131
132 void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
133
134 #define dx_propagate_tag(n,i)   __dx_propagate_tag(n,i)
135
136 #else
137 #define dx_propagate_tag(n,i)   do { } while (0)
138 #endif
139
140 #endif /* _DX_TAG_H */