1 #ifndef FAKEROOT_COMMUNICATE_H
2 #define FAKEROOT_COMMUNICATE_H
5 #include "fakerootconfig.h"
9 /* I've got a chicken-and-egg problem here. I want to have
10 stat64 support, only running on glibc2.1 or later. To
11 find out what glibc we've got installed, I need to
12 #include <features.h>.
13 But, before including that file, I have to define _LARGEFILE64_SOURCE
14 etc, cause otherwise features.h will not define it's internal defines.
15 As I assume that pre-2.1 libc's will just ignore those _LARGEFILE64_SOURCE
16 defines, I hope I can get away with this approach:
19 /*First, unconditionally define these, so that glibc 2.1 features.h defines
20 the needed 64 bits defines*/
21 #ifndef _LARGEFILE64_SOURCE
22 # define _LARGEFILE64_SOURCE
24 #ifndef _LARGEFILE_SOURCE
25 # define _LARGEFILE_SOURCE
28 /* Then include features.h, to find out what glibc we run */
29 #ifdef HAVE_FEATURES_H
30 # include <features.h>
33 #ifdef HAVE_SYS_FEATURE_TESTS_H
34 # include <sys/feature_tests.h>
37 /* Then decide whether we do or do not use the stat64 support */
38 #if (defined(sun) && !defined(__SunOS_5_5_1) && !defined(_LP64)) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
39 # define STAT64_SUPPORT
41 # warning Not using stat64 support
42 /* if glibc is 2.0 or older, undefine these again */
43 # undef STAT64_SUPPORT
44 # undef _LARGEFILE64_SOURCE
45 # undef _LARGEFILE_SOURCE
48 /* Sparc glibc 2.0.100 is broken, dlsym segfaults on --fxstat64..
49 #define STAT64_SUPPORT */
51 #include <sys/types.h>
53 #include <sys/utsname.h>
57 #ifdef HAVE_INTTYPES_H
58 # include <inttypes.h>
61 #ifndef FAKEROOT_FAKENET
62 # define FAKEROOTKEY_ENV "FAKEROOTKEY"
63 #endif /* ! FAKEROOT_FAKENET */
65 #define FAKEROOTUID_ENV "FAKEROOTUID"
66 #define FAKEROOTGID_ENV "FAKEROOTGID"
67 #define FAKEROOTEUID_ENV "FAKEROOTEUID"
68 #define FAKEROOTEGID_ENV "FAKEROOTEGID"
69 #define FAKEROOTSUID_ENV "FAKEROOTSUID"
70 #define FAKEROOTSGID_ENV "FAKEROOTSGID"
71 #define FAKEROOTFUID_ENV "FAKEROOTFUID"
72 #define FAKEROOTFGID_ENV "FAKEROOTFGID"
73 #define FAKEROOTDONTTRYCHOWN_ENV "FAKEROOTDONTTRYCHOWN"
75 #define FAKELIBDIR "/usr/lib/fakeroot"
76 #define FAKELIBNAME "libfakeroot.so.0"
77 #ifdef FAKEROOT_FAKENET
78 # define FD_BASE_ENV "FAKEROOT_FD_BASE"
79 #endif /* FAKEROOT_FAKENET */
80 #ifdef FAKEROOT_DB_PATH
81 # define DB_SEARCH_PATHS_ENV "FAKEROOT_DB_SEARCH_PATHS"
82 #endif /* FAKEROOT_DB_PATH */
85 # define UNUSED __attribute__((unused))
91 # define S_ISTXT S_ISVTX
95 # define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
98 /* Define big enough _constant size_ types for the various types of the
99 stat struct. I cannot (or rather, shouldn't) use struct stat itself
100 in the communication between the fake-daemon and the client (libfake),
101 as the sizes elements of struct stat may depend on the compiler or
102 compile time options of the C compiler, or the C library used. Thus,
103 the fake-daemon may have to communicate with two clients that have
104 different views of struct stat (this is the case for libc5 and
105 libc6 (glibc2) compiled programmes on Linux). This currently isn't
106 enabled any more, but used to be in libtricks.
120 extern const char *env_var_set(const char *env);
121 #ifndef STUPID_ALPHA_HACK
122 extern void send_stat(const struct stat *st, func_id_t f);
124 extern void send_stat(const struct stat *st, func_id_t f,int ver);
126 extern void send_fakem(const struct fake_msg *buf);
127 #ifndef STUPID_ALPHA_HACK
128 extern void send_get_stat(struct stat *buf);
130 extern void send_get_stat(struct stat *buf,int ver);
132 extern void cpyfakefake (struct fakestat *b1, const struct fakestat *b2);
133 #ifndef STUPID_ALPHA_HACK
134 extern void cpystatfakem(struct stat *st, const struct fake_msg *buf);
136 extern void cpystatfakem(struct stat *st, const struct fake_msg *buf, int ver);
139 #ifndef FAKEROOT_FAKENET
140 extern int init_get_msg();
141 extern key_t get_ipc_key(key_t new_key);
142 # ifndef STUPID_ALPHA_HACK
143 extern void cpyfakemstat(struct fake_msg *b1, const struct stat *st);
145 extern void cpyfakemstat(struct fake_msg *b1, const struct stat *st, int ver);
147 #else /* FAKEROOT_FAKENET */
148 # ifdef FAKEROOT_LIBFAKEROOT
149 extern volatile int comm_sd;
150 extern void lock_comm_sd(void);
151 extern void unlock_comm_sd(void);
153 #endif /* FAKEROOT_FAKENET */
155 #ifdef STAT64_SUPPORT
156 #ifndef STUPID_ALPHA_HACK
157 extern void send_stat64(const struct stat64 *st, func_id_t f);
158 extern void send_get_stat64(struct stat64 *buf);
160 extern void send_stat64(const struct stat64 *st, func_id_t f, int ver);
161 extern void send_get_stat64(struct stat64 *buf, int ver);
163 extern void stat64from32(struct stat64 *s64, const struct stat *s32);
164 extern void stat32from64(struct stat *s32, const struct stat64 *s64);
167 #ifndef FAKEROOT_FAKENET
171 #endif /* ! FAKEROOT_FAKENET */