| @@ -1,538 +1,542 @@ | | | @@ -1,538 +1,542 @@ |
1 | /* $NetBSD: am_utils.h,v 1.1.1.3 2015/01/17 16:34:18 christos Exp $ */ | | 1 | /* $NetBSD: am_utils.h,v 1.2 2015/10/14 16:00:17 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1997-2014 Erez Zadok | | 4 | * Copyright (c) 1997-2014 Erez Zadok |
5 | * Copyright (c) 1990 Jan-Simon Pendry | | 5 | * Copyright (c) 1990 Jan-Simon Pendry |
6 | * Copyright (c) 1990 Imperial College of Science, Technology & Medicine | | 6 | * Copyright (c) 1990 Imperial College of Science, Technology & Medicine |
7 | * Copyright (c) 1990 The Regents of the University of California. | | 7 | * Copyright (c) 1990 The Regents of the University of California. |
8 | * All rights reserved. | | 8 | * All rights reserved. |
9 | * | | 9 | * |
10 | * This code is derived from software contributed to Berkeley by | | 10 | * This code is derived from software contributed to Berkeley by |
11 | * Jan-Simon Pendry at Imperial College, London. | | 11 | * Jan-Simon Pendry at Imperial College, London. |
12 | * | | 12 | * |
13 | * Redistribution and use in source and binary forms, with or without | | 13 | * Redistribution and use in source and binary forms, with or without |
14 | * modification, are permitted provided that the following conditions | | 14 | * modification, are permitted provided that the following conditions |
15 | * are met: | | 15 | * are met: |
16 | * 1. Redistributions of source code must retain the above copyright | | 16 | * 1. Redistributions of source code must retain the above copyright |
17 | * notice, this list of conditions and the following disclaimer. | | 17 | * notice, this list of conditions and the following disclaimer. |
18 | * 2. Redistributions in binary form must reproduce the above copyright | | 18 | * 2. Redistributions in binary form must reproduce the above copyright |
19 | * notice, this list of conditions and the following disclaimer in the | | 19 | * notice, this list of conditions and the following disclaimer in the |
20 | * documentation and/or other materials provided with the distribution. | | 20 | * documentation and/or other materials provided with the distribution. |
21 | * 3. Neither the name of the University nor the names of its contributors | | 21 | * 3. Neither the name of the University nor the names of its contributors |
22 | * may be used to endorse or promote products derived from this software | | 22 | * may be used to endorse or promote products derived from this software |
23 | * without specific prior written permission. | | 23 | * without specific prior written permission. |
24 | * | | 24 | * |
25 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 25 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
35 | * SUCH DAMAGE. | | 35 | * SUCH DAMAGE. |
36 | * | | 36 | * |
37 | * | | 37 | * |
38 | * File: am-utils/include/am_utils.h | | 38 | * File: am-utils/include/am_utils.h |
39 | * | | 39 | * |
40 | */ | | 40 | */ |
41 | | | 41 | |
42 | /* | | 42 | /* |
43 | * Definitions that are specific to the am-utils package. | | 43 | * Definitions that are specific to the am-utils package. |
44 | */ | | 44 | */ |
45 | | | 45 | |
46 | #ifndef _AM_UTILS_H | | 46 | #ifndef _AM_UTILS_H |
47 | #define _AM_UTILS_H | | 47 | #define _AM_UTILS_H |
48 | | | 48 | |
49 | | | 49 | |
50 | #include "aux_conf.h" | | 50 | #include "aux_conf.h" |
51 | | | 51 | |
52 | /**************************************************************************/ | | 52 | /**************************************************************************/ |
53 | /*** MACROS ***/ | | 53 | /*** MACROS ***/ |
54 | /**************************************************************************/ | | 54 | /**************************************************************************/ |
55 | | | 55 | |
| | | 56 | #if !defined(__syslog_attribute__) && !defined(__syslog__) |
| | | 57 | #define __syslog__ __printf__ |
| | | 58 | #endif |
| | | 59 | |
56 | /* | | 60 | /* |
57 | * General macros. | | 61 | * General macros. |
58 | */ | | 62 | */ |
59 | #ifndef FALSE | | 63 | #ifndef FALSE |
60 | # define FALSE 0 | | 64 | # define FALSE 0 |
61 | #endif /* not FALSE */ | | 65 | #endif /* not FALSE */ |
62 | #ifndef TRUE | | 66 | #ifndef TRUE |
63 | # define TRUE 1 | | 67 | # define TRUE 1 |
64 | #endif /* not TRUE */ | | 68 | #endif /* not TRUE */ |
65 | #ifndef MAX | | 69 | #ifndef MAX |
66 | # define MAX(a, b) ((a) > (b) ? (a) : (b)) | | 70 | # define MAX(a, b) ((a) > (b) ? (a) : (b)) |
67 | #endif /* not MAX */ | | 71 | #endif /* not MAX */ |
68 | #ifndef MIN | | 72 | #ifndef MIN |
69 | # define MIN(a, b) ((a) < (b) ? (a) : (b)) | | 73 | # define MIN(a, b) ((a) < (b) ? (a) : (b)) |
70 | #endif /* not MIN */ | | 74 | #endif /* not MIN */ |
71 | | | 75 | |
72 | #define ONE_HOUR (60 * 60) /* One hour in seconds */ | | 76 | #define ONE_HOUR (60 * 60) /* One hour in seconds */ |
73 | | | 77 | |
74 | #ifndef MAXHOSTNAMELEN | | 78 | #ifndef MAXHOSTNAMELEN |
75 | # ifdef HOSTNAMESZ | | 79 | # ifdef HOSTNAMESZ |
76 | # define MAXHOSTNAMELEN HOSTNAMESZ | | 80 | # define MAXHOSTNAMELEN HOSTNAMESZ |
77 | # else /* not HOSTNAMESZ */ | | 81 | # else /* not HOSTNAMESZ */ |
78 | # define MAXHOSTNAMELEN 256 | | 82 | # define MAXHOSTNAMELEN 256 |
79 | # endif /* not HOSTNAMESZ */ | | 83 | # endif /* not HOSTNAMESZ */ |
80 | #endif /* not MAXHOSTNAMELEN */ | | 84 | #endif /* not MAXHOSTNAMELEN */ |
81 | | | 85 | |
82 | /* | | 86 | /* |
83 | * for hlfsd, and amd for detecting uid/gid | | 87 | * for hlfsd, and amd for detecting uid/gid |
84 | */ | | 88 | */ |
85 | #ifndef INVALIDID | | 89 | #ifndef INVALIDID |
86 | /* this is also defined in include/am_utils.h */ | | 90 | /* this is also defined in include/am_utils.h */ |
87 | # define INVALIDID (((unsigned short) ~0) - 3) | | 91 | # define INVALIDID (((unsigned short) ~0) - 3) |
88 | #endif /* not INVALIDID */ | | 92 | #endif /* not INVALIDID */ |
89 | | | 93 | |
90 | /* | | 94 | /* |
91 | * String comparison macros | | 95 | * String comparison macros |
92 | */ | | 96 | */ |
93 | #define STREQ(s1, s2) (strcmp((s1), (s2)) == 0) | | 97 | #define STREQ(s1, s2) (strcmp((s1), (s2)) == 0) |
94 | #define STRCEQ(s1, s2) (strcasecmp((s1), (s2)) == 0) | | 98 | #define STRCEQ(s1, s2) (strcasecmp((s1), (s2)) == 0) |
95 | #define NSTREQ(s1, s2, n) (strncmp((s1), (s2), (n)) == 0) | | 99 | #define NSTREQ(s1, s2, n) (strncmp((s1), (s2), (n)) == 0) |
96 | #define NSTRCEQ(s1, s2, n) (strncasecmp((s1), (s2), (n)) == 0) | | 100 | #define NSTRCEQ(s1, s2, n) (strncasecmp((s1), (s2), (n)) == 0) |
97 | #define FSTREQ(s1, s2) ((*(s1) == *(s2)) && STREQ((s1),(s2))) | | 101 | #define FSTREQ(s1, s2) ((*(s1) == *(s2)) && STREQ((s1),(s2))) |
98 | | | 102 | |
99 | /* | | 103 | /* |
100 | * Logging options/flags | | 104 | * Logging options/flags |
101 | */ | | 105 | */ |
102 | #define XLOG_FATAL 0x0001 | | 106 | #define XLOG_FATAL 0x0001 |
103 | #define XLOG_ERROR 0x0002 | | 107 | #define XLOG_ERROR 0x0002 |
104 | #define XLOG_USER 0x0004 | | 108 | #define XLOG_USER 0x0004 |
105 | #define XLOG_WARNING 0x0008 | | 109 | #define XLOG_WARNING 0x0008 |
106 | #define XLOG_INFO 0x0010 | | 110 | #define XLOG_INFO 0x0010 |
107 | #define XLOG_DEBUG 0x0020 | | 111 | #define XLOG_DEBUG 0x0020 |
108 | #define XLOG_MAP 0x0040 | | 112 | #define XLOG_MAP 0x0040 |
109 | #define XLOG_STATS 0x0080 | | 113 | #define XLOG_STATS 0x0080 |
110 | /* log option compositions */ | | 114 | /* log option compositions */ |
111 | #define XLOG_MASK 0x00ff /* mask for all flags */ | | 115 | #define XLOG_MASK 0x00ff /* mask for all flags */ |
112 | #define XLOG_MANDATORY (XLOG_FATAL|XLOG_ERROR) /* cannot turn these off */ | | 116 | #define XLOG_MANDATORY (XLOG_FATAL|XLOG_ERROR) /* cannot turn these off */ |
113 | #define XLOG_ALL (XLOG_FATAL|XLOG_ERROR|XLOG_USER|XLOG_WARNING|XLOG_INFO|XLOG_MAP|XLOG_STATS) | | 117 | #define XLOG_ALL (XLOG_FATAL|XLOG_ERROR|XLOG_USER|XLOG_WARNING|XLOG_INFO|XLOG_MAP|XLOG_STATS) |
114 | /* default: fatal + error + user + warning + info */ | | 118 | /* default: fatal + error + user + warning + info */ |
115 | #define XLOG_DEFAULT (XLOG_MASK & (XLOG_ALL & ~XLOG_MAP & ~XLOG_STATS)) | | 119 | #define XLOG_DEFAULT (XLOG_MASK & (XLOG_ALL & ~XLOG_MAP & ~XLOG_STATS)) |
116 | | | 120 | |
117 | /* default: no logging options */ | | 121 | /* default: no logging options */ |
118 | | | 122 | |
119 | #define NO_SUBNET "notknown" /* default subnet name for no subnet */ | | 123 | #define NO_SUBNET "notknown" /* default subnet name for no subnet */ |
120 | #define NEXP_AP (1022) /* gdmr: was 254 */ | | 124 | #define NEXP_AP (1022) /* gdmr: was 254 */ |
121 | #define NEXP_AP_MARGIN (128) /* ???? not used */ | | 125 | #define NEXP_AP_MARGIN (128) /* ???? not used */ |
122 | | | 126 | |
123 | /* | | 127 | /* |
124 | * Linked list macros | | 128 | * Linked list macros |
125 | */ | | 129 | */ |
126 | #define AM_FIRST(ty, q) ((ty *) ((q)->q_forw)) | | 130 | #define AM_FIRST(ty, q) ((ty *) ((q)->q_forw)) |
127 | #define AM_LAST(ty, q) ((ty *) ((q)->q_back)) | | 131 | #define AM_LAST(ty, q) ((ty *) ((q)->q_back)) |
128 | #define NEXT(ty, q) ((ty *) (((qelem *) q)->q_forw)) | | 132 | #define NEXT(ty, q) ((ty *) (((qelem *) q)->q_forw)) |
129 | #define PREV(ty, q) ((ty *) (((qelem *) q)->q_back)) | | 133 | #define PREV(ty, q) ((ty *) (((qelem *) q)->q_back)) |
130 | #define HEAD(ty, q) ((ty *) q) | | 134 | #define HEAD(ty, q) ((ty *) q) |
131 | #define ITER(v, ty, q) \ | | 135 | #define ITER(v, ty, q) \ |
132 | for ((v) = AM_FIRST(ty,(q)); (v) != HEAD(ty,(q)); (v) = NEXT(ty,(v))) | | 136 | for ((v) = AM_FIRST(ty,(q)); (v) != HEAD(ty,(q)); (v) = NEXT(ty,(v))) |
133 | | | 137 | |
134 | /* allocate anything of type ty */ | | 138 | /* allocate anything of type ty */ |
135 | #define ALLOC(ty) ((ty *) xmalloc(sizeof(ty))) | | 139 | #define ALLOC(ty) ((ty *) xmalloc(sizeof(ty))) |
136 | #define CALLOC(ty) ((ty *) xzalloc(sizeof(ty))) | | 140 | #define CALLOC(ty) ((ty *) xzalloc(sizeof(ty))) |
137 | /* simply allocate b bytes */ | | 141 | /* simply allocate b bytes */ |
138 | #define SALLOC(b) xmalloc((b)) | | 142 | #define SALLOC(b) xmalloc((b)) |
139 | | | 143 | |
140 | /* | | 144 | /* |
141 | * Systems which have the mount table in a file need to read it before | | 145 | * Systems which have the mount table in a file need to read it before |
142 | * they can perform an unmount() system call. | | 146 | * they can perform an unmount() system call. |
143 | */ | | 147 | */ |
144 | #define UMOUNT_FS(dir, mtb_name, unmount_flags) umount_fs(dir, mtb_name, unmount_flags) | | 148 | #define UMOUNT_FS(dir, mtb_name, unmount_flags) umount_fs(dir, mtb_name, unmount_flags) |
145 | /* next two are imported via $srcdir/conf/umount/umount_*.c */ | | 149 | /* next two are imported via $srcdir/conf/umount/umount_*.c */ |
146 | extern int umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags); | | 150 | extern int umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags); |
147 | #ifdef MNT2_GEN_OPT_FORCE | | 151 | #ifdef MNT2_GEN_OPT_FORCE |
148 | extern int umount2_fs(const char *mntdir, u_int unmount_flags); | | 152 | extern int umount2_fs(const char *mntdir, u_int unmount_flags); |
149 | #endif /* MNT2_GEN_OPT_FORCE */ | | 153 | #endif /* MNT2_GEN_OPT_FORCE */ |
150 | | | 154 | |
151 | /* unmount-related flags (special handling of autofs, forced/lazy, etc.) */ | | 155 | /* unmount-related flags (special handling of autofs, forced/lazy, etc.) */ |
152 | #define AMU_UMOUNT_FORCE 0x1 | | 156 | #define AMU_UMOUNT_FORCE 0x1 |
153 | #define AMU_UMOUNT_DETACH 0x2 | | 157 | #define AMU_UMOUNT_DETACH 0x2 |
154 | #define AMU_UMOUNT_AUTOFS 0x4 | | 158 | #define AMU_UMOUNT_AUTOFS 0x4 |
155 | | | 159 | |
156 | /* | | 160 | /* |
157 | * The following values can be tuned... | | 161 | * The following values can be tuned... |
158 | */ | | 162 | */ |
159 | #define ALLOWED_MOUNT_TIME 40 /* 40s for a mount */ | | 163 | #define ALLOWED_MOUNT_TIME 40 /* 40s for a mount */ |
160 | | | 164 | |
161 | /* | | 165 | /* |
162 | * RPC-related macros. | | 166 | * RPC-related macros. |
163 | */ | | 167 | */ |
164 | #define RPC_XID_PORTMAP 0 | | 168 | #define RPC_XID_PORTMAP 0 |
165 | #define RPC_XID_MOUNTD 1 | | 169 | #define RPC_XID_MOUNTD 1 |
166 | #define RPC_XID_NFSPING 2 | | 170 | #define RPC_XID_NFSPING 2 |
167 | #define RPC_XID_WEBNFS 3 | | 171 | #define RPC_XID_WEBNFS 3 |
168 | #define RPC_XID_MASK (0x0f) /* 16 id's for now */ | | 172 | #define RPC_XID_MASK (0x0f) /* 16 id's for now */ |
169 | #define MK_RPC_XID(type_id, uniq) ((type_id) | ((uniq) << 4)) | | 173 | #define MK_RPC_XID(type_id, uniq) ((type_id) | ((uniq) << 4)) |
170 | | | 174 | |
171 | /* | | 175 | /* |
172 | * What level of AMD are we backward compatible with? | | 176 | * What level of AMD are we backward compatible with? |
173 | * This only applies to externally visible characteristics. | | 177 | * This only applies to externally visible characteristics. |
174 | * Rev.Minor.Branch.Patch (2 digits each) | | 178 | * Rev.Minor.Branch.Patch (2 digits each) |
175 | */ | | 179 | */ |
176 | #define AMD_COMPAT 5000000 /* 5.0 */ | | 180 | #define AMD_COMPAT 5000000 /* 5.0 */ |
177 | | | 181 | |
178 | | | 182 | |
179 | /**************************************************************************/ | | 183 | /**************************************************************************/ |
180 | /*** STRUCTURES AND TYPEDEFS ***/ | | 184 | /*** STRUCTURES AND TYPEDEFS ***/ |
181 | /**************************************************************************/ | | 185 | /**************************************************************************/ |
182 | | | 186 | |
183 | /* some typedefs must come first */ | | 187 | /* some typedefs must come first */ |
184 | typedef char *amq_string; | | 188 | typedef char *amq_string; |
185 | typedef struct _qelem qelem; | | 189 | typedef struct _qelem qelem; |
186 | typedef struct mntlist mntlist; | | 190 | typedef struct mntlist mntlist; |
187 | | | 191 | |
188 | /* | | 192 | /* |
189 | * Linked list | | 193 | * Linked list |
190 | * (the name 'struct qelem' conflicts with linux's unistd.h) | | 194 | * (the name 'struct qelem' conflicts with linux's unistd.h) |
191 | */ | | 195 | */ |
192 | struct _qelem { | | 196 | struct _qelem { |
193 | qelem *q_forw; | | 197 | qelem *q_forw; |
194 | qelem *q_back; | | 198 | qelem *q_back; |
195 | }; | | 199 | }; |
196 | | | 200 | |
197 | /* | | 201 | /* |
198 | * Option tables | | 202 | * Option tables |
199 | */ | | 203 | */ |
200 | struct opt_tab { | | 204 | struct opt_tab { |
201 | char *opt; | | 205 | char *opt; |
202 | int flag; | | 206 | int flag; |
203 | }; | | 207 | }; |
204 | | | 208 | |
205 | /* | | 209 | /* |
206 | * Server states | | 210 | * Server states |
207 | */ | | 211 | */ |
208 | typedef enum { | | 212 | typedef enum { |
209 | Start, | | 213 | Start, |
210 | Run, | | 214 | Run, |
211 | Finishing, | | 215 | Finishing, |
212 | Quit, | | 216 | Quit, |
213 | Done | | 217 | Done |
214 | } serv_state; | | 218 | } serv_state; |
215 | | | 219 | |
216 | | | 220 | |
217 | /* | | 221 | /* |
218 | * List of mount table entries | | 222 | * List of mount table entries |
219 | */ | | 223 | */ |
220 | struct mntlist { | | 224 | struct mntlist { |
221 | struct mntlist *mnext; | | 225 | struct mntlist *mnext; |
222 | mntent_t *mnt; | | 226 | mntent_t *mnt; |
223 | }; | | 227 | }; |
224 | | | 228 | |
225 | /* | | 229 | /* |
226 | * Mount map | | 230 | * Mount map |
227 | */ | | 231 | */ |
228 | typedef struct mnt_map mnt_map; | | 232 | typedef struct mnt_map mnt_map; |
229 | | | 233 | |
230 | | | 234 | |
231 | /**************************************************************************/ | | 235 | /**************************************************************************/ |
232 | /*** EXTERNALS ***/ | | 236 | /*** EXTERNALS ***/ |
233 | /**************************************************************************/ | | 237 | /**************************************************************************/ |
234 | | | 238 | |
235 | /* | | 239 | /* |
236 | * Useful constants | | 240 | * Useful constants |
237 | */ | | 241 | */ |
238 | extern char *mnttab_file_name; /* Mount table */ | | 242 | extern char *mnttab_file_name; /* Mount table */ |
239 | extern char *cpu; /* "CPU type" */ | | 243 | extern char *cpu; /* "CPU type" */ |
240 | extern char *endian; /* "big" */ | | 244 | extern char *endian; /* "big" */ |
241 | extern char *hostdomain; /* "southseas.nz" */ | | 245 | extern char *hostdomain; /* "southseas.nz" */ |
242 | extern char copyright[]; /* Copyright info */ | | 246 | extern char copyright[]; /* Copyright info */ |
243 | extern char version[]; /* Version info */ | | 247 | extern char version[]; /* Version info */ |
244 | | | 248 | |
245 | /* | | 249 | /* |
246 | * Global variables. | | 250 | * Global variables. |
247 | */ | | 251 | */ |
248 | extern AUTH *nfs_auth; /* Dummy authorization for remote servers */ | | 252 | extern AUTH *nfs_auth; /* Dummy authorization for remote servers */ |
249 | extern FILE *logfp; /* Log file */ | | 253 | extern FILE *logfp; /* Log file */ |
250 | extern SVCXPRT *nfsxprt; | | 254 | extern SVCXPRT *nfsxprt; |
251 | extern char *PrimNetName; /* Name of primary connected network */ | | 255 | extern char *PrimNetName; /* Name of primary connected network */ |
252 | extern char *PrimNetNum; /* Name of primary connected network */ | | 256 | extern char *PrimNetNum; /* Name of primary connected network */ |
253 | extern char *SubsNetName; /* Name of subsidiary connected network */ | | 257 | extern char *SubsNetName; /* Name of subsidiary connected network */ |
254 | extern char *SubsNetNum; /* Name of subsidiary connected network */ | | 258 | extern char *SubsNetNum; /* Name of subsidiary connected network */ |
255 | | | 259 | |
256 | extern void am_set_progname(char *pn); /* "amd" */ | | 260 | extern void am_set_progname(char *pn); /* "amd" */ |
257 | extern const char *am_get_progname(void); /* "amd" */ | | 261 | extern const char *am_get_progname(void); /* "amd" */ |
258 | extern void am_set_hostname(char *hn); | | 262 | extern void am_set_hostname(char *hn); |
259 | extern const char *am_get_hostname(void); | | 263 | extern const char *am_get_hostname(void); |
260 | extern pid_t am_set_mypid(void); | | 264 | extern pid_t am_set_mypid(void); |
261 | extern pid_t am_mypid; | | 265 | extern pid_t am_mypid; |
262 | | | 266 | |
263 | extern int foreground; /* Foreground process */ | | 267 | extern int foreground; /* Foreground process */ |
264 | extern int orig_umask; /* umask() on startup */ | | 268 | extern int orig_umask; /* umask() on startup */ |
265 | extern serv_state amd_state; /* Should we go now */ | | 269 | extern serv_state amd_state; /* Should we go now */ |
266 | extern struct in_addr myipaddr; /* (An) IP address of this host */ | | 270 | extern struct in_addr myipaddr; /* (An) IP address of this host */ |
267 | extern struct opt_tab xlog_opt[]; | | 271 | extern struct opt_tab xlog_opt[]; |
268 | extern u_short nfs_port; /* Our NFS service port */ | | 272 | extern u_short nfs_port; /* Our NFS service port */ |
269 | | | 273 | |
270 | /* | | 274 | /* |
271 | * Global routines | | 275 | * Global routines |
272 | */ | | 276 | */ |
273 | extern CLIENT *get_mount_client(char *unused_host, struct sockaddr_in *sin, struct timeval *tv, int *sock, u_long mnt_version); | | 277 | extern CLIENT *get_mount_client(char *unused_host, struct sockaddr_in *sin, struct timeval *tv, int *sock, u_long mnt_version); |
274 | extern RETSIGTYPE sigchld(int); | | 278 | extern RETSIGTYPE sigchld(int); |
275 | extern bool_t xdr_amq_string(XDR *xdrs, amq_string *objp); | | 279 | extern bool_t xdr_amq_string(XDR *xdrs, amq_string *objp); |
276 | extern bool_t xdr_dirpath(XDR *xdrs, dirpath *objp); | | 280 | extern bool_t xdr_dirpath(XDR *xdrs, dirpath *objp); |
277 | extern char **strsplit(char *, int, int); | | 281 | extern char **strsplit(char *, int, int); |
278 | extern char *expand_selectors(char *); | | 282 | extern char *expand_selectors(char *); |
279 | extern char *get_version_string(void); | | 283 | extern char *get_version_string(void); |
280 | extern char *inet_dquad(char *, size_t, u_long); | | 284 | extern char *inet_dquad(char *, size_t, u_long); |
281 | extern char *print_wires(void); | | 285 | extern char *print_wires(void); |
282 | extern char *str3cat(char *, char *, char *, char *); | | 286 | extern char *str3cat(char *, char *, char *, char *); |
283 | extern char *strvcat(const char *, ...); | | 287 | extern char *strvcat(const char *, ...); |
284 | extern char *strealloc(char *, char *); | | 288 | extern char *strealloc(char *, char *); |
285 | extern char *strip_selectors(char *, char *); | | 289 | extern char *strip_selectors(char *, char *); |
286 | extern char *strnsave(const char *, int); | | 290 | extern char *strnsave(const char *, int); |
287 | extern int amu_close(int fd); | | 291 | extern int amu_close(int fd); |
288 | extern int bind_resv_port(int, u_short *); | | 292 | extern int bind_resv_port(int, u_short *); |
289 | extern int cmdoption(char *, struct opt_tab *, u_int *); | | 293 | extern int cmdoption(char *, struct opt_tab *, u_int *); |
290 | extern int compute_automounter_mount_flags(mntent_t *); | | 294 | extern int compute_automounter_mount_flags(mntent_t *); |
291 | extern int compute_mount_flags(mntent_t *); | | 295 | extern int compute_mount_flags(mntent_t *); |
292 | extern void discard_nfs_args(void *, u_long); | | 296 | extern void discard_nfs_args(void *, u_long); |
293 | extern u_long get_amd_program_number(void); | | 297 | extern u_long get_amd_program_number(void); |
294 | extern int getcreds(struct svc_req *, uid_t *, gid_t *, SVCXPRT *); | | 298 | extern int getcreds(struct svc_req *, uid_t *, gid_t *, SVCXPRT *); |
295 | extern int hasmntval(mntent_t *, char *); | | 299 | extern int hasmntval(mntent_t *, char *); |
296 | extern unsigned int hasmntvalerr(mntent_t *, char *, int *); | | 300 | extern unsigned int hasmntvalerr(mntent_t *, char *, int *); |
297 | extern char *hasmntstr(mntent_t *, char *); | | 301 | extern char *hasmntstr(mntent_t *, char *); |
298 | extern char *hasmnteq(mntent_t *, char *); | | 302 | extern char *hasmnteq(mntent_t *, char *); |
299 | extern char *haseq(char *); | | 303 | extern char *haseq(char *); |
300 | extern int is_network_member(const char *net); | | 304 | extern int is_network_member(const char *net); |
301 | extern int is_interface_local(u_long); | | 305 | extern int is_interface_local(u_long); |
302 | extern int islocalnet(u_long); | | 306 | extern int islocalnet(u_long); |
303 | extern int make_rpc_packet(char *, int, u_long, struct rpc_msg *, voidp, XDRPROC_T_TYPE, AUTH *); | | 307 | extern int make_rpc_packet(char *, int, u_long, struct rpc_msg *, voidp, XDRPROC_T_TYPE, AUTH *); |
304 | extern int mkdirs(char *, int); | | 308 | extern int mkdirs(char *, int); |
305 | extern int mount_fs(mntent_t *, int, caddr_t, int, MTYPE_TYPE, u_long, const char *, const char *, int); | | 309 | extern int mount_fs(mntent_t *, int, caddr_t, int, MTYPE_TYPE, u_long, const char *, const char *, int); |
306 | extern void nfs_program_2(struct svc_req *rqstp, SVCXPRT *transp); | | 310 | extern void nfs_program_2(struct svc_req *rqstp, SVCXPRT *transp); |
307 | extern void nfs_program_3(struct svc_req *rqstp, SVCXPRT *transp); | | 311 | extern void nfs_program_3(struct svc_req *rqstp, SVCXPRT *transp); |
308 | #define get_nfs_dispatcher_version(a) \ | | 312 | #define get_nfs_dispatcher_version(a) \ |
309 | ((a) == nfs_program_2 ? NFS_VERSION : NFS_VERSION3) | | 313 | ((a) == nfs_program_2 ? NFS_VERSION : NFS_VERSION3) |
310 | extern int pickup_rpc_reply(voidp, int, voidp, XDRPROC_T_TYPE); | | 314 | extern int pickup_rpc_reply(voidp, int, voidp, XDRPROC_T_TYPE); |
311 | extern int switch_option(char *); | | 315 | extern int switch_option(char *); |
312 | extern int switch_to_logfile(char *logfile, int orig_umask, int truncate_log); | | 316 | extern int switch_to_logfile(char *logfile, int orig_umask, int truncate_log); |
313 | extern mntlist *read_mtab(char *, const char *); | | 317 | extern mntlist *read_mtab(char *, const char *); |
314 | #ifndef HAVE_TRANSPORT_TYPE_TLI | | 318 | #ifndef HAVE_TRANSPORT_TYPE_TLI |
315 | extern struct sockaddr_in *amu_svc_getcaller(SVCXPRT *xprt); | | 319 | extern struct sockaddr_in *amu_svc_getcaller(SVCXPRT *xprt); |
316 | #endif /* not HAVE_TRANSPORT_TYPE_TLI */ | | 320 | #endif /* not HAVE_TRANSPORT_TYPE_TLI */ |
317 | extern time_t time(time_t *); | | 321 | extern time_t time(time_t *); |
318 | extern void amu_get_myaddress(struct in_addr *iap, const char *preferred_localhost); | | 322 | extern void amu_get_myaddress(struct in_addr *iap, const char *preferred_localhost); |
319 | extern void amu_release_controlling_tty(void); | | 323 | extern void amu_release_controlling_tty(void); |
320 | extern void compute_automounter_nfs_args(nfs_args_t *nap, mntent_t *mntp); | | 324 | extern void compute_automounter_nfs_args(nfs_args_t *nap, mntent_t *mntp); |
321 | extern void discard_mntlist(mntlist *mp); | | 325 | extern void discard_mntlist(mntlist *mp); |
322 | extern void free_mntlist(mntlist *); | | 326 | extern void free_mntlist(mntlist *); |
323 | extern void getwire(char **name1, char **number1); | | 327 | extern void getwire(char **name1, char **number1); |
324 | extern void going_down(int); | | 328 | extern void going_down(int); |
325 | extern void mnt_free(mntent_t *); | | 329 | extern void mnt_free(mntent_t *); |
326 | extern void plog(int, const char *,...) | | 330 | extern void plog(int, const char *,...) |
327 | __attribute__ ((__format__ (__printf__, 2, 3))); | | 331 | __attribute__ ((__format__ (__syslog__, 2, 3))); |
328 | extern void rmdirs(char *); | | 332 | extern void rmdirs(char *); |
329 | extern void rpc_msg_init(struct rpc_msg *, u_long, u_long, u_long); | | 333 | extern void rpc_msg_init(struct rpc_msg *, u_long, u_long, u_long); |
330 | extern void set_amd_program_number(u_long program); | | 334 | extern void set_amd_program_number(u_long program); |
331 | extern void show_opts(int ch, struct opt_tab *); | | 335 | extern void show_opts(int ch, struct opt_tab *); |
332 | extern void unregister_amq(void); | | 336 | extern void unregister_amq(void); |
333 | extern voidp xmalloc(int); | | 337 | extern voidp xmalloc(int); |
334 | extern voidp xrealloc(voidp, int); | | 338 | extern voidp xrealloc(voidp, int); |
335 | extern voidp xzalloc(int); | | 339 | extern voidp xzalloc(int); |
336 | extern char *xstrdup(const char *); | | 340 | extern char *xstrdup(const char *); |
337 | extern int check_pmap_up(char *host, struct sockaddr_in* sin); | | 341 | extern int check_pmap_up(char *host, struct sockaddr_in* sin); |
338 | extern u_long get_nfs_version(char *host, struct sockaddr_in *sin, u_long nfs_version, const char *proto, u_long def); | | 342 | extern u_long get_nfs_version(char *host, struct sockaddr_in *sin, u_long nfs_version, const char *proto, u_long def); |
339 | extern int nfs_valid_version(u_long vers); | | 343 | extern int nfs_valid_version(u_long vers); |
340 | extern long get_server_pid(void); | | 344 | extern long get_server_pid(void); |
341 | extern void setup_sighandler(int signum, void (*handler)(int)); | | 345 | extern void setup_sighandler(int signum, void (*handler)(int)); |
342 | extern time_t clocktime(nfstime *nt); | | 346 | extern time_t clocktime(nfstime *nt); |
343 | | | 347 | |
344 | #if defined(DEBUG) && (defined(HAVE_C99_VARARGS_MACROS) || defined(HAVE_GCC_VARARGS_MACROS)) | | 348 | #if defined(DEBUG) && (defined(HAVE_C99_VARARGS_MACROS) || defined(HAVE_GCC_VARARGS_MACROS)) |
345 | # ifdef HAVE_C99_VARARGS_MACROS | | 349 | # ifdef HAVE_C99_VARARGS_MACROS |
346 | #define xsnprintf(str,size,fmt,...) _xsnprintf(__FILE__,__LINE__,(str),(size),(fmt),__VA_ARGS__) | | 350 | #define xsnprintf(str,size,fmt,...) _xsnprintf(__FILE__,__LINE__,(str),(size),(fmt),__VA_ARGS__) |
347 | # endif /* HAVE_C99_VARARGS_MACROS */ | | 351 | # endif /* HAVE_C99_VARARGS_MACROS */ |
348 | # ifdef HAVE_GCC_VARARGS_MACROS | | 352 | # ifdef HAVE_GCC_VARARGS_MACROS |
349 | #define xsnprintf(str,size,fmt,args...) _xsnprintf(__FILE__,__LINE__,(str),(size),(fmt),args) | | 353 | #define xsnprintf(str,size,fmt,args...) _xsnprintf(__FILE__,__LINE__,(str),(size),(fmt),args) |
350 | # endif /* HAVE_GCC_VARARGS_MACROS */ | | 354 | # endif /* HAVE_GCC_VARARGS_MACROS */ |
351 | extern int _xsnprintf(const char *filename, int lineno, char *str, size_t size, const char *format, ...); | | 355 | extern int _xsnprintf(const char *filename, int lineno, char *str, size_t size, const char *format, ...); |
352 | #define xvsnprintf(str,size,fmt,ap) _xvsnprintf(__FILE__,__LINE__,(str),(size),(fmt),(ap)) | | 356 | #define xvsnprintf(str,size,fmt,ap) _xvsnprintf(__FILE__,__LINE__,(str),(size),(fmt),(ap)) |
353 | extern int _xvsnprintf(const char *filename, int lineno, char *str, size_t size, const char *format, va_list ap); | | 357 | extern int _xvsnprintf(const char *filename, int lineno, char *str, size_t size, const char *format, va_list ap); |
354 | #else /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ | | 358 | #else /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ |
355 | extern int xsnprintf(char *str, size_t size, const char *format, ...); | | 359 | extern int xsnprintf(char *str, size_t size, const char *format, ...); |
356 | extern int xvsnprintf(char *str, size_t size, const char *format, va_list ap); | | 360 | extern int xvsnprintf(char *str, size_t size, const char *format, va_list ap); |
357 | #endif /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ | | 361 | #endif /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ |
358 | | | 362 | |
359 | #ifdef DEBUG | | 363 | #ifdef DEBUG |
360 | extern void _xstrlcat(const char *filename, int lineno, char *dst, const char *src, size_t len); | | 364 | extern void _xstrlcat(const char *filename, int lineno, char *dst, const char *src, size_t len); |
361 | # define xstrlcat(d,s,l) _xstrlcat(__FILE__,__LINE__,(d),(s),(l)) | | 365 | # define xstrlcat(d,s,l) _xstrlcat(__FILE__,__LINE__,(d),(s),(l)) |
362 | extern void _xstrlcpy(const char *filename, int lineno, char *dst, const char *src, size_t len); | | 366 | extern void _xstrlcpy(const char *filename, int lineno, char *dst, const char *src, size_t len); |
363 | # define xstrlcpy(d,s,l) _xstrlcpy(__FILE__,__LINE__,(d),(s),(l)) | | 367 | # define xstrlcpy(d,s,l) _xstrlcpy(__FILE__,__LINE__,(d),(s),(l)) |
364 | #else /* not DEBUG */ | | 368 | #else /* not DEBUG */ |
365 | extern void xstrlcat(char *dst, const char *src, size_t len); | | 369 | extern void xstrlcat(char *dst, const char *src, size_t len); |
366 | extern void xstrlcpy(char *dst, const char *src, size_t len); | | 370 | extern void xstrlcpy(char *dst, const char *src, size_t len); |
367 | #endif /* not DEBUG */ | | 371 | #endif /* not DEBUG */ |
368 | | | 372 | |
369 | #ifdef MOUNT_TABLE_ON_FILE | | 373 | #ifdef MOUNT_TABLE_ON_FILE |
370 | extern void rewrite_mtab(mntlist *, const char *); | | 374 | extern void rewrite_mtab(mntlist *, const char *); |
371 | extern void unlock_mntlist(void); | | 375 | extern void unlock_mntlist(void); |
372 | extern void write_mntent(mntent_t *, const char *); | | 376 | extern void write_mntent(mntent_t *, const char *); |
373 | #endif /* MOUNT_TABLE_ON_FILE */ | | 377 | #endif /* MOUNT_TABLE_ON_FILE */ |
374 | | | 378 | |
375 | #if defined(HAVE_SYSLOG_H) || defined(HAVE_SYS_SYSLOG_H) | | 379 | #if defined(HAVE_SYSLOG_H) || defined(HAVE_SYS_SYSLOG_H) |
376 | extern int syslogging; | | 380 | extern int syslogging; |
377 | #endif /* defined(HAVE_SYSLOG_H) || defined(HAVE_SYS_SYSLOG_H) */ | | 381 | #endif /* defined(HAVE_SYSLOG_H) || defined(HAVE_SYS_SYSLOG_H) */ |
378 | | | 382 | |
379 | extern void compute_nfs_args(void *nap, mntent_t *mntp, int genflags, struct netconfig *nfsncp, struct sockaddr_in *ip_addr, u_long nfs_version, char *nfs_proto, am_nfs_handle_t *fhp, char *host_name, char *fs_name); | | 383 | extern void compute_nfs_args(void *nap, mntent_t *mntp, int genflags, struct netconfig *nfsncp, struct sockaddr_in *ip_addr, u_long nfs_version, char *nfs_proto, am_nfs_handle_t *fhp, char *host_name, char *fs_name); |
380 | extern void destroy_nfs_args(void *nap, u_long nfs_version); | | 384 | extern void destroy_nfs_args(void *nap, u_long nfs_version); |
381 | extern int create_amq_service(int *udp_soAMQp, SVCXPRT **udp_amqpp, struct netconfig **udp_amqncpp, int *tcp_soAMQp, SVCXPRT **tcp_amqpp, struct netconfig **tcp_amqncpp, u_short preferred_amq_port); | | 385 | extern int create_amq_service(int *udp_soAMQp, SVCXPRT **udp_amqpp, struct netconfig **udp_amqncpp, int *tcp_soAMQp, SVCXPRT **tcp_amqpp, struct netconfig **tcp_amqncpp, u_short preferred_amq_port); |
382 | extern int create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp), u_long nfs_version); | | 386 | extern int create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp), u_long nfs_version); |
383 | extern int amu_svc_register(SVCXPRT *, u_long, u_long, void (*)(struct svc_req *, SVCXPRT *), u_long, struct netconfig *); | | 387 | extern int amu_svc_register(SVCXPRT *, u_long, u_long, void (*)(struct svc_req *, SVCXPRT *), u_long, struct netconfig *); |
384 | | | 388 | |
385 | #ifdef HAVE_TRANSPORT_TYPE_TLI | | 389 | #ifdef HAVE_TRANSPORT_TYPE_TLI |
386 | | | 390 | |
387 | extern int get_knetconfig(struct knetconfig **kncpp, struct netconfig *in_ncp, char *nc_protoname); | | 391 | extern int get_knetconfig(struct knetconfig **kncpp, struct netconfig *in_ncp, char *nc_protoname); |
388 | extern struct netconfig *nfsncp; | | 392 | extern struct netconfig *nfsncp; |
389 | extern void free_knetconfig(struct knetconfig *kncp); | | 393 | extern void free_knetconfig(struct knetconfig *kncp); |
390 | | | 394 | |
391 | #endif /* HAVE_TRANSPORT_TYPE_TLI */ | | 395 | #endif /* HAVE_TRANSPORT_TYPE_TLI */ |
392 | | | 396 | |
393 | #ifdef HAVE_FS_AUTOFS | | 397 | #ifdef HAVE_FS_AUTOFS |
394 | extern int register_autofs_service(char *autofs_conftype, void (*autofs_dispatch)(struct svc_req *rqstp, SVCXPRT *xprt)); | | 398 | extern int register_autofs_service(char *autofs_conftype, void (*autofs_dispatch)(struct svc_req *rqstp, SVCXPRT *xprt)); |
395 | extern int unregister_autofs_service(char *autofs_conftype); | | 399 | extern int unregister_autofs_service(char *autofs_conftype); |
396 | #endif /* HAVE_FS_AUTOFS */ | | 400 | #endif /* HAVE_FS_AUTOFS */ |
397 | | | 401 | |
398 | | | 402 | |
399 | #ifndef HAVE_STRUCT_FHSTATUS_FHS_FH | | 403 | #ifndef HAVE_STRUCT_FHSTATUS_FHS_FH |
400 | # define fhs_fh fhstatus_u.fhs_fhandle | | 404 | # define fhs_fh fhstatus_u.fhs_fhandle |
401 | #endif /* not HAVE_STRUCT_FHSTATUS_FHS_FH */ | | 405 | #endif /* not HAVE_STRUCT_FHSTATUS_FHS_FH */ |
402 | | | 406 | |
403 | | | 407 | |
404 | /* | | 408 | /* |
405 | * Network File System: the old faithful generation NFS V.2 | | 409 | * Network File System: the old faithful generation NFS V.2 |
406 | */ | | 410 | */ |
407 | #ifndef NFS_VERSION2 | | 411 | #ifndef NFS_VERSION2 |
408 | # define NFS_VERSION2 ((u_int) 2) | | 412 | # define NFS_VERSION2 ((u_int) 2) |
409 | #endif /* not NFS_VERSION2 */ | | 413 | #endif /* not NFS_VERSION2 */ |
410 | | | 414 | |
411 | /* | | 415 | /* |
412 | * Network File System: the not so new anymore generation NFS V.3 | | 416 | * Network File System: the not so new anymore generation NFS V.3 |
413 | */ | | 417 | */ |
414 | #ifdef HAVE_FS_NFS3 | | 418 | #ifdef HAVE_FS_NFS3 |
415 | # ifndef NFS_VERSION3 | | 419 | # ifndef NFS_VERSION3 |
416 | # define NFS_VERSION3 ((u_int) 3) | | 420 | # define NFS_VERSION3 ((u_int) 3) |
417 | # endif /* not NFS_VERSION3 */ | | 421 | # endif /* not NFS_VERSION3 */ |
418 | #endif /* HAVE_FS_NFS3 */ | | 422 | #endif /* HAVE_FS_NFS3 */ |
419 | | | 423 | |
420 | /* | | 424 | /* |
421 | * Network File System: the new generation NFS V.4 | | 425 | * Network File System: the new generation NFS V.4 |
422 | */ | | 426 | */ |
423 | #ifdef HAVE_FS_NFS4 | | 427 | #ifdef HAVE_FS_NFS4 |
424 | # ifndef NFS_VERSION4 | | 428 | # ifndef NFS_VERSION4 |
425 | # define NFS_VERSION4 ((u_int) 4) | | 429 | # define NFS_VERSION4 ((u_int) 4) |
426 | # endif /* not NFS_VERSION4 */ | | 430 | # endif /* not NFS_VERSION4 */ |
427 | #endif /* HAVE_FS_NFS4 */ | | 431 | #endif /* HAVE_FS_NFS4 */ |
428 | | | 432 | |
429 | /**************************************************************************/ | | 433 | /**************************************************************************/ |
430 | /*** DEBUGGING ***/ | | 434 | /*** DEBUGGING ***/ |
431 | /**************************************************************************/ | | 435 | /**************************************************************************/ |
432 | | | 436 | |
433 | /* | | 437 | /* |
434 | * DEBUGGING: | | 438 | * DEBUGGING: |
435 | */ | | 439 | */ |
436 | | | 440 | |
437 | #ifdef DEBUG | | 441 | #ifdef DEBUG |
438 | | | 442 | |
439 | # define D_DAEMON 0x0001 /* Enter daemon mode */ | | 443 | # define D_DAEMON 0x0001 /* Enter daemon mode */ |
440 | # define D_TRACE 0x0002 /* Do protocol trace */ | | 444 | # define D_TRACE 0x0002 /* Do protocol trace */ |
441 | # define D_FULL 0x0004 /* Do full trace */ | | 445 | # define D_FULL 0x0004 /* Do full trace */ |
442 | # define D_MTAB 0x0008 /* Use local mtab */ | | 446 | # define D_MTAB 0x0008 /* Use local mtab */ |
443 | # define D_AMQ 0x0010 /* Register amq program */ | | 447 | # define D_AMQ 0x0010 /* Register amq program */ |
444 | # define D_STR 0x0020 /* Debug string munging */ | | 448 | # define D_STR 0x0020 /* Debug string munging */ |
445 | # ifdef DEBUG_MEM | | 449 | # ifdef DEBUG_MEM |
446 | # define D_MEM 0x0040 /* Trace memory allocations */ | | 450 | # define D_MEM 0x0040 /* Trace memory allocations */ |
447 | # else /* not DEBUG_MEM */ | | 451 | # else /* not DEBUG_MEM */ |
448 | # define D_MEM 0x0000 /* Dummy */ | | 452 | # define D_MEM 0x0000 /* Dummy */ |
449 | # endif /* not DEBUG_MEM */ | | 453 | # endif /* not DEBUG_MEM */ |
450 | # define D_FORK 0x0080 /* Fork server (hlfsd only) */ | | 454 | # define D_FORK 0x0080 /* Fork server (hlfsd only) */ |
451 | # define D_INFO 0x0100 /* info service specific debugging (hesiod, nis, etc) */ | | 455 | # define D_INFO 0x0100 /* info service specific debugging (hesiod, nis, etc) */ |
452 | # define D_HRTIME 0x0200 /* Print high resolution time stamps */ | | 456 | # define D_HRTIME 0x0200 /* Print high resolution time stamps */ |
453 | # define D_XDRTRACE 0x0400 /* Trace xdr routines */ | | 457 | # define D_XDRTRACE 0x0400 /* Trace xdr routines */ |
454 | # define D_READDIR 0x0800 /* Show browsable_dir progress */ | | 458 | # define D_READDIR 0x0800 /* Show browsable_dir progress */ |
455 | /* debug option compositions */ | | 459 | /* debug option compositions */ |
456 | # define D_MASK 0x0fff /* mask of known flags */ | | 460 | # define D_MASK 0x0fff /* mask of known flags */ |
457 | # define D_BASIC (D_TRACE|D_FULL|D_STR|D_MEM|D_INFO|D_XDRTRACE|D_READDIR) | | 461 | # define D_BASIC (D_TRACE|D_FULL|D_STR|D_MEM|D_INFO|D_XDRTRACE|D_READDIR) |
458 | # define D_CONTROL (D_DAEMON|D_AMQ|D_FORK) | | 462 | # define D_CONTROL (D_DAEMON|D_AMQ|D_FORK) |
459 | /* immutable flags: cannot be changed via "amq -D" */ | | 463 | /* immutable flags: cannot be changed via "amq -D" */ |
460 | # define D_IMMUTABLE (D_MTAB | D_CONTROL) | | 464 | # define D_IMMUTABLE (D_MTAB | D_CONTROL) |
461 | # define D_ALL (D_BASIC | D_CONTROL) | | 465 | # define D_ALL (D_BASIC | D_CONTROL) |
462 | # define D_DEFAULT (D_MASK & D_ALL & ~D_XDRTRACE) | | 466 | # define D_DEFAULT (D_MASK & D_ALL & ~D_XDRTRACE) |
463 | /* test mode: nodaemon, noamq, nofork, (local) mtab */ | | 467 | /* test mode: nodaemon, noamq, nofork, (local) mtab */ |
464 | # define D_TEST (D_BASIC | D_MTAB) | | 468 | # define D_TEST (D_BASIC | D_MTAB) |
465 | | | 469 | |
466 | # define amuDebug(x) (debug_flags & (x)) | | 470 | # define amuDebug(x) (debug_flags & (x)) |
467 | # define dlog if (amuDebug(D_FULL)) dplog | | 471 | # define dlog if (amuDebug(D_FULL)) dplog |
468 | | | 472 | |
469 | /* my favorite debugging tool -Erez */ | | 473 | /* my favorite debugging tool -Erez */ |
470 | #define EZKDBG plog(XLOG_INFO,"EZK:%s:%s:%d\n",__FILE__,__FUNCTION__,__LINE__) | | 474 | #define EZKDBG plog(XLOG_INFO,"EZK:%s:%s:%d\n",__FILE__,__FUNCTION__,__LINE__) |
471 | | | 475 | |
472 | # ifdef DEBUG_MEM | | 476 | # ifdef DEBUG_MEM |
473 | /* | | 477 | /* |
474 | * If debugging memory, then call a special freeing function that logs | | 478 | * If debugging memory, then call a special freeing function that logs |
475 | * more info, and resets the pointer to NULL so it cannot be used again. | | 479 | * more info, and resets the pointer to NULL so it cannot be used again. |
476 | */ | | 480 | */ |
477 | # define XFREE(x) dxfree(__FILE__,__LINE__,x) | | 481 | # define XFREE(x) dxfree(__FILE__,__LINE__,x) |
478 | extern void dxfree(char *file, int line, voidp ptr); | | 482 | extern void dxfree(char *file, int line, voidp ptr); |
479 | extern void malloc_verify(void); | | 483 | extern void malloc_verify(void); |
480 | # else /* not DEBUG_MEM */ | | 484 | # else /* not DEBUG_MEM */ |
481 | /* | | 485 | /* |
482 | * If regular debugging, then free the pointer and reset to NULL. | | 486 | * If regular debugging, then free the pointer and reset to NULL. |
483 | * This should remain so for as long as am-utils is in alpha/beta testing. | | 487 | * This should remain so for as long as am-utils is in alpha/beta testing. |
484 | */ | | 488 | */ |
485 | # define XFREE(x) do { free((voidp)x); x = NULL;} while (0) | | 489 | # define XFREE(x) do { free((voidp)x); x = NULL;} while (0) |
486 | # endif /* not DEBUG_MEM */ | | 490 | # endif /* not DEBUG_MEM */ |
487 | | | 491 | |
488 | /* functions that depend solely on debugging */ | | 492 | /* functions that depend solely on debugging */ |
489 | extern void print_nfs_args(const void *, u_long nfs_version); | | 493 | extern void print_nfs_args(const void *, u_long nfs_version); |
490 | extern int debug_option (char *opt); | | 494 | extern int debug_option (char *opt); |
491 | extern void dplog(const char *fmt, ...) | | 495 | extern void dplog(const char *fmt, ...) |
492 | __attribute__ ((__format__ (__printf__, 1, 2))); | | 496 | __attribute__ ((__format__ (__syslog__, 1, 2))); |
493 | | | 497 | |
494 | #else /* not DEBUG */ | | 498 | #else /* not DEBUG */ |
495 | | | 499 | |
496 | /* set dummy flags to zero */ | | 500 | /* set dummy flags to zero */ |
497 | # define D_DAEMON 0x0001 /* Enter daemon mode */ | | 501 | # define D_DAEMON 0x0001 /* Enter daemon mode */ |
498 | # define D_TRACE 0x0000 /* dummy: Do protocol trace */ | | 502 | # define D_TRACE 0x0000 /* dummy: Do protocol trace */ |
499 | # define D_FULL 0x0000 /* dummy: Do full trace */ | | 503 | # define D_FULL 0x0000 /* dummy: Do full trace */ |
500 | # define D_MTAB 0x0000 /* dummy: Use local mtab */ | | 504 | # define D_MTAB 0x0000 /* dummy: Use local mtab */ |
501 | # define D_AMQ 0x0010 /* Register amq program */ | | 505 | # define D_AMQ 0x0010 /* Register amq program */ |
502 | # define D_STR 0x0000 /* dummy: Debug string munging */ | | 506 | # define D_STR 0x0000 /* dummy: Debug string munging */ |
503 | # define D_MEM 0x0000 /* dummy: Trace memory allocations */ | | 507 | # define D_MEM 0x0000 /* dummy: Trace memory allocations */ |
504 | # define D_FORK 0x0080 /* Fork server (hlfsd only) */ | | 508 | # define D_FORK 0x0080 /* Fork server (hlfsd only) */ |
505 | # define D_INFO 0x0000 /* dummy: info service debugging */ | | 509 | # define D_INFO 0x0000 /* dummy: info service debugging */ |
506 | # define D_HRTIME 0x0000 /* dummy: hi-res time stamps */ | | 510 | # define D_HRTIME 0x0000 /* dummy: hi-res time stamps */ |
507 | # define D_XDRTRACE 0x0000 /* dummy: Trace xdr routines */ | | 511 | # define D_XDRTRACE 0x0000 /* dummy: Trace xdr routines */ |
508 | # define D_READDIR 0x0000 /* dummy: browsable_dir progress */ | | 512 | # define D_READDIR 0x0000 /* dummy: browsable_dir progress */ |
509 | # define D_CONTROL (D_DAEMON|D_AMQ|D_FORK) | | 513 | # define D_CONTROL (D_DAEMON|D_AMQ|D_FORK) |
510 | # define amuDebug(x) (debug_flags & (x)) | | 514 | # define amuDebug(x) (debug_flags & (x)) |
511 | /* | | 515 | /* |
512 | * If not debugging, then also reset the pointer. | | 516 | * If not debugging, then also reset the pointer. |
513 | * It's safer -- and besides, free() should do that anyway. | | 517 | * It's safer -- and besides, free() should do that anyway. |
514 | */ | | 518 | */ |
515 | # define XFREE(x) do { free((voidp)x); x = NULL;} while (0) | | 519 | # define XFREE(x) do { free((voidp)x); x = NULL;} while (0) |
516 | | | 520 | |
517 | # if defined(HAVE_GCC_VARARGS_MACROS) | | 521 | # if defined(HAVE_GCC_VARARGS_MACROS) |
518 | # define dlog(fmt...) | | 522 | # define dlog(fmt...) |
519 | # elif defined(HAVE_C99_VARARGS_MACROS) | | 523 | # elif defined(HAVE_C99_VARARGS_MACROS) |
520 | # define dlog(...) | | 524 | # define dlog(...) |
521 | # else /* no c99 varargs */ | | 525 | # else /* no c99 varargs */ |
522 | /* this define means that we CCP leaves code behind the (list,of,args) */ | | 526 | /* this define means that we CCP leaves code behind the (list,of,args) */ |
523 | # define dlog | | 527 | # define dlog |
524 | # endif /* no c99 varargs */ | | 528 | # endif /* no c99 varargs */ |
525 | | | 529 | |
526 | # define print_nfs_args(nap, nfs_version) | | 530 | # define print_nfs_args(nap, nfs_version) |
527 | # define debug_option(x) (1) | | 531 | # define debug_option(x) (1) |
528 | | | 532 | |
529 | #endif /* not DEBUG */ | | 533 | #endif /* not DEBUG */ |
530 | | | 534 | |
531 | extern u_int debug_flags; /* Debug options */ | | 535 | extern u_int debug_flags; /* Debug options */ |
532 | extern struct opt_tab dbg_opt[]; | | 536 | extern struct opt_tab dbg_opt[]; |
533 | | | 537 | |
534 | /**************************************************************************/ | | 538 | /**************************************************************************/ |
535 | /*** MISC (stuff left to autoconfiscate) ***/ | | 539 | /*** MISC (stuff left to autoconfiscate) ***/ |
536 | /**************************************************************************/ | | 540 | /**************************************************************************/ |
537 | | | 541 | |
538 | #endif /* not _AM_UTILS_H */ | | 542 | #endif /* not _AM_UTILS_H */ |