Root/
1 | #ifndef _LINUX_HIGHUID_H |
2 | #define _LINUX_HIGHUID_H |
3 | |
4 | #include <linux/types.h> |
5 | |
6 | /* |
7 | * general notes: |
8 | * |
9 | * CONFIG_UID16 is defined if the given architecture needs to |
10 | * support backwards compatibility for old system calls. |
11 | * |
12 | * kernel code should use uid_t and gid_t at all times when dealing with |
13 | * kernel-private data. |
14 | * |
15 | * old_uid_t and old_gid_t should only be different if CONFIG_UID16 is |
16 | * defined, else the platform should provide dummy typedefs for them |
17 | * such that they are equivalent to __kernel_{u,g}id_t. |
18 | * |
19 | * uid16_t and gid16_t are used on all architectures. (when dealing |
20 | * with structures hard coded to 16 bits, such as in filesystems) |
21 | */ |
22 | |
23 | |
24 | /* |
25 | * This is the "overflow" UID and GID. They are used to signify uid/gid |
26 | * overflow to old programs when they request uid/gid information but are |
27 | * using the old 16 bit interfaces. |
28 | * When you run a libc5 program, it will think that all highuid files or |
29 | * processes are owned by this uid/gid. |
30 | * The idea is that it's better to do so than possibly return 0 in lieu of |
31 | * 65536, etc. |
32 | */ |
33 | |
34 | extern int overflowuid; |
35 | extern int overflowgid; |
36 | |
37 | extern void __bad_uid(void); |
38 | extern void __bad_gid(void); |
39 | |
40 | #define DEFAULT_OVERFLOWUID 65534 |
41 | #define DEFAULT_OVERFLOWGID 65534 |
42 | |
43 | #ifdef CONFIG_UID16 |
44 | |
45 | /* prevent uid mod 65536 effect by returning a default value for high UIDs */ |
46 | #define high2lowuid(uid) ((uid) & ~0xFFFF ? (old_uid_t)overflowuid : (old_uid_t)(uid)) |
47 | #define high2lowgid(gid) ((gid) & ~0xFFFF ? (old_gid_t)overflowgid : (old_gid_t)(gid)) |
48 | /* |
49 | * -1 is different in 16 bits than it is in 32 bits |
50 | * these macros are used by chown(), setreuid(), ..., |
51 | */ |
52 | #define low2highuid(uid) ((uid) == (old_uid_t)-1 ? (uid_t)-1 : (uid_t)(uid)) |
53 | #define low2highgid(gid) ((gid) == (old_gid_t)-1 ? (gid_t)-1 : (gid_t)(gid)) |
54 | |
55 | #define __convert_uid(size, uid) \ |
56 | (size >= sizeof(uid) ? (uid) : high2lowuid(uid)) |
57 | #define __convert_gid(size, gid) \ |
58 | (size >= sizeof(gid) ? (gid) : high2lowgid(gid)) |
59 | |
60 | |
61 | #else |
62 | |
63 | #define __convert_uid(size, uid) (uid) |
64 | #define __convert_gid(size, gid) (gid) |
65 | |
66 | #endif /* !CONFIG_UID16 */ |
67 | |
68 | /* uid/gid input should be always 32bit uid_t */ |
69 | #define SET_UID(var, uid) do { (var) = __convert_uid(sizeof(var), (uid)); } while (0) |
70 | #define SET_GID(var, gid) do { (var) = __convert_gid(sizeof(var), (gid)); } while (0) |
71 | |
72 | /* |
73 | * Everything below this line is needed on all architectures, to deal with |
74 | * filesystems that only store 16 bits of the UID/GID, etc. |
75 | */ |
76 | |
77 | /* |
78 | * This is the UID and GID that will get written to disk if a filesystem |
79 | * only supports 16-bit UIDs and the kernel has a high UID/GID to write |
80 | */ |
81 | extern int fs_overflowuid; |
82 | extern int fs_overflowgid; |
83 | |
84 | #define DEFAULT_FS_OVERFLOWUID 65534 |
85 | #define DEFAULT_FS_OVERFLOWGID 65534 |
86 | |
87 | /* |
88 | * Since these macros are used in architectures that only need limited |
89 | * 16-bit UID back compatibility, we won't use old_uid_t and old_gid_t |
90 | */ |
91 | #define fs_high2lowuid(uid) ((uid) & ~0xFFFF ? (uid16_t)fs_overflowuid : (uid16_t)(uid)) |
92 | #define fs_high2lowgid(gid) ((gid) & ~0xFFFF ? (gid16_t)fs_overflowgid : (gid16_t)(gid)) |
93 | |
94 | #define low_16_bits(x) ((x) & 0xFFFF) |
95 | #define high_16_bits(x) (((x) & 0xFFFF0000) >> 16) |
96 | |
97 | #endif /* _LINUX_HIGHUID_H */ |
98 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9