Thu Apr 18 16:02:26 2024 UTC (34d)
Pull up following revision(s) (requested by riastradh in ticket #1956):

	external/bsd/am-utils/dist/include/amq_defs.h: revision 1.2
	external/bsd/am-utils/dist/amq/amq_xdr.c: revision 1.2
	external/bsd/am-utils/dist/amq/amq.c: revision 1.4
	external/bsd/am-utils/dist/amd/amq_subr.c: revision 1.4
	external/bsd/am-utils/dist/amd/amq_subr.c: revision 1.5

fix pointer bug (thanks RVP) and change to use 64 bit times. Don't bother
with backwards compatibility; too much work for little benefit.

remove long cast (thanks RVP)


(martin)
diff -r1.3 -r1.3.8.1 src/external/bsd/am-utils/dist/amd/amq_subr.c
diff -r1.3 -r1.3.8.1 src/external/bsd/am-utils/dist/amq/amq.c
diff -r1.1.1.3 -r1.1.1.3.8.1 src/external/bsd/am-utils/dist/amq/amq_xdr.c
diff -r1.1.1.3 -r1.1.1.3.8.1 src/external/bsd/am-utils/dist/include/amq_defs.h

cvs diff -r1.3 -r1.3.8.1 src/external/bsd/am-utils/dist/amd/amq_subr.c (switch to unified diff)

--- src/external/bsd/am-utils/dist/amd/amq_subr.c 2015/01/18 16:27:36 1.3
+++ src/external/bsd/am-utils/dist/amd/amq_subr.c 2024/04/18 16:02:26 1.3.8.1
@@ -1,600 +1,600 @@ @@ -1,600 +1,600 @@
1/* $NetBSD: amq_subr.c,v 1.3 2015/01/18 16:27:36 christos Exp $ */ 1/* $NetBSD: amq_subr.c,v 1.3.8.1 2024/04/18 16:02:26 martin 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/amd/amq_subr.c 38 * File: am-utils/amd/amq_subr.c
39 * 39 *
40 */ 40 */
41/* 41/*
42 * Auxiliary routines for amq tool 42 * Auxiliary routines for amq tool
43 */ 43 */
44 44
45#ifdef HAVE_CONFIG_H 45#ifdef HAVE_CONFIG_H
46# include <config.h> 46# include <config.h>
47#endif /* HAVE_CONFIG_H */ 47#endif /* HAVE_CONFIG_H */
48#include <am_defs.h> 48#include <am_defs.h>
49#include <amd.h> 49#include <amd.h>
50 50
51/* forward definitions */ 51/* forward definitions */
52bool_t xdr_amq_mount_tree_node(XDR *xdrs, amq_mount_tree *objp); 52bool_t xdr_amq_mount_tree_node(XDR *xdrs, amq_mount_tree *objp);
53bool_t xdr_amq_mount_subtree(XDR *xdrs, amq_mount_tree *objp); 53bool_t xdr_amq_mount_subtree(XDR *xdrs, amq_mount_tree *objp);
54 54
55 55
56voidp 56voidp
57amqproc_null_1_svc(voidp argp, struct svc_req *rqstp) 57amqproc_null_1_svc(voidp argp, struct svc_req *rqstp)
58{ 58{
59 static char res; 59 static char res;
60 60
61 return (voidp) &res; 61 return (voidp) &res;
62} 62}
63 63
64 64
65/* 65/*
66 * Return a sub-tree of mounts 66 * Return a sub-tree of mounts
67 */ 67 */
68amq_mount_tree_p * 68amq_mount_tree_p *
69amqproc_mnttree_1_svc(voidp argp, struct svc_req *rqstp) 69amqproc_mnttree_1_svc(voidp argp, struct svc_req *rqstp)
70{ 70{
71 static am_node *mp; 71 static am_node *mp;
72 72
73 mp = find_ap(*(char **) argp); 73 mp = find_ap(*(char **) argp);
74 return (amq_mount_tree_p *) ((void *)&mp); 74 return (amq_mount_tree_p *) ((void *)&mp);
75} 75}
76 76
77 77
78/* 78/*
79 * Unmount a single node 79 * Unmount a single node
80 */ 80 */
81int * 81int *
82amqproc_umnt_1_svc(voidp argp, struct svc_req *rqstp) 82amqproc_umnt_1_svc(voidp argp, struct svc_req *rqstp)
83{ 83{
84 static int res = AMQ_UMNT_OK; 84 static int res = AMQ_UMNT_OK;
85 am_node *mp = find_ap(*(char **) argp); 85 am_node *mp = find_ap(*(char **) argp);
86 86
87 if (mp) 87 if (mp)
88 forcibly_timeout_mp(mp); 88 forcibly_timeout_mp(mp);
89 89
90 return &res; 90 return &res;
91} 91}
92 92
93 93
94/* 94/*
95 * Synchronously unmount a single node - parent side. 95 * Synchronously unmount a single node - parent side.
96 */ 96 */
97int * 97int *
98amqproc_sync_umnt_1_svc_parent(voidp argp, struct svc_req *rqstp) 98amqproc_sync_umnt_1_svc_parent(voidp argp, struct svc_req *rqstp)
99{ 99{
100 amqproc_umnt_1_svc(argp, rqstp); 100 amqproc_umnt_1_svc(argp, rqstp);
101 return NULL; 101 return NULL;
102} 102}
103 103
104 104
105/* 105/*
106 * Synchronously unmount a single node - child side. 106 * Synchronously unmount a single node - child side.
107 */ 107 */
108amq_sync_umnt * 108amq_sync_umnt *
109amqproc_sync_umnt_1_svc_child(voidp argp, struct svc_req *rqstp) 109amqproc_sync_umnt_1_svc_child(voidp argp, struct svc_req *rqstp)
110{ 110{
111 static amq_sync_umnt rv; 111 static amq_sync_umnt rv;
112 amq_sync_umnt buf; 112 amq_sync_umnt buf;
113 ssize_t n; 113 ssize_t n;
114 114
115 am_node *mp = find_ap(*(char **) argp); 115 am_node *mp = find_ap(*(char **) argp);
116 116
117 memset(&rv, 0, sizeof(rv)); 117 memset(&rv, 0, sizeof(rv));
118 rv.au_etype = AMQ_UMNT_READ; 118 rv.au_etype = AMQ_UMNT_READ;
119 if (mp && mp->am_fd[0] >= 0) { 119 if (mp && mp->am_fd[0] >= 0) {
120 n = read(mp->am_fd[0], &buf, sizeof(buf)); 120 n = read(mp->am_fd[0], &buf, sizeof(buf));
121 if (n == sizeof(buf)) 121 if (n == sizeof(buf))
122 rv = buf; 122 rv = buf;
123 } 123 }
124 return &rv; 124 return &rv;
125} 125}
126 126
127 127
128/* 128/*
129 * Synchronously unmount a single node - use if we can't fork (asynchronous). 129 * Synchronously unmount a single node - use if we can't fork (asynchronous).
130 */ 130 */
131amq_sync_umnt * 131amq_sync_umnt *
132amqproc_sync_umnt_1_svc_async(voidp argp, struct svc_req *rqstp) 132amqproc_sync_umnt_1_svc_async(voidp argp, struct svc_req *rqstp)
133{ 133{
134 static amq_sync_umnt rv; 134 static amq_sync_umnt rv;
135 135
136 memset(&rv, 0, sizeof(rv)); 136 memset(&rv, 0, sizeof(rv));
137 rv.au_etype = AMQ_UMNT_FORK; 137 rv.au_etype = AMQ_UMNT_FORK;
138 rv.au_errno = errno; 138 rv.au_errno = errno;
139 139
140 amqproc_umnt_1_svc(argp, rqstp); 140 amqproc_umnt_1_svc(argp, rqstp);
141 141
142 return &rv; 142 return &rv;
143} 143}
144 144
145 145
146/* 146/*
147 * Return global statistics 147 * Return global statistics
148 */ 148 */
149amq_mount_stats * 149amq_mount_stats *
150amqproc_stats_1_svc(voidp argp, struct svc_req *rqstp) 150amqproc_stats_1_svc(voidp argp, struct svc_req *rqstp)
151{ 151{
152 return (amq_mount_stats *) ((void *)&amd_stats); 152 return (amq_mount_stats *) ((void *)&amd_stats);
153} 153}
154 154
155 155
156/* 156/*
157 * Return the entire tree of mount nodes 157 * Return the entire tree of mount nodes
158 */ 158 */
159amq_mount_tree_list * 159amq_mount_tree_list *
160amqproc_export_1_svc(voidp argp, struct svc_req *rqstp) 160amqproc_export_1_svc(voidp argp, struct svc_req *rqstp)
161{ 161{
162 static amq_mount_tree_list aml; 162 static amq_mount_tree_list aml;
163 static am_node *mp; 163 static am_node *mp;
164 164
165 mp = get_exported_ap(0); 165 mp = get_exported_ap(0);
166 aml.amq_mount_tree_list_val = (amq_mount_tree_p *) ((void *) &mp); 166 aml.amq_mount_tree_list_val = (amq_mount_tree_p *) ((void *) &mp);
167 aml.amq_mount_tree_list_len = 1; /* XXX */ 167 aml.amq_mount_tree_list_len = 1; /* XXX */
168 168
169 return &aml; 169 return &aml;
170} 170}
171 171
172 172
173int * 173int *
174amqproc_setopt_1_svc(voidp argp, struct svc_req *rqstp) 174amqproc_setopt_1_svc(voidp argp, struct svc_req *rqstp)
175{ 175{
176 static int rc; 176 static int rc;
177 amq_setopt *opt = (amq_setopt *) argp; 177 amq_setopt *opt = (amq_setopt *) argp;
178 178
179 rc = 0; 179 rc = 0;
180 180
181 switch (opt->as_opt) { 181 switch (opt->as_opt) {
182 182
183 case AMOPT_DEBUG: 183 case AMOPT_DEBUG:
184 if (debug_option(opt->as_str)) 184 if (debug_option(opt->as_str))
185 rc = EINVAL; 185 rc = EINVAL;
186 break; 186 break;
187 187
188 case AMOPT_LOGFILE: 188 case AMOPT_LOGFILE:
189 if (gopt.logfile && opt->as_str 189 if (gopt.logfile && opt->as_str
190 && STREQ(gopt.logfile, opt->as_str)) { 190 && STREQ(gopt.logfile, opt->as_str)) {
191 if (switch_to_logfile(opt->as_str, orig_umask, 0)) 191 if (switch_to_logfile(opt->as_str, orig_umask, 0))
192 rc = EINVAL; 192 rc = EINVAL;
193 } else { 193 } else {
194 rc = EACCES; 194 rc = EACCES;
195 } 195 }
196 break; 196 break;
197 197
198 case AMOPT_XLOG: 198 case AMOPT_XLOG:
199 if (switch_option(opt->as_str)) 199 if (switch_option(opt->as_str))
200 rc = EINVAL; 200 rc = EINVAL;
201 break; 201 break;
202 202
203 case AMOPT_FLUSHMAPC: 203 case AMOPT_FLUSHMAPC:
204 if (amd_state == Run) { 204 if (amd_state == Run) {
205 plog(XLOG_INFO, "amq says flush cache"); 205 plog(XLOG_INFO, "amq says flush cache");
206 do_mapc_reload = 0; 206 do_mapc_reload = 0;
207 flush_nfs_fhandle_cache((fserver *) NULL); 207 flush_nfs_fhandle_cache((fserver *) NULL);
208 flush_srvr_nfs_cache((fserver *) NULL); 208 flush_srvr_nfs_cache((fserver *) NULL);
209 } 209 }
210 break; 210 break;
211 } 211 }
212 212
213 return &rc; 213 return &rc;
214} 214}
215 215
216 216
217amq_mount_info_list * 217amq_mount_info_list *
218amqproc_getmntfs_1_svc(voidp argp, struct svc_req *rqstp) 218amqproc_getmntfs_1_svc(voidp argp, struct svc_req *rqstp)
219{ 219{
220 return (amq_mount_info_list *) ((void *)&mfhead); /* XXX */ 220 return (amq_mount_info_list *) ((void *)&mfhead); /* XXX */
221} 221}
222 222
223extern qelem map_list_head; 223extern qelem map_list_head;
224amq_map_info_list * 224amq_map_info_list *
225amqproc_getmapinfo_1_svc(voidp argp, struct svc_req *rqstp) 225amqproc_getmapinfo_1_svc(voidp argp, struct svc_req *rqstp)
226{ 226{
227 return (amq_map_info_list *) ((void *)&map_list_head); /* XXX */ 227 return (amq_map_info_list *) ((void *)&map_list_head); /* XXX */
228} 228}
229 229
230amq_string * 230amq_string *
231amqproc_getvers_1_svc(voidp argp, struct svc_req *rqstp) 231amqproc_getvers_1_svc(voidp argp, struct svc_req *rqstp)
232{ 232{
233 static amq_string res; 233 static amq_string res;
234 234
235 res = get_version_string(); 235 res = get_version_string();
236 return &res; 236 return &res;
237} 237}
238 238
239 239
240/* get PID of remote amd */ 240/* get PID of remote amd */
241int * 241int *
242amqproc_getpid_1_svc(voidp argp, struct svc_req *rqstp) 242amqproc_getpid_1_svc(voidp argp, struct svc_req *rqstp)
243{ 243{
244 static int res; 244 static int res;
245 245
246 res = getpid(); 246 res = getpid();
247 return &res; 247 return &res;
248} 248}
249 249
250 250
251/* 251/*
252 * Process PAWD string of remote pawd tool. 252 * Process PAWD string of remote pawd tool.
253 * 253 *
254 * We repeat the resolution of the string until the resolved string resolves 254 * We repeat the resolution of the string until the resolved string resolves
255 * to itself. This ensures that we follow path resolutions through all 255 * to itself. This ensures that we follow path resolutions through all
256 * possible Amd mount points until we reach some sort of convergence. To 256 * possible Amd mount points until we reach some sort of convergence. To
257 * prevent possible infinite loops, we break out of this loop if the strings 257 * prevent possible infinite loops, we break out of this loop if the strings
258 * do not converge after MAX_PAWD_TRIES times. 258 * do not converge after MAX_PAWD_TRIES times.
259 */ 259 */
260amq_string * 260amq_string *
261amqproc_pawd_1_svc(voidp argp, struct svc_req *rqstp) 261amqproc_pawd_1_svc(voidp argp, struct svc_req *rqstp)
262{ 262{
263 static amq_string res; 263 static amq_string res;
264#define MAX_PAWD_TRIES 10 264#define MAX_PAWD_TRIES 10
265 int index, len, maxagain = MAX_PAWD_TRIES; 265 int index, len, maxagain = MAX_PAWD_TRIES;
266 am_node *mp; 266 am_node *mp;
267 char *mountpoint; 267 char *mountpoint;
268 char *dir = *(char **) argp; 268 char *dir = *(char **) argp;
269 static char tmp_buf[MAXPATHLEN]; 269 static char tmp_buf[MAXPATHLEN];
270 char prev_buf[MAXPATHLEN]; 270 char prev_buf[MAXPATHLEN];
271 271
272 tmp_buf[0] = prev_buf[0] = '\0'; /* default is empty string: no match */ 272 tmp_buf[0] = prev_buf[0] = '\0'; /* default is empty string: no match */
273 do { 273 do {
274 for (mp = get_first_exported_ap(&index); 274 for (mp = get_first_exported_ap(&index);
275 mp; 275 mp;
276 mp = get_next_exported_ap(&index)) { 276 mp = get_next_exported_ap(&index)) {
277 if (STREQ(mp->am_al->al_mnt->mf_ops->fs_type, "toplvl")) 277 if (STREQ(mp->am_al->al_mnt->mf_ops->fs_type, "toplvl"))
278 continue; 278 continue;
279 if (STREQ(mp->am_al->al_mnt->mf_ops->fs_type, "auto")) 279 if (STREQ(mp->am_al->al_mnt->mf_ops->fs_type, "auto"))
280 continue; 280 continue;
281 mountpoint = (mp->am_link ? mp->am_link : mp->am_al->al_mnt->mf_mount); 281 mountpoint = (mp->am_link ? mp->am_link : mp->am_al->al_mnt->mf_mount);
282 len = strlen(mountpoint); 282 len = strlen(mountpoint);
283 if (len == 0) 283 if (len == 0)
284 continue; 284 continue;
285 if (!NSTREQ(mountpoint, dir, len)) 285 if (!NSTREQ(mountpoint, dir, len))
286 continue; 286 continue;
287 if (dir[len] != '\0' && dir[len] != '/') 287 if (dir[len] != '\0' && dir[len] != '/')
288 continue; 288 continue;
289 xstrlcpy(tmp_buf, mp->am_path, sizeof(tmp_buf)); 289 xstrlcpy(tmp_buf, mp->am_path, sizeof(tmp_buf));
290 xstrlcat(tmp_buf, &dir[len], sizeof(tmp_buf)); 290 xstrlcat(tmp_buf, &dir[len], sizeof(tmp_buf));
291 break; 291 break;
292 } /* end of "for" loop */ 292 } /* end of "for" loop */
293 /* once tmp_buf and prev_buf are equal, break out of "do" loop */ 293 /* once tmp_buf and prev_buf are equal, break out of "do" loop */
294 if (STREQ(tmp_buf, prev_buf)) 294 if (STREQ(tmp_buf, prev_buf))
295 break; 295 break;
296 else 296 else
297 xstrlcpy(prev_buf, tmp_buf, sizeof(prev_buf)); 297 xstrlcpy(prev_buf, tmp_buf, sizeof(prev_buf));
298 } while (--maxagain); 298 } while (--maxagain);
299 /* check if we couldn't resolve the string after MAX_PAWD_TRIES times */ 299 /* check if we couldn't resolve the string after MAX_PAWD_TRIES times */
300 if (maxagain <= 0) 300 if (maxagain <= 0)
301 plog(XLOG_WARNING, "path \"%s\" did not resolve after %d tries", 301 plog(XLOG_WARNING, "path \"%s\" did not resolve after %d tries",
302 tmp_buf, MAX_PAWD_TRIES); 302 tmp_buf, MAX_PAWD_TRIES);
303 303
304 res = tmp_buf; 304 res = tmp_buf;
305 return &res; 305 return &res;
306} 306}
307 307
308 308
309/* 309/*
310 * XDR routines. 310 * XDR routines.
311 */ 311 */
312 312
313 313
314bool_t 314bool_t
315xdr_amq_setopt(XDR *xdrs, amq_setopt *objp) 315xdr_amq_setopt(XDR *xdrs, amq_setopt *objp)
316{ 316{
317 if (!xdr_enum(xdrs, (enum_t *) ((voidp) &objp->as_opt))) { 317 if (!xdr_enum(xdrs, (enum_t *) ((voidp) &objp->as_opt))) {
318 return (FALSE); 318 return (FALSE);
319 } 319 }
320 if (!xdr_string(xdrs, &objp->as_str, AMQ_STRLEN)) { 320 if (!xdr_string(xdrs, &objp->as_str, AMQ_STRLEN)) {
321 return (FALSE); 321 return (FALSE);
322 } 322 }
323 return (TRUE); 323 return (TRUE);
324} 324}
325 325
326 326
327/* 327/*
328 * More XDR routines - Should be used for OUTPUT ONLY. 328 * More XDR routines - Should be used for OUTPUT ONLY.
329 */ 329 */
330bool_t 330bool_t
331xdr_amq_mount_tree_node(XDR *xdrs, amq_mount_tree *objp) 331xdr_amq_mount_tree_node(XDR *xdrs, amq_mount_tree *objp)
332{ 332{
333 am_node *mp = (am_node *) objp; 333 am_node *mp = (am_node *) objp;
334 long mtime; 334 longlong_t mtime;
335 335
336 if (!xdr_amq_string(xdrs, &mp->am_al->al_mnt->mf_info)) { 336 if (!xdr_amq_string(xdrs, &mp->am_al->al_mnt->mf_info)) {
337 return (FALSE); 337 return (FALSE);
338 } 338 }
339 if (!xdr_amq_string(xdrs, &mp->am_path)) { 339 if (!xdr_amq_string(xdrs, &mp->am_path)) {
340 return (FALSE); 340 return (FALSE);
341 } 341 }
342 if (!xdr_amq_string(xdrs, mp->am_link ? &mp->am_link : &mp->am_al->al_mnt->mf_mount)) { 342 if (!xdr_amq_string(xdrs, mp->am_link ? &mp->am_link : &mp->am_al->al_mnt->mf_mount)) {
343 return (FALSE); 343 return (FALSE);
344 } 344 }
345 if (!xdr_amq_string(xdrs, &mp->am_al->al_mnt->mf_ops->fs_type)) { 345 if (!xdr_amq_string(xdrs, &mp->am_al->al_mnt->mf_ops->fs_type)) {
346 return (FALSE); 346 return (FALSE);
347 } 347 }
348 mtime = mp->am_stats.s_mtime; 348 mtime = mp->am_stats.s_mtime;
349 if (!xdr_long(xdrs, &mtime)) { 349 if (!xdr_longlong_t(xdrs, &mtime)) {
350 return (FALSE); 350 return (FALSE);
351 } 351 }
352 if (!xdr_u_short(xdrs, &mp->am_stats.s_uid)) { 352 if (!xdr_u_short(xdrs, &mp->am_stats.s_uid)) {
353 return (FALSE); 353 return (FALSE);
354 } 354 }
355 if (!xdr_int(xdrs, &mp->am_stats.s_getattr)) { 355 if (!xdr_int(xdrs, &mp->am_stats.s_getattr)) {
356 return (FALSE); 356 return (FALSE);
357 } 357 }
358 if (!xdr_int(xdrs, &mp->am_stats.s_lookup)) { 358 if (!xdr_int(xdrs, &mp->am_stats.s_lookup)) {
359 return (FALSE); 359 return (FALSE);
360 } 360 }
361 if (!xdr_int(xdrs, &mp->am_stats.s_readdir)) { 361 if (!xdr_int(xdrs, &mp->am_stats.s_readdir)) {
362 return (FALSE); 362 return (FALSE);
363 } 363 }
364 if (!xdr_int(xdrs, &mp->am_stats.s_readlink)) { 364 if (!xdr_int(xdrs, &mp->am_stats.s_readlink)) {
365 return (FALSE); 365 return (FALSE);
366 } 366 }
367 if (!xdr_int(xdrs, &mp->am_stats.s_statfs)) { 367 if (!xdr_int(xdrs, &mp->am_stats.s_statfs)) {
368 return (FALSE); 368 return (FALSE);
369 } 369 }
370 return (TRUE); 370 return (TRUE);
371} 371}
372 372
373 373
374bool_t 374bool_t
375xdr_amq_mount_subtree(XDR *xdrs, amq_mount_tree *objp) 375xdr_amq_mount_subtree(XDR *xdrs, amq_mount_tree *objp)
376{ 376{
377 am_node *mp = (am_node *) objp; 377 am_node *mp = (am_node *) objp;
378 378
379 if (!xdr_amq_mount_tree_node(xdrs, objp)) { 379 if (!xdr_amq_mount_tree_node(xdrs, objp)) {
380 return (FALSE); 380 return (FALSE);
381 } 381 }
382 if (!xdr_pointer(xdrs, 382 if (!xdr_pointer(xdrs,
383 (char **) ((voidp) &mp->am_osib), 383 (char **) ((voidp) &mp->am_osib),
384 sizeof(amq_mount_tree), 384 sizeof(amq_mount_tree),
385 (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { 385 (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) {
386 return (FALSE); 386 return (FALSE);
387 } 387 }
388 if (!xdr_pointer(xdrs, 388 if (!xdr_pointer(xdrs,
389 (char **) ((voidp) &mp->am_child), 389 (char **) ((voidp) &mp->am_child),
390 sizeof(amq_mount_tree), 390 sizeof(amq_mount_tree),
391 (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { 391 (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) {
392 return (FALSE); 392 return (FALSE);
393 } 393 }
394 return (TRUE); 394 return (TRUE);
395} 395}
396 396
397 397
398bool_t 398bool_t
399xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp) 399xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp)
400{ 400{
401 am_node *mp = (am_node *) objp; 401 am_node *mp = (am_node *) objp;
402 am_node *mnil = NULL; 402 am_node *mnil = NULL;
403 403
404 if (!xdr_amq_mount_tree_node(xdrs, objp)) { 404 if (!xdr_amq_mount_tree_node(xdrs, objp)) {
405 return (FALSE); 405 return (FALSE);
406 } 406 }
407 if (!xdr_pointer(xdrs, 407 if (!xdr_pointer(xdrs,
408 (char **) ((voidp) &mnil), 408 (char **) ((voidp) &mnil),
409 sizeof(amq_mount_tree), 409 sizeof(amq_mount_tree),
410 (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { 410 (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) {
411 return (FALSE); 411 return (FALSE);
412 } 412 }
413 if (!xdr_pointer(xdrs, 413 if (!xdr_pointer(xdrs,
414 (char **) ((voidp) &mp->am_child), 414 (char **) ((voidp) &mp->am_child),
415 sizeof(amq_mount_tree), 415 sizeof(amq_mount_tree),
416 (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { 416 (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) {
417 return (FALSE); 417 return (FALSE);
418 } 418 }
419 return (TRUE); 419 return (TRUE);
420} 420}
421 421
422 422
423bool_t 423bool_t
424xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp) 424xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp)
425{ 425{
426 if (!xdr_pointer(xdrs, (char **) objp, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { 426 if (!xdr_pointer(xdrs, (char **) objp, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
427 return (FALSE); 427 return (FALSE);
428 } 428 }
429 return (TRUE); 429 return (TRUE);
430} 430}
431 431
432 432
433bool_t 433bool_t
434xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp) 434xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp)
435{ 435{
436 if (!xdr_int(xdrs, &objp->as_drops)) { 436 if (!xdr_int(xdrs, &objp->as_drops)) {
437 return (FALSE); 437 return (FALSE);
438 } 438 }
439 if (!xdr_int(xdrs, &objp->as_stale)) { 439 if (!xdr_int(xdrs, &objp->as_stale)) {
440 return (FALSE); 440 return (FALSE);
441 } 441 }
442 if (!xdr_int(xdrs, &objp->as_mok)) { 442 if (!xdr_int(xdrs, &objp->as_mok)) {
443 return (FALSE); 443 return (FALSE);
444 } 444 }
445 if (!xdr_int(xdrs, &objp->as_merr)) { 445 if (!xdr_int(xdrs, &objp->as_merr)) {
446 return (FALSE); 446 return (FALSE);
447 } 447 }
448 if (!xdr_int(xdrs, &objp->as_uerr)) { 448 if (!xdr_int(xdrs, &objp->as_uerr)) {
449 return (FALSE); 449 return (FALSE);
450 } 450 }
451 return (TRUE); 451 return (TRUE);
452} 452}
453 453
454 454
455 455
456bool_t 456bool_t
457xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp) 457xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp)
458{ 458{
459 if (!xdr_array(xdrs, 459 if (!xdr_array(xdrs,
460 (char **) ((voidp) &objp->amq_mount_tree_list_val), 460 (char **) ((voidp) &objp->amq_mount_tree_list_val),
461 (u_int *) &objp->amq_mount_tree_list_len, 461 (u_int *) &objp->amq_mount_tree_list_len,
462 ~0, 462 ~0,
463 sizeof(amq_mount_tree_p), 463 sizeof(amq_mount_tree_p),
464 (XDRPROC_T_TYPE) xdr_amq_mount_tree_p)) { 464 (XDRPROC_T_TYPE) xdr_amq_mount_tree_p)) {
465 return (FALSE); 465 return (FALSE);
466 } 466 }
467 return (TRUE); 467 return (TRUE);
468} 468}
469 469
470 470
471bool_t 471bool_t
472xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead) 472xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead)
473{ 473{
474 mntfs *mf; 474 mntfs *mf;
475 u_int len = 0; 475 u_int len = 0;
476 476
477 /* 477 /*
478 * Compute length of list 478 * Compute length of list
479 */ 479 */
480 for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) { 480 for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) {
481 if (!(mf->mf_fsflags & FS_AMQINFO)) 481 if (!(mf->mf_fsflags & FS_AMQINFO))
482 continue; 482 continue;
483 len++; 483 len++;
484 } 484 }
485 xdr_u_int(xdrs, &len); 485 xdr_u_int(xdrs, &len);
486 486
487 /* 487 /*
488 * Send individual data items 488 * Send individual data items
489 */ 489 */
490 for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) { 490 for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) {
491 int up; 491 int up;
492 if (!(mf->mf_fsflags & FS_AMQINFO)) 492 if (!(mf->mf_fsflags & FS_AMQINFO))
493 continue; 493 continue;
494 494
495 if (!xdr_amq_string(xdrs, &mf->mf_ops->fs_type)) { 495 if (!xdr_amq_string(xdrs, &mf->mf_ops->fs_type)) {
496 return (FALSE); 496 return (FALSE);
497 } 497 }
498 if (!xdr_amq_string(xdrs, &mf->mf_mount)) { 498 if (!xdr_amq_string(xdrs, &mf->mf_mount)) {
499 return (FALSE); 499 return (FALSE);
500 } 500 }
501 if (!xdr_amq_string(xdrs, &mf->mf_info)) { 501 if (!xdr_amq_string(xdrs, &mf->mf_info)) {
502 return (FALSE); 502 return (FALSE);
503 } 503 }
504 if (!xdr_amq_string(xdrs, &mf->mf_server->fs_host)) { 504 if (!xdr_amq_string(xdrs, &mf->mf_server->fs_host)) {
505 return (FALSE); 505 return (FALSE);
506 } 506 }
507 if (!xdr_int(xdrs, &mf->mf_error)) { 507 if (!xdr_int(xdrs, &mf->mf_error)) {
508 return (FALSE); 508 return (FALSE);
509 } 509 }
510 if (!xdr_int(xdrs, &mf->mf_refc)) { 510 if (!xdr_int(xdrs, &mf->mf_refc)) {
511 return (FALSE); 511 return (FALSE);
512 } 512 }
513 if (FSRV_ERROR(mf->mf_server) || FSRV_ISDOWN(mf->mf_server)) 513 if (FSRV_ERROR(mf->mf_server) || FSRV_ISDOWN(mf->mf_server))
514 up = 0; 514 up = 0;
515 else if (FSRV_ISUP(mf->mf_server)) 515 else if (FSRV_ISUP(mf->mf_server))
516 up = 1; 516 up = 1;
517 else 517 else
518 up = -1; 518 up = -1;
519 if (!xdr_int(xdrs, &up)) { 519 if (!xdr_int(xdrs, &up)) {
520 return (FALSE); 520 return (FALSE);
521 } 521 }
522 } 522 }
523 return (TRUE); 523 return (TRUE);
524} 524}
525 525
526bool_t 526bool_t
527xdr_amq_map_info_qelem(XDR *xdrs, qelem *qhead) 527xdr_amq_map_info_qelem(XDR *xdrs, qelem *qhead)
528{ 528{
529 mnt_map *m; 529 mnt_map *m;
530 u_int len = 0; 530 u_int len = 0;
531 int x; 531 int x;
532 char *n; 532 char *n;
533 long modify; 533 longlong_t modify;
534 534
535 /* 535 /*
536 * Compute length of list 536 * Compute length of list
537 */ 537 */
538 ITER(m, mnt_map, qhead) { 538 ITER(m, mnt_map, qhead) {
539 len++; 539 len++;
540 } 540 }
541 541
542 if (!xdr_u_int(xdrs, &len)) 542 if (!xdr_u_int(xdrs, &len))
543 return (FALSE); 543 return (FALSE);
544 544
545 /* 545 /*
546 * Send individual data items 546 * Send individual data items
547 */ 547 */
548 ITER(m, mnt_map, qhead) { 548 ITER(m, mnt_map, qhead) {
549 if (!xdr_amq_string(xdrs, &m->map_name)) { 549 if (!xdr_amq_string(xdrs, &m->map_name)) {
550 return (FALSE); 550 return (FALSE);
551 } 551 }
552 552
553 n = m->wildcard ? m->wildcard : ""; 553 n = m->wildcard ? m->wildcard : "";
554 if (!xdr_amq_string(xdrs, &n)) { 554 if (!xdr_amq_string(xdrs, &n)) {
555 return (FALSE); 555 return (FALSE);
556 } 556 }
557 557
558 modify = (long)m->modify; 558 modify = m->modify;
559 if (!xdr_long(xdrs, &modify)) { 559 if (!xdr_longlong_t(xdrs, &modify)) {
560 return (FALSE); 560 return (FALSE);
561 } 561 }
562 562
563 x = m->flags; 563 x = m->flags;
564 if (!xdr_int(xdrs, &x)) { 564 if (!xdr_int(xdrs, &x)) {
565 return (FALSE); 565 return (FALSE);
566 } 566 }
567 567
568 x = m->nentries; 568 x = m->nentries;
569 if (!xdr_int(xdrs, &x)) { 569 if (!xdr_int(xdrs, &x)) {
570 return (FALSE); 570 return (FALSE);
571 } 571 }
572 572
573 x = m->reloads; 573 x = m->reloads;
574 if (!xdr_int(xdrs, &x)) { 574 if (!xdr_int(xdrs, &x)) {
575 return (FALSE); 575 return (FALSE);
576 } 576 }
577 577
578 if (!xdr_int(xdrs, &m->refc)) { 578 if (!xdr_int(xdrs, &m->refc)) {
579 return (FALSE); 579 return (FALSE);
580 } 580 }
581 581
582 if (m->isup) 582 if (m->isup)
583 x = (*m->isup)(m, m->map_name); 583 x = (*m->isup)(m, m->map_name);
584 else 584 else
585 x = -1; 585 x = -1;
586 if (!xdr_int(xdrs, &x)) { 586 if (!xdr_int(xdrs, &x)) {
587 return (FALSE); 587 return (FALSE);
588 } 588 }
589 } 589 }
590 return (TRUE); 590 return (TRUE);
591} 591}
592 592
593bool_t 593bool_t
594xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr) 594xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr)
595{ 595{
596 XDR xdr; 596 XDR xdr;
597 597
598 xdr.x_op = XDR_FREE; 598 xdr.x_op = XDR_FREE;
599 return ((*xdr_args) (&xdr, (caddr_t *) args_ptr)); 599 return ((*xdr_args) (&xdr, (caddr_t *) args_ptr));
600} 600}

cvs diff -r1.3 -r1.3.8.1 src/external/bsd/am-utils/dist/amq/amq.c (switch to unified diff)

--- src/external/bsd/am-utils/dist/amq/amq.c 2015/01/18 15:37:57 1.3
+++ src/external/bsd/am-utils/dist/amq/amq.c 2024/04/18 16:02:26 1.3.8.1
@@ -1,848 +1,848 @@ @@ -1,848 +1,848 @@
1/* $NetBSD: amq.c,v 1.3 2015/01/18 15:37:57 christos Exp $ */ 1/* $NetBSD: amq.c,v 1.3.8.1 2024/04/18 16:02:26 martin 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/amq/amq.c 38 * File: am-utils/amq/amq.c
39 * 39 *
40 */ 40 */
41 41
42/* 42/*
43 * Automounter query tool 43 * Automounter query tool
44 */ 44 */
45 45
46#ifdef HAVE_CONFIG_H 46#ifdef HAVE_CONFIG_H
47# include <config.h> 47# include <config.h>
48#endif /* HAVE_CONFIG_H */ 48#endif /* HAVE_CONFIG_H */
49#include <am_defs.h> 49#include <am_defs.h>
50#include <amq.h> 50#include <amq.h>
51 51
52/* locals */ 52/* locals */
53static int flush_flag; 53static int flush_flag;
54static int getpid_flag; 54static int getpid_flag;
55static int getpwd_flag; 55static int getpwd_flag;
56static int getvers_flag; 56static int getvers_flag;
57static int minfo_flag; 57static int minfo_flag;
58static int mapinfo_flag; 58static int mapinfo_flag;
59static int quiet_flag; 59static int quiet_flag;
60static int stats_flag; 60static int stats_flag;
61static int unmount_flag; 61static int unmount_flag;
62static int use_tcp_flag; 62static int use_tcp_flag;
63static int use_udp_flag; 63static int use_udp_flag;
64static u_long amd_program_number = AMQ_PROGRAM; 64static u_long amd_program_number = AMQ_PROGRAM;
65static char *debug_opts; 65static char *debug_opts;
66static char *amq_logfile; 66static char *amq_logfile;
67static char *xlog_optstr; 67static char *xlog_optstr;
68static char localhost[] = "localhost"; 68static char localhost[] = "localhost";
69static char *def_server = localhost; 69static char *def_server = localhost;
70 70
71/* externals */ 71/* externals */
72extern int optind; 72extern int optind;
73extern char *optarg; 73extern char *optarg;
74 74
75/* structures */ 75/* structures */
76enum show_opt { 76enum show_opt {
77 Full, Stats, Calc, Short, ShowDone 77 Full, Stats, Calc, Short, ShowDone
78}; 78};
79 79
80 80
81static void 81static void
82time_print(time_type tt) 82time_print(time_type tt)
83{ 83{
84 time_t t = (time_t)*tt; 84 time_t t = (time_t)tt;
85 struct tm *tp = localtime(&t); 85 struct tm *tp = localtime(&t);
86 printf("%02d/%02d/%04d %02d:%02d:%02d", 86 printf("%02d/%02d/%04d %02d:%02d:%02d",
87 tp->tm_mon + 1, tp->tm_mday, 87 tp->tm_mon + 1, tp->tm_mday,
88 tp->tm_year < 1900 ? tp->tm_year + 1900 : tp->tm_year, 88 tp->tm_year < 1900 ? tp->tm_year + 1900 : tp->tm_year,
89 tp->tm_hour, tp->tm_min, tp->tm_sec); 89 tp->tm_hour, tp->tm_min, tp->tm_sec);
90} 90}
91 91
92/* 92/*
93 * If (e) is Calc then just calculate the sizes 93 * If (e) is Calc then just calculate the sizes
94 * Otherwise display the mount node on stdout 94 * Otherwise display the mount node on stdout
95 */ 95 */
96static void 96static void
97show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid) 97show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid)
98{ 98{
99 switch (e) { 99 switch (e) {
100 case Calc: 100 case Calc:
101 { 101 {
102 int mw = strlen(mt->mt_mountinfo); 102 int mw = strlen(mt->mt_mountinfo);
103 int dw = strlen(mt->mt_directory); 103 int dw = strlen(mt->mt_directory);
104 int tw = strlen(mt->mt_type); 104 int tw = strlen(mt->mt_type);
105 if (mw > *mwid) 105 if (mw > *mwid)
106 *mwid = mw; 106 *mwid = mw;
107 if (dw > *dwid) 107 if (dw > *dwid)
108 *dwid = dw; 108 *dwid = dw;
109 if (tw > *twid) 109 if (tw > *twid)
110 *twid = tw; 110 *twid = tw;
111 } 111 }
112 break; 112 break;
113 113
114 case Full: 114 case Full:
115 { 115 {
116 printf("%-*.*s %-*.*s %-*.*s %s\n\t%-5d %-7d %-6d %-7d %-7d %-6d", 116 printf("%-*.*s %-*.*s %-*.*s %s\n\t%-5d %-7d %-6d %-7d %-7d %-6d",
117 *dwid, *dwid, 117 *dwid, *dwid,
118 *mt->mt_directory ? mt->mt_directory : "/", /* XXX */ 118 *mt->mt_directory ? mt->mt_directory : "/", /* XXX */
119 *twid, *twid, 119 *twid, *twid,
120 mt->mt_type, 120 mt->mt_type,
121 *mwid, *mwid, 121 *mwid, *mwid,
122 mt->mt_mountinfo, 122 mt->mt_mountinfo,
123 mt->mt_mountpoint, 123 mt->mt_mountpoint,
124 124
125 mt->mt_mountuid, 125 mt->mt_mountuid,
126 mt->mt_getattr, 126 mt->mt_getattr,
127 mt->mt_lookup, 127 mt->mt_lookup,
128 mt->mt_readdir, 128 mt->mt_readdir,
129 mt->mt_readlink, 129 mt->mt_readlink,
130 mt->mt_statfs); 130 mt->mt_statfs);
131 time_print(mt->mt_mounttime); 131 time_print(mt->mt_mounttime);
132 printf("\n"); 132 printf("\n");
133 } 133 }
134 break; 134 break;
135 135
136 case Stats: 136 case Stats:
137 { 137 {
138 printf("%-*.*s %-5d %-7d %-6d %-7d %-7d %-6d ", 138 printf("%-*.*s %-5d %-7d %-6d %-7d %-7d %-6d ",
139 *dwid, *dwid, 139 *dwid, *dwid,
140 *mt->mt_directory ? mt->mt_directory : "/", /* XXX */ 140 *mt->mt_directory ? mt->mt_directory : "/", /* XXX */
141 141
142 mt->mt_mountuid, 142 mt->mt_mountuid,
143 mt->mt_getattr, 143 mt->mt_getattr,
144 mt->mt_lookup, 144 mt->mt_lookup,
145 mt->mt_readdir, 145 mt->mt_readdir,
146 mt->mt_readlink, 146 mt->mt_readlink,
147 mt->mt_statfs); 147 mt->mt_statfs);
148 time_print(mt->mt_mounttime); 148 time_print(mt->mt_mounttime);
149 printf("\n"); 149 printf("\n");
150 } 150 }
151 break; 151 break;
152 152
153 case Short: 153 case Short:
154 { 154 {
155 printf("%-*.*s %-*.*s %-*.*s %s\n", 155 printf("%-*.*s %-*.*s %-*.*s %s\n",
156 *dwid, *dwid, 156 *dwid, *dwid,
157 *mt->mt_directory ? mt->mt_directory : "/", 157 *mt->mt_directory ? mt->mt_directory : "/",
158 *twid, *twid, 158 *twid, *twid,
159 mt->mt_type, 159 mt->mt_type,
160 *mwid, *mwid, 160 *mwid, *mwid,
161 mt->mt_mountinfo, 161 mt->mt_mountinfo,
162 mt->mt_mountpoint); 162 mt->mt_mountpoint);
163 } 163 }
164 break; 164 break;
165 165
166 default: 166 default:
167 break; 167 break;
168 } 168 }
169} 169}
170 170
171 171
172/* 172/*
173 * Display a pwd data 173 * Display a pwd data
174 */ 174 */
175static void 175static void
176show_pwd(amq_mount_tree *mt, char *path, size_t l, int *flag) 176show_pwd(amq_mount_tree *mt, char *path, size_t l, int *flag)
177{ 177{
178 int len; 178 int len;
179 179
180 while (mt) { 180 while (mt) {
181 len = strlen(mt->mt_mountpoint); 181 len = strlen(mt->mt_mountpoint);
182 if (NSTREQ(path, mt->mt_mountpoint, len) && 182 if (NSTREQ(path, mt->mt_mountpoint, len) &&
183 !STREQ(mt->mt_directory, mt->mt_mountpoint)) { 183 !STREQ(mt->mt_directory, mt->mt_mountpoint)) {
184 char buf[MAXPATHLEN+1]; /* must be same size as 'path' */ 184 char buf[MAXPATHLEN+1]; /* must be same size as 'path' */
185 xstrlcpy(buf, mt->mt_directory, sizeof(buf)); 185 xstrlcpy(buf, mt->mt_directory, sizeof(buf));
186 xstrlcat(buf, &path[len], sizeof(buf)); 186 xstrlcat(buf, &path[len], sizeof(buf));
187 xstrlcpy(path, buf, l); 187 xstrlcpy(path, buf, l);
188 *flag = 1; 188 *flag = 1;
189 } 189 }
190 show_pwd(mt->mt_next, path, l, flag); 190 show_pwd(mt->mt_next, path, l, flag);
191 mt = mt->mt_child; 191 mt = mt->mt_child;
192 } 192 }
193} 193}
194 194
195 195
196/* 196/*
197 * Display a mount tree. 197 * Display a mount tree.
198 */ 198 */
199static void 199static void
200show_mt(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *pwid) 200show_mt(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *pwid)
201{ 201{
202 while (mt) { 202 while (mt) {
203 show_mti(mt, e, mwid, dwid, pwid); 203 show_mti(mt, e, mwid, dwid, pwid);
204 show_mt(mt->mt_next, e, mwid, dwid, pwid); 204 show_mt(mt->mt_next, e, mwid, dwid, pwid);
205 mt = mt->mt_child; 205 mt = mt->mt_child;
206 } 206 }
207} 207}
208 208
209 209
210static void 210static void
211show_mi(amq_mount_info_list *ml, enum show_opt e, int *mwid, int *dwid, int *twid) 211show_mi(amq_mount_info_list *ml, enum show_opt e, int *mwid, int *dwid, int *twid)
212{ 212{
213 u_int i; 213 u_int i;
214 214
215 switch (e) { 215 switch (e) {
216 216
217 case Calc: 217 case Calc:
218 { 218 {
219 for (i = 0; i < ml->amq_mount_info_list_len; i++) { 219 for (i = 0; i < ml->amq_mount_info_list_len; i++) {
220 amq_mount_info *mi = &ml->amq_mount_info_list_val[i]; 220 amq_mount_info *mi = &ml->amq_mount_info_list_val[i];
221 int mw = strlen(mi->mi_mountinfo); 221 int mw = strlen(mi->mi_mountinfo);
222 int dw = strlen(mi->mi_mountpt); 222 int dw = strlen(mi->mi_mountpt);
223 int tw = strlen(mi->mi_type); 223 int tw = strlen(mi->mi_type);
224 if (mw > *mwid) 224 if (mw > *mwid)
225 *mwid = mw; 225 *mwid = mw;
226 if (dw > *dwid) 226 if (dw > *dwid)
227 *dwid = dw; 227 *dwid = dw;
228 if (tw > *twid) 228 if (tw > *twid)
229 *twid = tw; 229 *twid = tw;
230 } 230 }
231 } 231 }
232 break; 232 break;
233 233
234 case Full: 234 case Full:
235 { 235 {
236 for (i = 0; i < ml->amq_mount_info_list_len; i++) { 236 for (i = 0; i < ml->amq_mount_info_list_len; i++) {
237 amq_mount_info *mi = &ml->amq_mount_info_list_val[i]; 237 amq_mount_info *mi = &ml->amq_mount_info_list_val[i];
238 printf("%-*.*s %-*.*s %-*.*s %-3d %s is %s ", 238 printf("%-*.*s %-*.*s %-*.*s %-3d %s is %s ",
239 *mwid, *mwid, mi->mi_mountinfo, 239 *mwid, *mwid, mi->mi_mountinfo,
240 *dwid, *dwid, mi->mi_mountpt, 240 *dwid, *dwid, mi->mi_mountpt,
241 *twid, *twid, mi->mi_type, 241 *twid, *twid, mi->mi_type,
242 mi->mi_refc, mi->mi_fserver, 242 mi->mi_refc, mi->mi_fserver,
243 mi->mi_up > 0 ? "up" : 243 mi->mi_up > 0 ? "up" :
244 mi->mi_up < 0 ? "starting" : "down"); 244 mi->mi_up < 0 ? "starting" : "down");
245 if (mi->mi_error > 0) { 245 if (mi->mi_error > 0) {
246 printf(" (%s)", strerror(mi->mi_error)); 246 printf(" (%s)", strerror(mi->mi_error));
247 } else if (mi->mi_error < 0) { 247 } else if (mi->mi_error < 0) {
248 fputs(" (in progress)", stdout); 248 fputs(" (in progress)", stdout);
249 } 249 }
250 fputc('\n', stdout); 250 fputc('\n', stdout);
251 } 251 }
252 } 252 }
253 break; 253 break;
254 254
255 default: 255 default:
256 break; 256 break;
257 } 257 }
258} 258}
259 259
260static void 260static void
261show_mapinfo(amq_map_info_list *ml, enum show_opt e, int *nwid, int *wwid) 261show_mapinfo(amq_map_info_list *ml, enum show_opt e, int *nwid, int *wwid)
262{ 262{
263 u_int i; 263 u_int i;
264 264
265 switch (e) { 265 switch (e) {
266 266
267 case Calc: 267 case Calc:
268 { 268 {
269 for (i = 0; i < ml->amq_map_info_list_len; i++) { 269 for (i = 0; i < ml->amq_map_info_list_len; i++) {
270 amq_map_info *mi = &ml->amq_map_info_list_val[i]; 270 amq_map_info *mi = &ml->amq_map_info_list_val[i];
271 int nw = strlen(mi->mi_name); 271 int nw = strlen(mi->mi_name);
272 int ww = strlen(mi->mi_wildcard ? mi->mi_wildcard : "(null"); 272 int ww = strlen(mi->mi_wildcard ? mi->mi_wildcard : "(null");
273 if (nw > *nwid) 273 if (nw > *nwid)
274 *nwid = nw; 274 *nwid = nw;
275 if (ww > *wwid) 275 if (ww > *wwid)
276 *wwid = ww; 276 *wwid = ww;
277 } 277 }
278 } 278 }
279 break; 279 break;
280 280
281 case Full: 281 case Full:
282 { 282 {
283 printf("%-*.*s %-*.*s %-8.8s %-7.7s %-7.7s %-7.7s %-s Modified\n", 283 printf("%-*.*s %-*.*s %-8.8s %-7.7s %-7.7s %-7.7s %-s Modified\n",
284 *nwid, *nwid, "Name", 284 *nwid, *nwid, "Name",
285 *wwid, *wwid, "Wild", 285 *wwid, *wwid, "Wild",
286 "Flags", "Refcnt", "Entries", "Reloads", "Stat"); 286 "Flags", "Refcnt", "Entries", "Reloads", "Stat");
287 for (i = 0; i < ml->amq_map_info_list_len; i++) { 287 for (i = 0; i < ml->amq_map_info_list_len; i++) {
288 amq_map_info *mi = &ml->amq_map_info_list_val[i]; 288 amq_map_info *mi = &ml->amq_map_info_list_val[i];
289 printf("%-*.*s %*.*s %-8x %-7d %-7d %-7d %s ", 289 printf("%-*.*s %*.*s %-8x %-7d %-7d %-7d %s ",
290 *nwid, *nwid, mi->mi_name, 290 *nwid, *nwid, mi->mi_name,
291 *wwid, *wwid, mi->mi_wildcard, 291 *wwid, *wwid, mi->mi_wildcard,
292 mi->mi_flags, mi->mi_refc, mi->mi_nentries, mi->mi_reloads, 292 mi->mi_flags, mi->mi_refc, mi->mi_nentries, mi->mi_reloads,
293 mi->mi_up == -1 ? "root" : (mi->mi_up ? " up" : "down")); 293 mi->mi_up == -1 ? "root" : (mi->mi_up ? " up" : "down"));
294 time_print(mi->mi_modify); 294 time_print(mi->mi_modify);
295 fputc('\n', stdout); 295 fputc('\n', stdout);
296 } 296 }
297 } 297 }
298 break; 298 break;
299 299
300 default: 300 default:
301 break; 301 break;
302 } 302 }
303} 303}
304 304
305/* 305/*
306 * Display general mount statistics 306 * Display general mount statistics
307 */ 307 */
308static void 308static void
309show_ms(amq_mount_stats *ms) 309show_ms(amq_mount_stats *ms)
310{ 310{
311 printf("\ 311 printf("\
312requests stale mount mount unmount\n\ 312requests stale mount mount unmount\n\
313deferred fhandles ok failed failed\n\ 313deferred fhandles ok failed failed\n\
314%-9d %-9d %-9d %-9d %-9d\n", 314%-9d %-9d %-9d %-9d %-9d\n",
315 ms->as_drops, ms->as_stale, ms->as_mok, ms->as_merr, ms->as_uerr); 315 ms->as_drops, ms->as_stale, ms->as_mok, ms->as_merr, ms->as_uerr);
316} 316}
317 317
318 318
319#if defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) 319#if defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT)
320static char * 320static char *
321cluster_server(void) 321cluster_server(void)
322{ 322{
323 struct cct_entry *cp; 323 struct cct_entry *cp;
324 324
325 if (cnodeid() == 0) { 325 if (cnodeid() == 0) {
326 /* 326 /*
327 * Not clustered 327 * Not clustered
328 */ 328 */
329 return def_server; 329 return def_server;
330 } 330 }
331 while (cp = getccent()) 331 while (cp = getccent())
332 if (cp->cnode_type == 'r') 332 if (cp->cnode_type == 'r')
333 return cp->cnode_name; 333 return cp->cnode_name;
334 334
335 return def_server; 335 return def_server;
336} 336}
337#endif /* defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) */ 337#endif /* defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) */
338 338
339 339
340static void 340static void
341print_umnt_error(amq_sync_umnt *rv, const char *fs) 341print_umnt_error(amq_sync_umnt *rv, const char *fs)
342{ 342{
343 343
344 switch (rv->au_etype) { 344 switch (rv->au_etype) {
345 case AMQ_UMNT_OK: 345 case AMQ_UMNT_OK:
346 break; 346 break;
347 case AMQ_UMNT_FAILED: 347 case AMQ_UMNT_FAILED:
348 printf("unmount failed: %s\n", strerror(rv->au_errno)); 348 printf("unmount failed: %s\n", strerror(rv->au_errno));
349 break; 349 break;
350 case AMQ_UMNT_FORK: 350 case AMQ_UMNT_FORK:
351 if (rv->au_errno == 0) 351 if (rv->au_errno == 0)
352 printf("%s is not mounted\n", fs); 352 printf("%s is not mounted\n", fs);
353 else 353 else
354 printf("falling back to asynchronous unmount: %s\n", 354 printf("falling back to asynchronous unmount: %s\n",
355 strerror(rv->au_errno)); 355 strerror(rv->au_errno));
356 break; 356 break;
357 case AMQ_UMNT_READ: 357 case AMQ_UMNT_READ:
358 printf("pipe read error: %s\n", strerror(rv->au_errno)); 358 printf("pipe read error: %s\n", strerror(rv->au_errno));
359 break; 359 break;
360 case AMQ_UMNT_SERVER: 360 case AMQ_UMNT_SERVER:
361 printf("amd server down\n"); 361 printf("amd server down\n");
362 break; 362 break;
363 case AMQ_UMNT_SIGNAL: 363 case AMQ_UMNT_SIGNAL:
364 printf("got signal: %d\n", rv->au_signal); 364 printf("got signal: %d\n", rv->au_signal);
365 break; 365 break;
366 /* 366 /*
367 * Omit default so the compiler can check for missing cases. 367 * Omit default so the compiler can check for missing cases.
368 * 368 *
369 default: 369 default:
370 break; 370 break;
371 */ 371 */
372 } 372 }
373} 373}
374 374
375 375
376static int 376static int
377amu_sync_umnt_to_retval(amq_sync_umnt *rv) 377amu_sync_umnt_to_retval(amq_sync_umnt *rv)
378{ 378{
379 switch (rv->au_etype) { 379 switch (rv->au_etype) {
380 case AMQ_UMNT_FORK: 380 case AMQ_UMNT_FORK:
381 if (rv->au_errno == 0) { 381 if (rv->au_errno == 0) {
382 /* 382 /*
383 * We allow this error so that things like: 383 * We allow this error so that things like:
384 * amq -uu /l/cd0d && eject cd0 384 * amq -uu /l/cd0d && eject cd0
385 * will work when /l/cd0d is not mounted. 385 * will work when /l/cd0d is not mounted.
386 * XXX - We still print an error message. 386 * XXX - We still print an error message.
387 */ 387 */
388 return 0; 388 return 0;
389 } 389 }
390 /*FALLTHROUGH*/ 390 /*FALLTHROUGH*/
391 default: 391 default:
392 return rv->au_etype; 392 return rv->au_etype;
393 } 393 }
394} 394}
395 395
396 396
397static int 397static int
398clnt_failed(CLIENT *clnt, char *server) 398clnt_failed(CLIENT *clnt, char *server)
399{ 399{
400 fprintf(stderr, "%s: ", am_get_progname()); 400 fprintf(stderr, "%s: ", am_get_progname());
401 clnt_perror(clnt, server); 401 clnt_perror(clnt, server);
402 return 1; 402 return 1;
403} 403}
404 404
405 405
406/* 406/*
407 * MAIN 407 * MAIN
408 */ 408 */
409int 409int
410main(int argc, char *argv[]) 410main(int argc, char *argv[])
411{ 411{
412 int opt_ch; 412 int opt_ch;
413 int errs = 0; 413 int errs = 0;
414 char *server; 414 char *server;
415 struct sockaddr_in server_addr; 415 struct sockaddr_in server_addr;
416 CLIENT *clnt = NULL; 416 CLIENT *clnt = NULL;
417 struct hostent *hp; 417 struct hostent *hp;
418 int nodefault = 0; 418 int nodefault = 0;
419 struct timeval tv; 419 struct timeval tv;
420 char *progname = NULL; 420 char *progname = NULL;
421 421
422 /* 422 /*
423 * Compute program name 423 * Compute program name
424 */ 424 */
425 if (argv[0]) { 425 if (argv[0]) {
426 progname = strrchr(argv[0], '/'); 426 progname = strrchr(argv[0], '/');
427 if (progname && progname[1]) 427 if (progname && progname[1])
428 progname++; 428 progname++;
429 else 429 else
430 progname = argv[0]; 430 progname = argv[0];
431 } 431 }
432 if (!progname) 432 if (!progname)
433 progname = "amq"; 433 progname = "amq";
434 am_set_progname(progname); 434 am_set_progname(progname);
435 435
436 /* 436 /*
437 * Parse arguments 437 * Parse arguments
438 */ 438 */
439 while ((opt_ch = getopt(argc, argv, "Hfh:il:mqsuvx:D:pP:TUw")) != -1) 439 while ((opt_ch = getopt(argc, argv, "Hfh:il:mqsuvx:D:pP:TUw")) != -1)
440 switch (opt_ch) { 440 switch (opt_ch) {
441 case 'H': 441 case 'H':
442 goto show_usage; 442 goto show_usage;
443 break; 443 break;
444 444
445 case 'f': 445 case 'f':
446 flush_flag = 1; 446 flush_flag = 1;
447 nodefault = 1; 447 nodefault = 1;
448 break; 448 break;
449 449
450 case 'h': 450 case 'h':
451 def_server = optarg; 451 def_server = optarg;
452 break; 452 break;
453 453
454 case 'i': 454 case 'i':
455 mapinfo_flag = 1; 455 mapinfo_flag = 1;
456 nodefault = 1; 456 nodefault = 1;
457 break; 457 break;
458 458
459 case 'l': 459 case 'l':
460 amq_logfile = optarg; 460 amq_logfile = optarg;
461 nodefault = 1; 461 nodefault = 1;
462 break; 462 break;
463 463
464 case 'm': 464 case 'm':
465 minfo_flag = 1; 465 minfo_flag = 1;
466 nodefault = 1; 466 nodefault = 1;
467 break; 467 break;
468 468
469 case 'p': 469 case 'p':
470 getpid_flag = 1; 470 getpid_flag = 1;
471 nodefault = 1; 471 nodefault = 1;
472 break; 472 break;
473 473
474 case 'q': 474 case 'q':
475 quiet_flag = 1; 475 quiet_flag = 1;
476 nodefault = 1; 476 nodefault = 1;
477 break; 477 break;
478 478
479 case 's': 479 case 's':
480 stats_flag = 1; 480 stats_flag = 1;
481 nodefault = 1; 481 nodefault = 1;
482 break; 482 break;
483 483
484 case 'u': 484 case 'u':
485 unmount_flag++; 485 unmount_flag++;
486 nodefault = 1; 486 nodefault = 1;
487 break; 487 break;
488 488
489 case 'v': 489 case 'v':
490 getvers_flag = 1; 490 getvers_flag = 1;
491 nodefault = 1; 491 nodefault = 1;
492 break; 492 break;
493 493
494 case 'x': 494 case 'x':
495 xlog_optstr = optarg; 495 xlog_optstr = optarg;
496 nodefault = 1; 496 nodefault = 1;
497 break; 497 break;
498 498
499 case 'D': 499 case 'D':
500 debug_opts = optarg; 500 debug_opts = optarg;
501 nodefault = 1; 501 nodefault = 1;
502 break; 502 break;
503 503
504 case 'P': 504 case 'P':
505 amd_program_number = atoi(optarg); 505 amd_program_number = atoi(optarg);
506 break; 506 break;
507 507
508 case 'T': 508 case 'T':
509 use_tcp_flag = 1; 509 use_tcp_flag = 1;
510 break; 510 break;
511 511
512 case 'U': 512 case 'U':
513 use_udp_flag = 1; 513 use_udp_flag = 1;
514 break; 514 break;
515 515
516 case 'w': 516 case 'w':
517 getpwd_flag = 1; 517 getpwd_flag = 1;
518 break; 518 break;
519 519
520 default: 520 default:
521 errs = 1; 521 errs = 1;
522 break; 522 break;
523 } 523 }
524 524
525 if (optind == argc) { 525 if (optind == argc) {
526 if (unmount_flag) 526 if (unmount_flag)
527 errs = 1; 527 errs = 1;
528 } 528 }
529 if (errs) { 529 if (errs) {
530 show_usage: 530 show_usage:
531 fprintf(stderr, "\ 531 fprintf(stderr, "\
532Usage: %s [-fimpqsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\ 532Usage: %s [-fimpqsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\
533\t[-x log_options] [-D debug_options]\n\ 533\t[-x log_options] [-D debug_options]\n\
534\t[-P program_number] [[-u[u]] directory ...]\n", 534\t[-P program_number] [[-u[u]] directory ...]\n",
535 am_get_progname() 535 am_get_progname()
536 ); 536 );
537 exit(1); 537 exit(1);
538 } 538 }
539 539
540 540
541 /* set use_udp and use_tcp flags both to on if none are defined */ 541 /* set use_udp and use_tcp flags both to on if none are defined */
542 if (!use_tcp_flag && !use_udp_flag) 542 if (!use_tcp_flag && !use_udp_flag)
543 use_tcp_flag = use_udp_flag = 1; 543 use_tcp_flag = use_udp_flag = 1;
544 544
545#if defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) 545#if defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT)
546 /* 546 /*
547 * Figure out root server of cluster 547 * Figure out root server of cluster
548 */ 548 */
549 if (def_server == localhost) 549 if (def_server == localhost)
550 server = cluster_server(); 550 server = cluster_server();
551 else 551 else
552#endif /* defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) */ 552#endif /* defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) */
553 server = def_server; 553 server = def_server;
554 554
555 /* 555 /*
556 * Get address of server 556 * Get address of server
557 */ 557 */
558 if ((hp = gethostbyname(server)) == 0 && !STREQ(server, localhost)) { 558 if ((hp = gethostbyname(server)) == 0 && !STREQ(server, localhost)) {
559 fprintf(stderr, "%s: Can't get address of %s\n", 559 fprintf(stderr, "%s: Can't get address of %s\n",
560 am_get_progname(), server); 560 am_get_progname(), server);
561 exit(1); 561 exit(1);
562 } 562 }
563 memset(&server_addr, 0, sizeof(server_addr)); 563 memset(&server_addr, 0, sizeof(server_addr));
564 /* as per POSIX, sin_len need not be set (used internally by kernel) */ 564 /* as per POSIX, sin_len need not be set (used internally by kernel) */
565 server_addr.sin_family = AF_INET; 565 server_addr.sin_family = AF_INET;
566 if (hp) { 566 if (hp) {
567 memmove((voidp) &server_addr.sin_addr, (voidp) hp->h_addr, 567 memmove((voidp) &server_addr.sin_addr, (voidp) hp->h_addr,
568 sizeof(server_addr.sin_addr)); 568 sizeof(server_addr.sin_addr));
569 } else { 569 } else {
570 /* fake "localhost" */ 570 /* fake "localhost" */
571 server_addr.sin_addr.s_addr = htonl(0x7f000001); 571 server_addr.sin_addr.s_addr = htonl(0x7f000001);
572 } 572 }
573 573
574 /* 574 /*
575 * Create RPC endpoint 575 * Create RPC endpoint
576 */ 576 */
577 tv.tv_sec = 5; /* 5 seconds for timeout or per retry */ 577 tv.tv_sec = 5; /* 5 seconds for timeout or per retry */
578 tv.tv_usec = 0; 578 tv.tv_usec = 0;
579 579
580 if (use_tcp_flag) /* try tcp first */ 580 if (use_tcp_flag) /* try tcp first */
581 clnt = clnt_create(server, amd_program_number, AMQ_VERSION, "tcp"); 581 clnt = clnt_create(server, amd_program_number, AMQ_VERSION, "tcp");
582 if (!clnt && use_udp_flag) { /* try udp next */ 582 if (!clnt && use_udp_flag) { /* try udp next */
583 clnt = clnt_create(server, amd_program_number, AMQ_VERSION, "udp"); 583 clnt = clnt_create(server, amd_program_number, AMQ_VERSION, "udp");
584 /* if ok, set timeout (valid for connectionless transports only) */ 584 /* if ok, set timeout (valid for connectionless transports only) */
585 if (clnt) 585 if (clnt)
586 clnt_control(clnt, CLSET_RETRY_TIMEOUT, (char *) &tv); 586 clnt_control(clnt, CLSET_RETRY_TIMEOUT, (char *) &tv);
587 } 587 }
588 if (!clnt) { 588 if (!clnt) {
589 fprintf(stderr, "%s: ", am_get_progname()); 589 fprintf(stderr, "%s: ", am_get_progname());
590 clnt_pcreateerror(server); 590 clnt_pcreateerror(server);
591 exit(1); 591 exit(1);
592 } 592 }
593 593
594 /* 594 /*
595 * Control debugging 595 * Control debugging
596 */ 596 */
597 if (debug_opts) { 597 if (debug_opts) {
598 int *rc; 598 int *rc;
599 amq_setopt opt; 599 amq_setopt opt;
600 opt.as_opt = AMOPT_DEBUG; 600 opt.as_opt = AMOPT_DEBUG;
601 opt.as_str = debug_opts; 601 opt.as_str = debug_opts;
602 rc = amqproc_setopt_1(&opt, clnt); 602 rc = amqproc_setopt_1(&opt, clnt);
603 if (rc && *rc < 0) { 603 if (rc && *rc < 0) {
604 fprintf(stderr, "%s: daemon not compiled for debug\n", 604 fprintf(stderr, "%s: daemon not compiled for debug\n",
605 am_get_progname()); 605 am_get_progname());
606 errs = 1; 606 errs = 1;
607 } else if (!rc || *rc > 0) { 607 } else if (!rc || *rc > 0) {
608 fprintf(stderr, "%s: debug setting for \"%s\" failed\n", 608 fprintf(stderr, "%s: debug setting for \"%s\" failed\n",
609 am_get_progname(), debug_opts); 609 am_get_progname(), debug_opts);
610 errs = 1; 610 errs = 1;
611 } 611 }
612 } 612 }
613 613
614 /* 614 /*
615 * Control logging 615 * Control logging
616 */ 616 */
617 if (xlog_optstr) { 617 if (xlog_optstr) {
618 int *rc; 618 int *rc;
619 amq_setopt opt; 619 amq_setopt opt;
620 opt.as_opt = AMOPT_XLOG; 620 opt.as_opt = AMOPT_XLOG;
621 opt.as_str = xlog_optstr; 621 opt.as_str = xlog_optstr;
622 rc = amqproc_setopt_1(&opt, clnt); 622 rc = amqproc_setopt_1(&opt, clnt);
623 if (!rc || *rc) { 623 if (!rc || *rc) {
624 fprintf(stderr, "%s: setting log level to \"%s\" failed\n", 624 fprintf(stderr, "%s: setting log level to \"%s\" failed\n",
625 am_get_progname(), xlog_optstr); 625 am_get_progname(), xlog_optstr);
626 errs = 1; 626 errs = 1;
627 } 627 }
628 } 628 }
629 629
630 /* 630 /*
631 * Control log file 631 * Control log file
632 */ 632 */
633 if (amq_logfile) { 633 if (amq_logfile) {
634 int *rc; 634 int *rc;
635 amq_setopt opt; 635 amq_setopt opt;
636 opt.as_opt = AMOPT_LOGFILE; 636 opt.as_opt = AMOPT_LOGFILE;
637 opt.as_str = amq_logfile; 637 opt.as_str = amq_logfile;
638 rc = amqproc_setopt_1(&opt, clnt); 638 rc = amqproc_setopt_1(&opt, clnt);
639 if (!rc || *rc) { 639 if (!rc || *rc) {
640 fprintf(stderr, "%s: setting logfile to \"%s\" failed\n", 640 fprintf(stderr, "%s: setting logfile to \"%s\" failed\n",
641 am_get_progname(), amq_logfile); 641 am_get_progname(), amq_logfile);
642 errs = 1; 642 errs = 1;
643 } 643 }
644 } 644 }
645 645
646 /* 646 /*
647 * Flush map cache 647 * Flush map cache
648 */ 648 */
649 if (flush_flag) { 649 if (flush_flag) {
650 int *rc; 650 int *rc;
651 amq_setopt opt; 651 amq_setopt opt;
652 opt.as_opt = AMOPT_FLUSHMAPC; 652 opt.as_opt = AMOPT_FLUSHMAPC;
653 opt.as_str = ""; 653 opt.as_str = "";
654 rc = amqproc_setopt_1(&opt, clnt); 654 rc = amqproc_setopt_1(&opt, clnt);
655 if (!rc || *rc) { 655 if (!rc || *rc) {
656 fprintf(stderr, "%s: amd on %s cannot flush the map cache\n", 656 fprintf(stderr, "%s: amd on %s cannot flush the map cache\n",
657 am_get_progname(), server); 657 am_get_progname(), server);
658 errs = 1; 658 errs = 1;
659 } 659 }
660 } 660 }
661 661
662 /* 662 /*
663 * getpwd info 663 * getpwd info
664 */ 664 */
665 if (getpwd_flag) { 665 if (getpwd_flag) {
666 char path[MAXPATHLEN+1]; 666 char path[MAXPATHLEN+1];
667 char *wd; 667 char *wd;
668 amq_mount_tree_list *mlp; 668 amq_mount_tree_list *mlp;
669 amq_mount_tree_p mt; 669 amq_mount_tree_p mt;
670 u_int i; 670 u_int i;
671 int flag; 671 int flag;
672 672
673 wd = getcwd(path, MAXPATHLEN+1); 673 wd = getcwd(path, MAXPATHLEN+1);
674 if (!wd) { 674 if (!wd) {
675 fprintf(stderr, "%s: getcwd failed (%s)", am_get_progname(), 675 fprintf(stderr, "%s: getcwd failed (%s)", am_get_progname(),
676 strerror(errno)); 676 strerror(errno));
677 exit(1); 677 exit(1);
678 } 678 }
679 mlp = amqproc_export_1((voidp) 0, clnt); 679 mlp = amqproc_export_1((voidp) 0, clnt);
680 for (i = 0; mlp && i < mlp->amq_mount_tree_list_len; i++) { 680 for (i = 0; mlp && i < mlp->amq_mount_tree_list_len; i++) {
681 mt = mlp->amq_mount_tree_list_val[i]; 681 mt = mlp->amq_mount_tree_list_val[i];
682 while (1) { 682 while (1) {
683 flag = 0; 683 flag = 0;
684 show_pwd(mt, path, sizeof(path), &flag); 684 show_pwd(mt, path, sizeof(path), &flag);
685 if (!flag) { 685 if (!flag) {
686 printf("%s\n", path); 686 printf("%s\n", path);
687 break; 687 break;
688 } 688 }
689 } 689 }
690 } 690 }
691 exit(0); 691 exit(0);
692 } 692 }
693 693
694 /* 694 /*
695 * Mount info 695 * Mount info
696 */ 696 */
697 if (minfo_flag) { 697 if (minfo_flag) {
698 int dummy; 698 int dummy;
699 amq_mount_info_list *ml = amqproc_getmntfs_1(&dummy, clnt); 699 amq_mount_info_list *ml = amqproc_getmntfs_1(&dummy, clnt);
700 if (ml) { 700 if (ml) {
701 int mwid = 0, dwid = 0, twid = 0; 701 int mwid = 0, dwid = 0, twid = 0;
702 show_mi(ml, Calc, &mwid, &dwid, &twid); 702 show_mi(ml, Calc, &mwid, &dwid, &twid);
703 mwid++; 703 mwid++;
704 dwid++; 704 dwid++;
705 twid++; 705 twid++;
706 show_mi(ml, Full, &mwid, &dwid, &twid); 706 show_mi(ml, Full, &mwid, &dwid, &twid);
707 707
708 } else { 708 } else {
709 fprintf(stderr, "%s: amd on %s cannot provide mount info\n", 709 fprintf(stderr, "%s: amd on %s cannot provide mount info\n",
710 am_get_progname(), server); 710 am_get_progname(), server);
711 } 711 }
712 } 712 }
713 713
714 714
715 /* 715 /*
716 * Map 716 * Map
717 */ 717 */
718 if (mapinfo_flag) { 718 if (mapinfo_flag) {
719 int dummy; 719 int dummy;
720 amq_map_info_list *ml = amqproc_getmapinfo_1(&dummy, clnt); 720 amq_map_info_list *ml = amqproc_getmapinfo_1(&dummy, clnt);
721 if (ml) { 721 if (ml) {
722 int mwid = 0, wwid = 0; 722 int mwid = 0, wwid = 0;
723 show_mapinfo(ml, Calc, &mwid, &wwid); 723 show_mapinfo(ml, Calc, &mwid, &wwid);
724 mwid++; 724 mwid++;
725 if (wwid) 725 if (wwid)
726 wwid++; 726 wwid++;
727 show_mapinfo(ml, Full, &mwid, &wwid); 727 show_mapinfo(ml, Full, &mwid, &wwid);
728 } else { 728 } else {
729 fprintf(stderr, "%s: amd on %s cannot provide map info\n", 729 fprintf(stderr, "%s: amd on %s cannot provide map info\n",
730 am_get_progname(), server); 730 am_get_progname(), server);
731 } 731 }
732 } 732 }
733 733
734 /* 734 /*
735 * Get Version 735 * Get Version
736 */ 736 */
737 if (getvers_flag) { 737 if (getvers_flag) {
738 amq_string *spp = amqproc_getvers_1((voidp) 0, clnt); 738 amq_string *spp = amqproc_getvers_1((voidp) 0, clnt);
739 if (spp && *spp) { 739 if (spp && *spp) {
740 fputs(*spp, stdout); 740 fputs(*spp, stdout);
741 XFREE(*spp); 741 XFREE(*spp);
742 } else { 742 } else {
743 fprintf(stderr, "%s: failed to get version information\n", 743 fprintf(stderr, "%s: failed to get version information\n",
744 am_get_progname()); 744 am_get_progname());
745 errs = 1; 745 errs = 1;
746 } 746 }
747 } 747 }
748 748
749 /* 749 /*
750 * Get PID of amd 750 * Get PID of amd
751 */ 751 */
752 if (getpid_flag) { 752 if (getpid_flag) {
753 int *ip = amqproc_getpid_1((voidp) 0, clnt); 753 int *ip = amqproc_getpid_1((voidp) 0, clnt);
754 if (ip && *ip) { 754 if (ip && *ip) {
755 printf("%d\n", *ip); 755 printf("%d\n", *ip);
756 } else { 756 } else {
757 fprintf(stderr, "%s: failed to get PID of amd\n", am_get_progname()); 757 fprintf(stderr, "%s: failed to get PID of amd\n", am_get_progname());
758 errs = 1; 758 errs = 1;
759 } 759 }
760 } 760 }
761 761
762 /* 762 /*
763 * Apply required operation to all remaining arguments 763 * Apply required operation to all remaining arguments
764 */ 764 */
765 if (optind < argc) { 765 if (optind < argc) {
766 do { 766 do {
767 char *fs = argv[optind++]; 767 char *fs = argv[optind++];
768 if (unmount_flag > 1) { 768 if (unmount_flag > 1) {
769 amq_sync_umnt *sup; 769 amq_sync_umnt *sup;
770 /* 770 /*
771 * Synchronous unmount request 771 * Synchronous unmount request
772 */ 772 */
773 sup = amqproc_sync_umnt_1(&fs, clnt); 773 sup = amqproc_sync_umnt_1(&fs, clnt);
774 if (sup) { 774 if (sup) {
775 if (quiet_flag == 0) 775 if (quiet_flag == 0)
776 print_umnt_error(sup, fs); 776 print_umnt_error(sup, fs);
777 errs = amu_sync_umnt_to_retval(sup); 777 errs = amu_sync_umnt_to_retval(sup);
778 } else { 778 } else {
779 errs = clnt_failed(clnt, server); 779 errs = clnt_failed(clnt, server);
780 } 780 }
781 } else if (unmount_flag) { 781 } else if (unmount_flag) {
782 /* 782 /*
783 * Unmount request 783 * Unmount request
784 */ 784 */
785 amqproc_umnt_1(&fs, clnt); 785 amqproc_umnt_1(&fs, clnt);
786 } else { 786 } else {
787 /* 787 /*
788 * Stats request 788 * Stats request
789 */ 789 */
790 amq_mount_tree_p *mtp = amqproc_mnttree_1(&fs, clnt); 790 amq_mount_tree_p *mtp = amqproc_mnttree_1(&fs, clnt);
791 if (mtp) { 791 if (mtp) {
792 amq_mount_tree *mt = *mtp; 792 amq_mount_tree *mt = *mtp;
793 if (mt) { 793 if (mt) {
794 int mwid = 0, dwid = 0, twid = 0; 794 int mwid = 0, dwid = 0, twid = 0;
795 show_mt(mt, Calc, &mwid, &dwid, &twid); 795 show_mt(mt, Calc, &mwid, &dwid, &twid);
796 mwid++; 796 mwid++;
797 dwid++, twid++; 797 dwid++, twid++;
798 printf("%-*.*s Uid Getattr Lookup RdDir RdLnk Statfs Mounted@\n", 798 printf("%-*.*s Uid Getattr Lookup RdDir RdLnk Statfs Mounted@\n",
799 dwid, dwid, "What"); 799 dwid, dwid, "What");
800 show_mt(mt, Stats, &mwid, &dwid, &twid); 800 show_mt(mt, Stats, &mwid, &dwid, &twid);
801 } else { 801 } else {
802 fprintf(stderr, "%s: %s not automounted\n", am_get_progname(), fs); 802 fprintf(stderr, "%s: %s not automounted\n", am_get_progname(), fs);
803 } 803 }
804 xdr_pri_free((XDRPROC_T_TYPE) xdr_amq_mount_tree_p, (caddr_t) mtp); 804 xdr_pri_free((XDRPROC_T_TYPE) xdr_amq_mount_tree_p, (caddr_t) mtp);
805 } else { 805 } else {
806 errs = clnt_failed(clnt, server); 806 errs = clnt_failed(clnt, server);
807 } 807 }
808 } 808 }
809 } while (optind < argc); 809 } while (optind < argc);
810 810
811 } else if (unmount_flag) { 811 } else if (unmount_flag) {
812 goto show_usage; 812 goto show_usage;
813 813
814 } else if (stats_flag) { 814 } else if (stats_flag) {
815 amq_mount_stats *ms = amqproc_stats_1((voidp) 0, clnt); 815 amq_mount_stats *ms = amqproc_stats_1((voidp) 0, clnt);
816 if (ms) { 816 if (ms) {
817 show_ms(ms); 817 show_ms(ms);
818 } else { 818 } else {
819 errs = clnt_failed(clnt, server); 819 errs = clnt_failed(clnt, server);
820 } 820 }
821 821
822 } else if (!nodefault) { 822 } else if (!nodefault) {
823 amq_mount_tree_list *mlp = amqproc_export_1((voidp) 0, clnt); 823 amq_mount_tree_list *mlp = amqproc_export_1((voidp) 0, clnt);
824 if (mlp) { 824 if (mlp) {
825 enum show_opt e = Calc; 825 enum show_opt e = Calc;
826 int mwid = 0, dwid = 0, pwid = 0; 826 int mwid = 0, dwid = 0, pwid = 0;
827 827
828 while (e != ShowDone) { 828 while (e != ShowDone) {
829 u_int i; 829 u_int i;
830 for (i = 0; i < mlp->amq_mount_tree_list_len; i++) { 830 for (i = 0; i < mlp->amq_mount_tree_list_len; i++) {
831 show_mt(mlp->amq_mount_tree_list_val[i], 831 show_mt(mlp->amq_mount_tree_list_val[i],
832 e, &mwid, &dwid, &pwid); 832 e, &mwid, &dwid, &pwid);
833 } 833 }
834 mwid++; 834 mwid++;
835 dwid++, pwid++; 835 dwid++, pwid++;
836 if (e == Calc) 836 if (e == Calc)
837 e = Short; 837 e = Short;
838 else if (e == Short) 838 else if (e == Short)
839 e = ShowDone; 839 e = ShowDone;
840 } 840 }
841 841
842 } else { 842 } else {
843 errs = clnt_failed(clnt, server); 843 errs = clnt_failed(clnt, server);
844 } 844 }
845 } 845 }
846 exit(errs); 846 exit(errs);
847 return errs; /* should never reach here */ 847 return errs; /* should never reach here */
848} 848}

cvs diff -r1.1.1.3 -r1.1.1.3.8.1 src/external/bsd/am-utils/dist/amq/amq_xdr.c (switch to unified diff)

--- src/external/bsd/am-utils/dist/amq/amq_xdr.c 2015/01/17 16:34:15 1.1.1.3
+++ src/external/bsd/am-utils/dist/amq/amq_xdr.c 2024/04/18 16:02:26 1.1.1.3.8.1
@@ -1,318 +1,318 @@ @@ -1,318 +1,318 @@
1/* $NetBSD: amq_xdr.c,v 1.1.1.3 2015/01/17 16:34:15 christos Exp $ */ 1/* $NetBSD: amq_xdr.c,v 1.1.1.3.8.1 2024/04/18 16:02:26 martin 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/amq/amq_xdr.c 38 * File: am-utils/amq/amq_xdr.c
39 * 39 *
40 */ 40 */
41 41
42#ifdef HAVE_CONFIG_H 42#ifdef HAVE_CONFIG_H
43# include <config.h> 43# include <config.h>
44#endif /* HAVE_CONFIG_H */ 44#endif /* HAVE_CONFIG_H */
45#include <am_defs.h> 45#include <am_defs.h>
46#include <amq.h> 46#include <amq.h>
47 47
48 48
49bool_t 49bool_t
50xdr_time_type(XDR *xdrs, time_type *objp) 50xdr_time_type(XDR *xdrs, time_type *objp)
51{ 51{
52 if (!xdr_long(xdrs, (long *) objp)) { 52 if (!xdr_longlong_t(xdrs, (longlong_t *) objp)) {
53 return (FALSE); 53 return (FALSE);
54 } 54 }
55 return (TRUE); 55 return (TRUE);
56} 56}
57 57
58 58
59bool_t 59bool_t
60xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp) 60xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp)
61{ 61{
62 62
63 if (!xdr_amq_string(xdrs, &objp->mt_mountinfo)) { 63 if (!xdr_amq_string(xdrs, &objp->mt_mountinfo)) {
64 return (FALSE); 64 return (FALSE);
65 } 65 }
66 66
67 if (!xdr_amq_string(xdrs, &objp->mt_directory)) { 67 if (!xdr_amq_string(xdrs, &objp->mt_directory)) {
68 return (FALSE); 68 return (FALSE);
69 } 69 }
70 70
71 if (!xdr_amq_string(xdrs, &objp->mt_mountpoint)) { 71 if (!xdr_amq_string(xdrs, &objp->mt_mountpoint)) {
72 return (FALSE); 72 return (FALSE);
73 } 73 }
74 74
75 if (!xdr_amq_string(xdrs, &objp->mt_type)) { 75 if (!xdr_amq_string(xdrs, &objp->mt_type)) {
76 return (FALSE); 76 return (FALSE);
77 } 77 }
78 78
79 if (!xdr_time_type(xdrs, &objp->mt_mounttime)) { 79 if (!xdr_time_type(xdrs, &objp->mt_mounttime)) {
80 return (FALSE); 80 return (FALSE);
81 } 81 }
82 82
83 if (!xdr_u_short(xdrs, &objp->mt_mountuid)) { 83 if (!xdr_u_short(xdrs, &objp->mt_mountuid)) {
84 return (FALSE); 84 return (FALSE);
85 } 85 }
86 86
87 if (!xdr_int(xdrs, &objp->mt_getattr)) { 87 if (!xdr_int(xdrs, &objp->mt_getattr)) {
88 return (FALSE); 88 return (FALSE);
89 } 89 }
90 90
91 if (!xdr_int(xdrs, &objp->mt_lookup)) { 91 if (!xdr_int(xdrs, &objp->mt_lookup)) {
92 return (FALSE); 92 return (FALSE);
93 } 93 }
94 94
95 if (!xdr_int(xdrs, &objp->mt_readdir)) { 95 if (!xdr_int(xdrs, &objp->mt_readdir)) {
96 return (FALSE); 96 return (FALSE);
97 } 97 }
98 98
99 if (!xdr_int(xdrs, &objp->mt_readlink)) { 99 if (!xdr_int(xdrs, &objp->mt_readlink)) {
100 return (FALSE); 100 return (FALSE);
101 } 101 }
102 102
103 if (!xdr_int(xdrs, &objp->mt_statfs)) { 103 if (!xdr_int(xdrs, &objp->mt_statfs)) {
104 return (FALSE); 104 return (FALSE);
105 } 105 }
106 106
107 if (!xdr_pointer(xdrs, 107 if (!xdr_pointer(xdrs,
108 (char **) ((voidp) &objp->mt_next), 108 (char **) ((voidp) &objp->mt_next),
109 sizeof(amq_mount_tree), 109 sizeof(amq_mount_tree),
110 (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { 110 (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
111 return (FALSE); 111 return (FALSE);
112 } 112 }
113 113
114 if (!xdr_pointer(xdrs, 114 if (!xdr_pointer(xdrs,
115 (char **) ((voidp) &objp->mt_child), 115 (char **) ((voidp) &objp->mt_child),
116 sizeof(amq_mount_tree), 116 sizeof(amq_mount_tree),
117 (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { 117 (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
118 return (FALSE); 118 return (FALSE);
119 } 119 }
120 120
121 return (TRUE); 121 return (TRUE);
122} 122}
123 123
124 124
125bool_t 125bool_t
126xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp) 126xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp)
127{ 127{
128 if (!xdr_pointer(xdrs, 128 if (!xdr_pointer(xdrs,
129 (char **) objp, 129 (char **) objp,
130 sizeof(amq_mount_tree), 130 sizeof(amq_mount_tree),
131 (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { 131 (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
132 return (FALSE); 132 return (FALSE);
133 } 133 }
134 return (TRUE); 134 return (TRUE);
135} 135}
136 136
137 137
138bool_t 138bool_t
139xdr_amq_mount_info(XDR *xdrs, amq_mount_info *objp) 139xdr_amq_mount_info(XDR *xdrs, amq_mount_info *objp)
140{ 140{
141 141
142 if (!xdr_amq_string(xdrs, &objp->mi_type)) { 142 if (!xdr_amq_string(xdrs, &objp->mi_type)) {
143 return (FALSE); 143 return (FALSE);
144 } 144 }
145 145
146 if (!xdr_amq_string(xdrs, &objp->mi_mountpt)) { 146 if (!xdr_amq_string(xdrs, &objp->mi_mountpt)) {
147 return (FALSE); 147 return (FALSE);
148 } 148 }
149 149
150 if (!xdr_amq_string(xdrs, &objp->mi_mountinfo)) { 150 if (!xdr_amq_string(xdrs, &objp->mi_mountinfo)) {
151 return (FALSE); 151 return (FALSE);
152 } 152 }
153 153
154 if (!xdr_amq_string(xdrs, &objp->mi_fserver)) { 154 if (!xdr_amq_string(xdrs, &objp->mi_fserver)) {
155 return (FALSE); 155 return (FALSE);
156 } 156 }
157 157
158 if (!xdr_int(xdrs, &objp->mi_error)) { 158 if (!xdr_int(xdrs, &objp->mi_error)) {
159 return (FALSE); 159 return (FALSE);
160 } 160 }
161 161
162 if (!xdr_int(xdrs, &objp->mi_refc)) { 162 if (!xdr_int(xdrs, &objp->mi_refc)) {
163 return (FALSE); 163 return (FALSE);
164 } 164 }
165 165
166 if (!xdr_int(xdrs, &objp->mi_up)) { 166 if (!xdr_int(xdrs, &objp->mi_up)) {
167 return (FALSE); 167 return (FALSE);
168 } 168 }
169 169
170 return (TRUE); 170 return (TRUE);
171} 171}
172 172
173 173
174bool_t 174bool_t
175xdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp) 175xdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp)
176{ 176{
177 if (!xdr_array(xdrs, 177 if (!xdr_array(xdrs,
178 (char **) ((voidp) &objp->amq_mount_info_list_val), 178 (char **) ((voidp) &objp->amq_mount_info_list_val),
179 (u_int *) &objp->amq_mount_info_list_len, 179 (u_int *) &objp->amq_mount_info_list_len,
180 ~0, 180 ~0,
181 sizeof(amq_mount_info), 181 sizeof(amq_mount_info),
182 (XDRPROC_T_TYPE) xdr_amq_mount_info)) { 182 (XDRPROC_T_TYPE) xdr_amq_mount_info)) {
183 return (FALSE); 183 return (FALSE);
184 } 184 }
185 return (TRUE); 185 return (TRUE);
186} 186}
187 187
188bool_t 188bool_t
189xdr_amq_map_info(XDR *xdrs, amq_map_info *objp) 189xdr_amq_map_info(XDR *xdrs, amq_map_info *objp)
190{ 190{
191 if (!xdr_amq_string(xdrs, &objp->mi_name)) { 191 if (!xdr_amq_string(xdrs, &objp->mi_name)) {
192 return (FALSE); 192 return (FALSE);
193 } 193 }
194 194
195 if (!xdr_amq_string(xdrs, &objp->mi_wildcard)) { 195 if (!xdr_amq_string(xdrs, &objp->mi_wildcard)) {
196 return (FALSE); 196 return (FALSE);
197 } 197 }
198 198
199 if (!xdr_time_type(xdrs, &objp->mi_modify)) { 199 if (!xdr_time_type(xdrs, &objp->mi_modify)) {
200 return (FALSE); 200 return (FALSE);
201 } 201 }
202 202
203 if (!xdr_int(xdrs, &objp->mi_flags)) { 203 if (!xdr_int(xdrs, &objp->mi_flags)) {
204 return (FALSE); 204 return (FALSE);
205 } 205 }
206 206
207 if (!xdr_int(xdrs, &objp->mi_nentries)) { 207 if (!xdr_int(xdrs, &objp->mi_nentries)) {
208 return (FALSE); 208 return (FALSE);
209 } 209 }
210 210
211 if (!xdr_int(xdrs, &objp->mi_reloads)) { 211 if (!xdr_int(xdrs, &objp->mi_reloads)) {
212 return (FALSE); 212 return (FALSE);
213 } 213 }
214 214
215 if (!xdr_int(xdrs, &objp->mi_refc)) { 215 if (!xdr_int(xdrs, &objp->mi_refc)) {
216 return (FALSE); 216 return (FALSE);
217 } 217 }
218 218
219 if (!xdr_int(xdrs, &objp->mi_up)) { 219 if (!xdr_int(xdrs, &objp->mi_up)) {
220 return (FALSE); 220 return (FALSE);
221 } 221 }
222 222
223 return (TRUE); 223 return (TRUE);
224} 224}
225 225
226 226
227bool_t 227bool_t
228xdr_amq_map_info_list(XDR *xdrs, amq_map_info_list *objp) 228xdr_amq_map_info_list(XDR *xdrs, amq_map_info_list *objp)
229{ 229{
230 if (!xdr_array(xdrs, 230 if (!xdr_array(xdrs,
231 (char **) ((voidp) &objp->amq_map_info_list_val), 231 (char **) ((voidp) &objp->amq_map_info_list_val),
232 (u_int *) &objp->amq_map_info_list_len, 232 (u_int *) &objp->amq_map_info_list_len,
233 ~0, 233 ~0,
234 sizeof(amq_map_info), 234 sizeof(amq_map_info),
235 (XDRPROC_T_TYPE) xdr_amq_map_info)) { 235 (XDRPROC_T_TYPE) xdr_amq_map_info)) {
236 return (FALSE); 236 return (FALSE);
237 } 237 }
238 return (TRUE); 238 return (TRUE);
239} 239}
240 240
241 241
242bool_t 242bool_t
243xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp) 243xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp)
244{ 244{
245 if (!xdr_array(xdrs, 245 if (!xdr_array(xdrs,
246 (char **) ((voidp) &objp->amq_mount_tree_list_val), 246 (char **) ((voidp) &objp->amq_mount_tree_list_val),
247 (u_int *) &objp->amq_mount_tree_list_len, 247 (u_int *) &objp->amq_mount_tree_list_len,
248 ~0, 248 ~0,
249 sizeof(amq_mount_tree_p), 249 sizeof(amq_mount_tree_p),
250 (XDRPROC_T_TYPE) xdr_amq_mount_tree_p)) { 250 (XDRPROC_T_TYPE) xdr_amq_mount_tree_p)) {
251 return (FALSE); 251 return (FALSE);
252 } 252 }
253 return (TRUE); 253 return (TRUE);
254} 254}
255 255
256 256
257bool_t 257bool_t
258xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp) 258xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp)
259{ 259{
260 260
261 if (!xdr_int(xdrs, &objp->as_drops)) { 261 if (!xdr_int(xdrs, &objp->as_drops)) {
262 return (FALSE); 262 return (FALSE);
263 } 263 }
264 264
265 if (!xdr_int(xdrs, &objp->as_stale)) { 265 if (!xdr_int(xdrs, &objp->as_stale)) {
266 return (FALSE); 266 return (FALSE);
267 } 267 }
268 268
269 if (!xdr_int(xdrs, &objp->as_mok)) { 269 if (!xdr_int(xdrs, &objp->as_mok)) {
270 return (FALSE); 270 return (FALSE);
271 } 271 }
272 272
273 if (!xdr_int(xdrs, &objp->as_merr)) { 273 if (!xdr_int(xdrs, &objp->as_merr)) {
274 return (FALSE); 274 return (FALSE);
275 } 275 }
276 276
277 if (!xdr_int(xdrs, &objp->as_uerr)) { 277 if (!xdr_int(xdrs, &objp->as_uerr)) {
278 return (FALSE); 278 return (FALSE);
279 } 279 }
280 280
281 return (TRUE); 281 return (TRUE);
282} 282}
283 283
284 284
285bool_t 285bool_t
286xdr_amq_opt(XDR *xdrs, amq_opt *objp) 286xdr_amq_opt(XDR *xdrs, amq_opt *objp)
287{ 287{
288 if (!xdr_enum(xdrs, (enum_t *) objp)) { 288 if (!xdr_enum(xdrs, (enum_t *) objp)) {
289 return (FALSE); 289 return (FALSE);
290 } 290 }
291 return (TRUE); 291 return (TRUE);
292} 292}
293 293
294 294
295bool_t 295bool_t
296xdr_amq_setopt(XDR *xdrs, amq_setopt *objp) 296xdr_amq_setopt(XDR *xdrs, amq_setopt *objp)
297{ 297{
298 298
299 if (!xdr_amq_opt(xdrs, &objp->as_opt)) { 299 if (!xdr_amq_opt(xdrs, &objp->as_opt)) {
300 return (FALSE); 300 return (FALSE);
301 } 301 }
302 302
303 if (!xdr_amq_string(xdrs, &objp->as_str)) { 303 if (!xdr_amq_string(xdrs, &objp->as_str)) {
304 return (FALSE); 304 return (FALSE);
305 } 305 }
306 306
307 return (TRUE); 307 return (TRUE);
308} 308}
309 309
310 310
311bool_t 311bool_t
312xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr) 312xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr)
313{ 313{
314 XDR xdr; 314 XDR xdr;
315 315
316 xdr.x_op = XDR_FREE; 316 xdr.x_op = XDR_FREE;
317 return ((*xdr_args) (&xdr, (caddr_t *) args_ptr)); 317 return ((*xdr_args) (&xdr, (caddr_t *) args_ptr));
318} 318}

cvs diff -r1.1.1.3 -r1.1.1.3.8.1 src/external/bsd/am-utils/dist/include/amq_defs.h (switch to unified diff)

--- src/external/bsd/am-utils/dist/include/amq_defs.h 2015/01/17 16:34:18 1.1.1.3
+++ src/external/bsd/am-utils/dist/include/amq_defs.h 2024/04/18 16:02:26 1.1.1.3.8.1
@@ -1,193 +1,193 @@ @@ -1,193 +1,193 @@
1/* $NetBSD: amq_defs.h,v 1.1.1.3 2015/01/17 16:34:18 christos Exp $ */ 1/* $NetBSD: amq_defs.h,v 1.1.1.3.8.1 2024/04/18 16:02:26 martin 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/amq_defs.h 38 * File: am-utils/include/amq_defs.h
39 * 39 *
40 */ 40 */
41 41
42#ifndef _AMQ_DEFS_H 42#ifndef _AMQ_DEFS_H
43#define _AMQ_DEFS_H 43#define _AMQ_DEFS_H
44 44
45/* 45/*
46 * MACROS 46 * MACROS
47 */ 47 */
48#ifndef AMQ_SIZE 48#ifndef AMQ_SIZE
49# define AMQ_SIZE 16384 49# define AMQ_SIZE 16384
50#endif /* not AMQ_SIZE */ 50#endif /* not AMQ_SIZE */
51#define AMQ_STRLEN 16384 51#define AMQ_STRLEN 16384
52#define AMQ_PROGRAM ((u_long)300019) 52#define AMQ_PROGRAM ((u_long)300019)
53#define AMQ_VERSION ((u_long)1) 53#define AMQ_VERSION ((u_long)1)
54#define AMQPROC_NULL ((u_long)0) 54#define AMQPROC_NULL ((u_long)0)
55#define AMQPROC_MNTTREE ((u_long)1) 55#define AMQPROC_MNTTREE ((u_long)1)
56#define AMQPROC_UMNT ((u_long)2) /* asynchronous unmount */ 56#define AMQPROC_UMNT ((u_long)2) /* asynchronous unmount */
57#define AMQPROC_STATS ((u_long)3) 57#define AMQPROC_STATS ((u_long)3)
58#define AMQPROC_EXPORT ((u_long)4) 58#define AMQPROC_EXPORT ((u_long)4)
59#define AMQPROC_SETOPT ((u_long)5) 59#define AMQPROC_SETOPT ((u_long)5)
60#define AMQPROC_GETMNTFS ((u_long)6) 60#define AMQPROC_GETMNTFS ((u_long)6)
61#define AMQPROC_MOUNT ((u_long)7) 61#define AMQPROC_MOUNT ((u_long)7)
62#define AMQPROC_GETVERS ((u_long)8) 62#define AMQPROC_GETVERS ((u_long)8)
63#define AMQPROC_GETPID ((u_long)9) 63#define AMQPROC_GETPID ((u_long)9)
64#define AMQPROC_PAWD ((u_long)10) 64#define AMQPROC_PAWD ((u_long)10)
65#define AMQPROC_SYNC_UMNT ((u_long)11) /* synchronous unmount */ 65#define AMQPROC_SYNC_UMNT ((u_long)11) /* synchronous unmount */
66#define AMQPROC_GETMAPINFO ((u_long)12) 66#define AMQPROC_GETMAPINFO ((u_long)12)
67 67
68/* 68/*
69 * TYPEDEFS 69 * TYPEDEFS
70 */ 70 */
71typedef long *time_type; 71typedef long long time_type;
72typedef struct amq_mount_info amq_mount_info; 72typedef struct amq_mount_info amq_mount_info;
73typedef struct amq_map_info amq_map_info; 73typedef struct amq_map_info amq_map_info;
74typedef struct amq_mount_stats amq_mount_stats; 74typedef struct amq_mount_stats amq_mount_stats;
75typedef struct amq_mount_tree amq_mount_tree; 75typedef struct amq_mount_tree amq_mount_tree;
76typedef struct amq_setopt amq_setopt; 76typedef struct amq_setopt amq_setopt;
77typedef struct amq_sync_umnt amq_sync_umnt; 77typedef struct amq_sync_umnt amq_sync_umnt;
78typedef amq_mount_tree *amq_mount_tree_p; 78typedef amq_mount_tree *amq_mount_tree_p;
79 79
80/* 80/*
81 * STRUCTURES: 81 * STRUCTURES:
82 */ 82 */
83struct amq_mount_tree { 83struct amq_mount_tree {
84 amq_string mt_mountinfo; 84 amq_string mt_mountinfo;
85 amq_string mt_directory; 85 amq_string mt_directory;
86 amq_string mt_mountpoint; 86 amq_string mt_mountpoint;
87 amq_string mt_type; 87 amq_string mt_type;
88 time_type mt_mounttime; 88 time_type mt_mounttime;
89 u_short mt_mountuid; 89 u_short mt_mountuid;
90 int mt_getattr; 90 int mt_getattr;
91 int mt_lookup; 91 int mt_lookup;
92 int mt_readdir; 92 int mt_readdir;
93 int mt_readlink; 93 int mt_readlink;
94 int mt_statfs; 94 int mt_statfs;
95 struct amq_mount_tree *mt_next; 95 struct amq_mount_tree *mt_next;
96 struct amq_mount_tree *mt_child; 96 struct amq_mount_tree *mt_child;
97}; 97};
98 98
99struct amq_mount_info { 99struct amq_mount_info {
100 amq_string mi_type; 100 amq_string mi_type;
101 amq_string mi_mountpt; 101 amq_string mi_mountpt;
102 amq_string mi_mountinfo; 102 amq_string mi_mountinfo;
103 amq_string mi_fserver; 103 amq_string mi_fserver;
104 int mi_error; 104 int mi_error;
105 int mi_refc; 105 int mi_refc;
106 int mi_up; 106 int mi_up;
107}; 107};
108 108
109typedef struct { 109typedef struct {
110 u_int amq_mount_info_list_len; 110 u_int amq_mount_info_list_len;
111 amq_mount_info *amq_mount_info_list_val; 111 amq_mount_info *amq_mount_info_list_val;
112} amq_mount_info_list; 112} amq_mount_info_list;
113 113
114typedef struct { 114typedef struct {
115 u_int amq_mount_tree_list_len; 115 u_int amq_mount_tree_list_len;
116 amq_mount_tree_p *amq_mount_tree_list_val; 116 amq_mount_tree_p *amq_mount_tree_list_val;
117} amq_mount_tree_list; 117} amq_mount_tree_list;
118 118
119struct amq_map_info { 119struct amq_map_info {
120 amq_string mi_name; 120 amq_string mi_name;
121 amq_string mi_wildcard; 121 amq_string mi_wildcard;
122 time_type mi_modify; 122 time_type mi_modify;
123 int mi_flags; 123 int mi_flags;
124 int mi_refc; 124 int mi_refc;
125 int mi_up; 125 int mi_up;
126 int mi_reloads; 126 int mi_reloads;
127 int mi_nentries; 127 int mi_nentries;
128}; 128};
129 129
130typedef struct { 130typedef struct {
131 u_int amq_map_info_list_len; 131 u_int amq_map_info_list_len;
132 amq_map_info *amq_map_info_list_val; 132 amq_map_info *amq_map_info_list_val;
133} amq_map_info_list; 133} amq_map_info_list;
134 134
135struct amq_mount_stats { 135struct amq_mount_stats {
136 int as_drops; 136 int as_drops;
137 int as_stale; 137 int as_stale;
138 int as_mok; 138 int as_mok;
139 int as_merr; 139 int as_merr;
140 int as_uerr; 140 int as_uerr;
141}; 141};
142 142
143typedef enum { 143typedef enum {
144 AMQ_UMNT_OK = 0, /* must be zero! */ 144 AMQ_UMNT_OK = 0, /* must be zero! */
145 AMQ_UMNT_FAILED = 1, /* unmount failed */ 145 AMQ_UMNT_FAILED = 1, /* unmount failed */
146 AMQ_UMNT_FORK = 2, /* fork failed */ 146 AMQ_UMNT_FORK = 2, /* fork failed */
147 AMQ_UMNT_READ = 3, /* pipe read failed */ 147 AMQ_UMNT_READ = 3, /* pipe read failed */
148 AMQ_UMNT_SERVER = 4, /* server down */ 148 AMQ_UMNT_SERVER = 4, /* server down */
149 AMQ_UMNT_SIGNAL = 5 /* received signal */ 149 AMQ_UMNT_SIGNAL = 5 /* received signal */
150} au_etype; 150} au_etype;
151 151
152struct amq_sync_umnt { 152struct amq_sync_umnt {
153 au_etype au_etype; /* error type */ 153 au_etype au_etype; /* error type */
154 int au_errno; /* error number */ 154 int au_errno; /* error number */
155 int au_signal; /* signal received */ 155 int au_signal; /* signal received */
156}; 156};
157 157
158enum amq_opt { 158enum amq_opt {
159 AMOPT_DEBUG = 0, 159 AMOPT_DEBUG = 0,
160 AMOPT_LOGFILE = 1, 160 AMOPT_LOGFILE = 1,
161 AMOPT_XLOG = 2, 161 AMOPT_XLOG = 2,
162 AMOPT_FLUSHMAPC = 3 162 AMOPT_FLUSHMAPC = 3
163}; 163};
164typedef enum amq_opt amq_opt; /* enum typedefs should be after enum */ 164typedef enum amq_opt amq_opt; /* enum typedefs should be after enum */
165 165
166struct amq_setopt { 166struct amq_setopt {
167 amq_opt as_opt; 167 amq_opt as_opt;
168 amq_string as_str; 168 amq_string as_str;
169}; 169};
170 170
171/* 171/*
172 * EXTERNALS: 172 * EXTERNALS:
173 * 173 *
174 * external definitions for amqproc_*_1() have been moved off to private 174 * external definitions for amqproc_*_1() have been moved off to private
175 * headers in lib/amu.h, amd/amd.h, etc. They have to be private since the 175 * headers in lib/amu.h, amd/amd.h, etc. They have to be private since the
176 * same named functions appear in different places with different prototypes 176 * same named functions appear in different places with different prototypes
177 * an functionality. 177 * an functionality.
178 */ 178 */
179extern bool_t xdr_amq_mount_info(XDR *xdrs, amq_mount_info *objp); 179extern bool_t xdr_amq_mount_info(XDR *xdrs, amq_mount_info *objp);
180extern bool_t xdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp); 180extern bool_t xdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp);
181extern bool_t xdr_amq_map_info(XDR *xdrs, amq_map_info *objp); 181extern bool_t xdr_amq_map_info(XDR *xdrs, amq_map_info *objp);
182extern bool_t xdr_amq_map_info_list(XDR *xdrs, amq_map_info_list *objp); 182extern bool_t xdr_amq_map_info_list(XDR *xdrs, amq_map_info_list *objp);
183extern bool_t xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp); 183extern bool_t xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp);
184extern bool_t xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp); 184extern bool_t xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp);
185extern bool_t xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp); 185extern bool_t xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp);
186extern bool_t xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp); 186extern bool_t xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp);
187extern bool_t xdr_amq_opt(XDR *xdrs, amq_opt *objp); 187extern bool_t xdr_amq_opt(XDR *xdrs, amq_opt *objp);
188extern bool_t xdr_amq_setopt(XDR *xdrs, amq_setopt *objp); 188extern bool_t xdr_amq_setopt(XDR *xdrs, amq_setopt *objp);
189extern bool_t xdr_amq_sync_umnt(XDR *xdrs, amq_sync_umnt *objp); 189extern bool_t xdr_amq_sync_umnt(XDR *xdrs, amq_sync_umnt *objp);
190extern bool_t xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr); 190extern bool_t xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr);
191extern bool_t xdr_time_type(XDR *xdrs, time_type *objp); 191extern bool_t xdr_time_type(XDR *xdrs, time_type *objp);
192 192
193#endif /* not _AMQ_DEFS_H */ 193#endif /* not _AMQ_DEFS_H */