diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/highuid.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/linux/highuid.h')
-rw-r--r-- | include/linux/highuid.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/include/linux/highuid.h b/include/linux/highuid.h new file mode 100644 index 000000000000..53ecac3905e8 --- /dev/null +++ b/include/linux/highuid.h | |||
@@ -0,0 +1,98 @@ | |||
1 | #ifndef _LINUX_HIGHUID_H | ||
2 | #define _LINUX_HIGHUID_H | ||
3 | |||
4 | #include <linux/config.h> | ||
5 | #include <linux/types.h> | ||
6 | |||
7 | /* | ||
8 | * general notes: | ||
9 | * | ||
10 | * CONFIG_UID16 is defined if the given architecture needs to | ||
11 | * support backwards compatibility for old system calls. | ||
12 | * | ||
13 | * kernel code should use uid_t and gid_t at all times when dealing with | ||
14 | * kernel-private data. | ||
15 | * | ||
16 | * old_uid_t and old_gid_t should only be different if CONFIG_UID16 is | ||
17 | * defined, else the platform should provide dummy typedefs for them | ||
18 | * such that they are equivalent to __kernel_{u,g}id_t. | ||
19 | * | ||
20 | * uid16_t and gid16_t are used on all architectures. (when dealing | ||
21 | * with structures hard coded to 16 bits, such as in filesystems) | ||
22 | */ | ||
23 | |||
24 | |||
25 | /* | ||
26 | * This is the "overflow" UID and GID. They are used to signify uid/gid | ||
27 | * overflow to old programs when they request uid/gid information but are | ||
28 | * using the old 16 bit interfaces. | ||
29 | * When you run a libc5 program, it will think that all highuid files or | ||
30 | * processes are owned by this uid/gid. | ||
31 | * The idea is that it's better to do so than possibly return 0 in lieu of | ||
32 | * 65536, etc. | ||
33 | */ | ||
34 | |||
35 | extern int overflowuid; | ||
36 | extern int overflowgid; | ||
37 | |||
38 | extern void __bad_uid(void); | ||
39 | extern void __bad_gid(void); | ||
40 | |||
41 | #define DEFAULT_OVERFLOWUID 65534 | ||
42 | #define DEFAULT_OVERFLOWGID 65534 | ||
43 | |||
44 | #ifdef CONFIG_UID16 | ||
45 | |||
46 | /* prevent uid mod 65536 effect by returning a default value for high UIDs */ | ||
47 | #define high2lowuid(uid) ((uid) & ~0xFFFF ? (old_uid_t)overflowuid : (old_uid_t)(uid)) | ||
48 | #define high2lowgid(gid) ((gid) & ~0xFFFF ? (old_gid_t)overflowgid : (old_gid_t)(gid)) | ||
49 | /* | ||
50 | * -1 is different in 16 bits than it is in 32 bits | ||
51 | * these macros are used by chown(), setreuid(), ..., | ||
52 | */ | ||
53 | #define low2highuid(uid) ((uid) == (old_uid_t)-1 ? (uid_t)-1 : (uid_t)(uid)) | ||
54 | #define low2highgid(gid) ((gid) == (old_gid_t)-1 ? (gid_t)-1 : (gid_t)(gid)) | ||
55 | |||
56 | #define __convert_uid(size, uid) \ | ||
57 | (size >= sizeof(uid) ? (uid) : high2lowuid(uid)) | ||
58 | #define __convert_gid(size, gid) \ | ||
59 | (size >= sizeof(gid) ? (gid) : high2lowgid(gid)) | ||
60 | |||
61 | |||
62 | #else | ||
63 | |||
64 | #define __convert_uid(size, uid) (uid) | ||
65 | #define __convert_gid(size, gid) (gid) | ||
66 | |||
67 | #endif /* !CONFIG_UID16 */ | ||
68 | |||
69 | /* uid/gid input should be always 32bit uid_t */ | ||
70 | #define SET_UID(var, uid) do { (var) = __convert_uid(sizeof(var), (uid)); } while (0) | ||
71 | #define SET_GID(var, gid) do { (var) = __convert_gid(sizeof(var), (gid)); } while (0) | ||
72 | |||
73 | /* | ||
74 | * Everything below this line is needed on all architectures, to deal with | ||
75 | * filesystems that only store 16 bits of the UID/GID, etc. | ||
76 | */ | ||
77 | |||
78 | /* | ||
79 | * This is the UID and GID that will get written to disk if a filesystem | ||
80 | * only supports 16-bit UIDs and the kernel has a high UID/GID to write | ||
81 | */ | ||
82 | extern int fs_overflowuid; | ||
83 | extern int fs_overflowgid; | ||
84 | |||
85 | #define DEFAULT_FS_OVERFLOWUID 65534 | ||
86 | #define DEFAULT_FS_OVERFLOWGID 65534 | ||
87 | |||
88 | /* | ||
89 | * Since these macros are used in architectures that only need limited | ||
90 | * 16-bit UID back compatibility, we won't use old_uid_t and old_gid_t | ||
91 | */ | ||
92 | #define fs_high2lowuid(uid) ((uid) & ~0xFFFF ? (uid16_t)fs_overflowuid : (uid16_t)(uid)) | ||
93 | #define fs_high2lowgid(gid) ((gid) & ~0xFFFF ? (gid16_t)fs_overflowgid : (gid16_t)(gid)) | ||
94 | |||
95 | #define low_16_bits(x) ((x) & 0xFFFF) | ||
96 | #define high_16_bits(x) (((x) & 0xFFFF0000) >> 16) | ||
97 | |||
98 | #endif /* _LINUX_HIGHUID_H */ | ||