1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate * Copyright 1995-2003 Sun Microsystems, Inc. All rights reserved.
24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate /*
28*7c478bd9Sstevel@tonic-gate * module:
29*7c478bd9Sstevel@tonic-gate * debug.c
30*7c478bd9Sstevel@tonic-gate *
31*7c478bd9Sstevel@tonic-gate * purpose:
32*7c478bd9Sstevel@tonic-gate * utility routines for debugging filesync (tracing, diagnostics,
33*7c478bd9Sstevel@tonic-gate * and error simulation)
34*7c478bd9Sstevel@tonic-gate *
35*7c478bd9Sstevel@tonic-gate * contents:
36*7c478bd9Sstevel@tonic-gate * showflags display a word of flags symbolicly
37*7c478bd9Sstevel@tonic-gate * dbg_usage printout usage info for -D switch
38*7c478bd9Sstevel@tonic-gate * err_usage printout usage info for -E switch
39*7c478bd9Sstevel@tonic-gate * dbg_set_error enable an error simulation
40*7c478bd9Sstevel@tonic-gate * dbg_check_error check for error simulation
41*7c478bd9Sstevel@tonic-gate *
42*7c478bd9Sstevel@tonic-gate *
43*7c478bd9Sstevel@tonic-gate * note:
44*7c478bd9Sstevel@tonic-gate * there are numerous flag words and bit fields in this
45*7c478bd9Sstevel@tonic-gate * program, and it would be horrendous to just print them
46*7c478bd9Sstevel@tonic-gate * out in hex (in debugging output). These routines use
47*7c478bd9Sstevel@tonic-gate * a "flaglist" data structure to map between bits and
48*7c478bd9Sstevel@tonic-gate * character string names or descriptions.
49*7c478bd9Sstevel@tonic-gate *
50*7c478bd9Sstevel@tonic-gate * a flaglist is merely a list of paired bits and name strings.
51*7c478bd9Sstevel@tonic-gate */
52*7c478bd9Sstevel@tonic-gate
53*7c478bd9Sstevel@tonic-gate #include <stdio.h>
54*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
55*7c478bd9Sstevel@tonic-gate #include <string.h>
56*7c478bd9Sstevel@tonic-gate #include <ctype.h>
57*7c478bd9Sstevel@tonic-gate #include <errno.h>
58*7c478bd9Sstevel@tonic-gate
59*7c478bd9Sstevel@tonic-gate #include "filesync.h"
60*7c478bd9Sstevel@tonic-gate #include "database.h"
61*7c478bd9Sstevel@tonic-gate #include "debug.h"
62*7c478bd9Sstevel@tonic-gate
63*7c478bd9Sstevel@tonic-gate
64*7c478bd9Sstevel@tonic-gate /* bits in opt_debug for usage message */
65*7c478bd9Sstevel@tonic-gate static struct flaglist dbgflags[] =
66*7c478bd9Sstevel@tonic-gate { DBG_BASE, "BASE: base include building",
67*7c478bd9Sstevel@tonic-gate DBG_RULE, "RULE: rule tree building",
68*7c478bd9Sstevel@tonic-gate DBG_STAT, "STAT: file stats",
69*7c478bd9Sstevel@tonic-gate DBG_ANAL, "ANAL: difference analysis",
70*7c478bd9Sstevel@tonic-gate DBG_RECON, "RECO: reconciliation list processing",
71*7c478bd9Sstevel@tonic-gate DBG_VARS, "VARS: qualification and expansion",
72*7c478bd9Sstevel@tonic-gate DBG_FILES, "FILE: rule and baseline files",
73*7c478bd9Sstevel@tonic-gate DBG_LIST, "LIST: tree building",
74*7c478bd9Sstevel@tonic-gate DBG_EVAL, "EVAL: tree walking",
75*7c478bd9Sstevel@tonic-gate DBG_IGNORE, "IGNO: ignore list",
76*7c478bd9Sstevel@tonic-gate DBG_MISC, "MISC: everything else",
77*7c478bd9Sstevel@tonic-gate 0, 0
78*7c478bd9Sstevel@tonic-gate };
79*7c478bd9Sstevel@tonic-gate
80*7c478bd9Sstevel@tonic-gate /* bits in opt_debug for dsiplay */
81*7c478bd9Sstevel@tonic-gate struct flaglist dbgmap[] =
82*7c478bd9Sstevel@tonic-gate { DBG_BASE, "BASE",
83*7c478bd9Sstevel@tonic-gate DBG_RULE, "RULE",
84*7c478bd9Sstevel@tonic-gate DBG_STAT, "STAT",
85*7c478bd9Sstevel@tonic-gate DBG_ANAL, "ANAL",
86*7c478bd9Sstevel@tonic-gate DBG_RECON, "RECO",
87*7c478bd9Sstevel@tonic-gate DBG_VARS, "VARS",
88*7c478bd9Sstevel@tonic-gate DBG_FILES, "FILE",
89*7c478bd9Sstevel@tonic-gate DBG_LIST, "LIST",
90*7c478bd9Sstevel@tonic-gate DBG_EVAL, "EVAL",
91*7c478bd9Sstevel@tonic-gate DBG_IGNORE, "IGNO",
92*7c478bd9Sstevel@tonic-gate DBG_MISC, "MISC",
93*7c478bd9Sstevel@tonic-gate 0, 0
94*7c478bd9Sstevel@tonic-gate };
95*7c478bd9Sstevel@tonic-gate
96*7c478bd9Sstevel@tonic-gate /* bits in the rules flag field */
97*7c478bd9Sstevel@tonic-gate struct flaglist rflags[] =
98*7c478bd9Sstevel@tonic-gate { R_IGNORE, "IGNORE",
99*7c478bd9Sstevel@tonic-gate R_PROGRAM, "PROGRAM",
100*7c478bd9Sstevel@tonic-gate R_WILD, "WILD",
101*7c478bd9Sstevel@tonic-gate R_NEW, "NEW",
102*7c478bd9Sstevel@tonic-gate R_BOGUS, "BOGUS",
103*7c478bd9Sstevel@tonic-gate R_RESTRICT, "RESTRICT",
104*7c478bd9Sstevel@tonic-gate 0, 0
105*7c478bd9Sstevel@tonic-gate };
106*7c478bd9Sstevel@tonic-gate
107*7c478bd9Sstevel@tonic-gate /* bits in the files flag field */
108*7c478bd9Sstevel@tonic-gate struct flaglist fileflags[] =
109*7c478bd9Sstevel@tonic-gate { F_NEW, "new",
110*7c478bd9Sstevel@tonic-gate F_IN_BASELINE, "base",
111*7c478bd9Sstevel@tonic-gate F_IN_SOURCE, "srce",
112*7c478bd9Sstevel@tonic-gate F_IN_DEST, "dest",
113*7c478bd9Sstevel@tonic-gate F_EVALUATE, "eval",
114*7c478bd9Sstevel@tonic-gate F_SPARSE, "sparse",
115*7c478bd9Sstevel@tonic-gate F_REMOVE, "remove",
116*7c478bd9Sstevel@tonic-gate F_CONFLICT, "conflict",
117*7c478bd9Sstevel@tonic-gate F_LISTED, "listed",
118*7c478bd9Sstevel@tonic-gate F_STAT_ERROR, "statfail",
119*7c478bd9Sstevel@tonic-gate 0, 0
120*7c478bd9Sstevel@tonic-gate };
121*7c478bd9Sstevel@tonic-gate
122*7c478bd9Sstevel@tonic-gate /* bits in the file src/dst difference mask */
123*7c478bd9Sstevel@tonic-gate struct flaglist diffmap[] = {
124*7c478bd9Sstevel@tonic-gate D_CREATE, "create",
125*7c478bd9Sstevel@tonic-gate D_DELETE, "delete",
126*7c478bd9Sstevel@tonic-gate D_MTIME, "modtime",
127*7c478bd9Sstevel@tonic-gate D_SIZE, "size",
128*7c478bd9Sstevel@tonic-gate D_UID, "uid",
129*7c478bd9Sstevel@tonic-gate D_GID, "gid",
130*7c478bd9Sstevel@tonic-gate D_PROT, "modes",
131*7c478bd9Sstevel@tonic-gate D_LINKS, "links",
132*7c478bd9Sstevel@tonic-gate D_TYPE, "type",
133*7c478bd9Sstevel@tonic-gate D_FACLS, "facls",
134*7c478bd9Sstevel@tonic-gate D_RENAME_TO, "rename2",
135*7c478bd9Sstevel@tonic-gate D_RENAME_FROM, "renamed",
136*7c478bd9Sstevel@tonic-gate 0, 0
137*7c478bd9Sstevel@tonic-gate };
138*7c478bd9Sstevel@tonic-gate
139*7c478bd9Sstevel@tonic-gate /* bits in the exit error code mask */
140*7c478bd9Sstevel@tonic-gate struct flaglist errmap[] = {
141*7c478bd9Sstevel@tonic-gate ERR_RESOLVABLE, "resolvable",
142*7c478bd9Sstevel@tonic-gate ERR_UNRESOLVED, "unresolvable",
143*7c478bd9Sstevel@tonic-gate ERR_MISSING, "missing files",
144*7c478bd9Sstevel@tonic-gate ERR_PERM, "permissions",
145*7c478bd9Sstevel@tonic-gate ERR_FILES, "rule/base errors",
146*7c478bd9Sstevel@tonic-gate ERR_INVAL, "invalid arguments",
147*7c478bd9Sstevel@tonic-gate ERR_NOBASE, "bad base dir",
148*7c478bd9Sstevel@tonic-gate ERR_OTHER, "other",
149*7c478bd9Sstevel@tonic-gate 0, 0
150*7c478bd9Sstevel@tonic-gate };
151*7c478bd9Sstevel@tonic-gate
152*7c478bd9Sstevel@tonic-gate /*
153*7c478bd9Sstevel@tonic-gate * routine:
154*7c478bd9Sstevel@tonic-gate * showflags
155*7c478bd9Sstevel@tonic-gate *
156*7c478bd9Sstevel@tonic-gate * purpose:
157*7c478bd9Sstevel@tonic-gate * format flags for printing
158*7c478bd9Sstevel@tonic-gate *
159*7c478bd9Sstevel@tonic-gate * parameters:
160*7c478bd9Sstevel@tonic-gate * pointer to map
161*7c478bd9Sstevel@tonic-gate * mask to be interpreted \
162*7c478bd9Sstevel@tonic-gate *
163*7c478bd9Sstevel@tonic-gate * returns:
164*7c478bd9Sstevel@tonic-gate * pointer to a static buffer
165*7c478bd9Sstevel@tonic-gate */
166*7c478bd9Sstevel@tonic-gate char *
showflags(struct flaglist * map,long mask)167*7c478bd9Sstevel@tonic-gate showflags(struct flaglist *map, long mask)
168*7c478bd9Sstevel@tonic-gate { int i;
169*7c478bd9Sstevel@tonic-gate static char outbuf[MAX_NAME];
170*7c478bd9Sstevel@tonic-gate
171*7c478bd9Sstevel@tonic-gate outbuf[0] = 0;
172*7c478bd9Sstevel@tonic-gate for (i = 0; map[i].fl_mask; i++)
173*7c478bd9Sstevel@tonic-gate if (mask & map[i].fl_mask) {
174*7c478bd9Sstevel@tonic-gate if (outbuf[0])
175*7c478bd9Sstevel@tonic-gate strcat(outbuf, "|");
176*7c478bd9Sstevel@tonic-gate strcat(outbuf, map[i].fl_name);
177*7c478bd9Sstevel@tonic-gate }
178*7c478bd9Sstevel@tonic-gate
179*7c478bd9Sstevel@tonic-gate return (outbuf);
180*7c478bd9Sstevel@tonic-gate }
181*7c478bd9Sstevel@tonic-gate
182*7c478bd9Sstevel@tonic-gate /*
183*7c478bd9Sstevel@tonic-gate * routines:
184*7c478bd9Sstevel@tonic-gate * dbg_usage, err_usage
185*7c478bd9Sstevel@tonic-gate *
186*7c478bd9Sstevel@tonic-gate * purpose:
187*7c478bd9Sstevel@tonic-gate * to print out usage messages for the secret debugging flags
188*7c478bd9Sstevel@tonic-gate *
189*7c478bd9Sstevel@tonic-gate * returns:
190*7c478bd9Sstevel@tonic-gate * void
191*7c478bd9Sstevel@tonic-gate */
192*7c478bd9Sstevel@tonic-gate void
dbg_usage(void)193*7c478bd9Sstevel@tonic-gate dbg_usage(void)
194*7c478bd9Sstevel@tonic-gate { int i;
195*7c478bd9Sstevel@tonic-gate
196*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Usage:\tfilesync -Dmask ...\n");
197*7c478bd9Sstevel@tonic-gate for (i = 0; dbgflags[i].fl_mask; i++)
198*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\t0x%04lx .... %s\n",
199*7c478bd9Sstevel@tonic-gate dbgflags[i].fl_mask, dbgflags[i].fl_name);
200*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\n");
201*7c478bd9Sstevel@tonic-gate }
202*7c478bd9Sstevel@tonic-gate
203*7c478bd9Sstevel@tonic-gate #ifdef DBG_ERRORS
204*7c478bd9Sstevel@tonic-gate /*
205*7c478bd9Sstevel@tonic-gate * The -E flag is a debugging feature that enables the user to request
206*7c478bd9Sstevel@tonic-gate * the simulation of difficult to trigger error conditions in order
207*7c478bd9Sstevel@tonic-gate * to test out the error handling code in filesync. We maintain a
208*7c478bd9Sstevel@tonic-gate * registry that specifies a file name and an operation, and an errno
209*7c478bd9Sstevel@tonic-gate * to be returned if the specified operation is attempted on the
210*7c478bd9Sstevel@tonic-gate * specified file.
211*7c478bd9Sstevel@tonic-gate */
212*7c478bd9Sstevel@tonic-gate void
err_usage(void)213*7c478bd9Sstevel@tonic-gate err_usage(void)
214*7c478bd9Sstevel@tonic-gate {
215*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Usage:\tfilesync -E<errno>,<code>,<filename>\n");
216*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\ts ... eval stat source\n");
217*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tS ... eval stat destination\n");
218*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tn ... eval nftw source\n");
219*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tN ... eval nftw destination\n");
220*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tc ... reconcile copy create\n");
221*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\to ... reconcile copy open\n");
222*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tr ... reconcile copy read/readlink\n");
223*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tw ... reconcile copy write\n");
224*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tl ... reconcile link/symlink\n");
225*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tu ... reconcile unlink\n");
226*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\td ... reconcile mkdir/mknod\n");
227*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tD ... reconcile rmdir\n");
228*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tm ... reconcile rename\n");
229*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tR ... reconcile restat\n");
230*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tp ... reconcile protection (chmod)");
231*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\ta ... reconcile access control (setfacl)");
232*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tO ... reconcile ownership (chown)");
233*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\tZ ... out of space on target\n");
234*7c478bd9Sstevel@tonic-gate fprintf(stderr, "\n");
235*7c478bd9Sstevel@tonic-gate }
236*7c478bd9Sstevel@tonic-gate
237*7c478bd9Sstevel@tonic-gate /*
238*7c478bd9Sstevel@tonic-gate * this data structure us used to keep track of the error simulations
239*7c478bd9Sstevel@tonic-gate * that have been requested.
240*7c478bd9Sstevel@tonic-gate */
241*7c478bd9Sstevel@tonic-gate static struct errsim {
242*7c478bd9Sstevel@tonic-gate int Errno; /* error number to return */
243*7c478bd9Sstevel@tonic-gate char code; /* event triggering the error */
244*7c478bd9Sstevel@tonic-gate char *file; /* file name triggering error */
245*7c478bd9Sstevel@tonic-gate } errsim[ DBG_MAX_ERR ];
246*7c478bd9Sstevel@tonic-gate
247*7c478bd9Sstevel@tonic-gate static int num_errs; /* number of simulated errors */
248*7c478bd9Sstevel@tonic-gate
249*7c478bd9Sstevel@tonic-gate
250*7c478bd9Sstevel@tonic-gate /*
251*7c478bd9Sstevel@tonic-gate * routine:
252*7c478bd9Sstevel@tonic-gate * dbg_set_error
253*7c478bd9Sstevel@tonic-gate *
254*7c478bd9Sstevel@tonic-gate * purpose:
255*7c478bd9Sstevel@tonic-gate * note that we have been requested to simulate file access errors
256*7c478bd9Sstevel@tonic-gate *
257*7c478bd9Sstevel@tonic-gate * parameters:
258*7c478bd9Sstevel@tonic-gate * argument string <errno>,<errcode>,<filename>
259*7c478bd9Sstevel@tonic-gate *
260*7c478bd9Sstevel@tonic-gate * returns:
261*7c478bd9Sstevel@tonic-gate * error mask
262*7c478bd9Sstevel@tonic-gate */
263*7c478bd9Sstevel@tonic-gate int
dbg_set_error(char * arg)264*7c478bd9Sstevel@tonic-gate dbg_set_error(char *arg)
265*7c478bd9Sstevel@tonic-gate { char *s;
266*7c478bd9Sstevel@tonic-gate char error_type;
267*7c478bd9Sstevel@tonic-gate int error_no;
268*7c478bd9Sstevel@tonic-gate
269*7c478bd9Sstevel@tonic-gate if (num_errs >= DBG_MAX_ERR) {
270*7c478bd9Sstevel@tonic-gate fprintf(stderr, "ERROR: only %d -E specifications allowed\n",
271*7c478bd9Sstevel@tonic-gate DBG_MAX_ERR);
272*7c478bd9Sstevel@tonic-gate return (ERR_INVAL);
273*7c478bd9Sstevel@tonic-gate }
274*7c478bd9Sstevel@tonic-gate
275*7c478bd9Sstevel@tonic-gate /* get the error number */
276*7c478bd9Sstevel@tonic-gate if (!isdigit(arg[0]))
277*7c478bd9Sstevel@tonic-gate return (ERR_INVAL);
278*7c478bd9Sstevel@tonic-gate error_no = strtol(arg, &s, 0);
279*7c478bd9Sstevel@tonic-gate
280*7c478bd9Sstevel@tonic-gate /* get the error condition */
281*7c478bd9Sstevel@tonic-gate if (*s++ != ',' || !isalpha(*s))
282*7c478bd9Sstevel@tonic-gate return (ERR_INVAL);
283*7c478bd9Sstevel@tonic-gate error_type = *s;
284*7c478bd9Sstevel@tonic-gate
285*7c478bd9Sstevel@tonic-gate /* get the file name */
286*7c478bd9Sstevel@tonic-gate while (*s && *s != ',') s++;
287*7c478bd9Sstevel@tonic-gate if (*s++ != ',' || *s == 0)
288*7c478bd9Sstevel@tonic-gate return (ERR_INVAL);
289*7c478bd9Sstevel@tonic-gate
290*7c478bd9Sstevel@tonic-gate /* register the error simulation */
291*7c478bd9Sstevel@tonic-gate errsim[num_errs].Errno = error_no;
292*7c478bd9Sstevel@tonic-gate errsim[num_errs].code = error_type;
293*7c478bd9Sstevel@tonic-gate errsim[num_errs].file = s;
294*7c478bd9Sstevel@tonic-gate
295*7c478bd9Sstevel@tonic-gate if (opt_debug & DBG_MISC)
296*7c478bd9Sstevel@tonic-gate fprintf(stderr, "MISC: errsim[%d] %c(%s) -> %d\n",
297*7c478bd9Sstevel@tonic-gate num_errs, error_type, s, error_no);
298*7c478bd9Sstevel@tonic-gate
299*7c478bd9Sstevel@tonic-gate num_errs++;
300*7c478bd9Sstevel@tonic-gate
301*7c478bd9Sstevel@tonic-gate return (0);
302*7c478bd9Sstevel@tonic-gate }
303*7c478bd9Sstevel@tonic-gate
304*7c478bd9Sstevel@tonic-gate /*
305*7c478bd9Sstevel@tonic-gate * routine:
306*7c478bd9Sstevel@tonic-gate * dbg_chk_error
307*7c478bd9Sstevel@tonic-gate *
308*7c478bd9Sstevel@tonic-gate * purpose:
309*7c478bd9Sstevel@tonic-gate * determine whether or not we have been asked to simulate an
310*7c478bd9Sstevel@tonic-gate * error for a specified file.
311*7c478bd9Sstevel@tonic-gate *
312*7c478bd9Sstevel@tonic-gate * parameters:
313*7c478bd9Sstevel@tonic-gate * file name
314*7c478bd9Sstevel@tonic-gate *
315*7c478bd9Sstevel@tonic-gate * returns:
316*7c478bd9Sstevel@tonic-gate * errno (or zero if no error)
317*7c478bd9Sstevel@tonic-gate */
318*7c478bd9Sstevel@tonic-gate int
dbg_chk_error(const char * name,char code)319*7c478bd9Sstevel@tonic-gate dbg_chk_error(const char *name, char code)
320*7c478bd9Sstevel@tonic-gate { int i;
321*7c478bd9Sstevel@tonic-gate
322*7c478bd9Sstevel@tonic-gate for (i = 0; i < num_errs; i++) {
323*7c478bd9Sstevel@tonic-gate /* see if this code matches any registered condition */
324*7c478bd9Sstevel@tonic-gate if (code != errsim[i].code)
325*7c478bd9Sstevel@tonic-gate continue;
326*7c478bd9Sstevel@tonic-gate
327*7c478bd9Sstevel@tonic-gate /* see if this also matches the file name */
328*7c478bd9Sstevel@tonic-gate if (!suffix(name, errsim[i].file))
329*7c478bd9Sstevel@tonic-gate continue;
330*7c478bd9Sstevel@tonic-gate
331*7c478bd9Sstevel@tonic-gate /* we have a winner */
332*7c478bd9Sstevel@tonic-gate if (opt_debug & DBG_MISC)
333*7c478bd9Sstevel@tonic-gate fprintf(stderr, "MISC: trigger %d for file %c(%s)\n",
334*7c478bd9Sstevel@tonic-gate errsim[i].Errno, code, name);
335*7c478bd9Sstevel@tonic-gate return (errsim[i].Errno);
336*7c478bd9Sstevel@tonic-gate }
337*7c478bd9Sstevel@tonic-gate return (0);
338*7c478bd9Sstevel@tonic-gate }
339*7c478bd9Sstevel@tonic-gate
340*7c478bd9Sstevel@tonic-gate #else /* ! DBG_ERRORS */
341*7c478bd9Sstevel@tonic-gate void
err_usage(void)342*7c478bd9Sstevel@tonic-gate err_usage(void)
343*7c478bd9Sstevel@tonic-gate {
344*7c478bd9Sstevel@tonic-gate fprintf(stderr, "ERROR: this filesync does not support -E\n");
345*7c478bd9Sstevel@tonic-gate }
346*7c478bd9Sstevel@tonic-gate
347*7c478bd9Sstevel@tonic-gate int
dbg_set_error(char * arg)348*7c478bd9Sstevel@tonic-gate dbg_set_error(char *arg)
349*7c478bd9Sstevel@tonic-gate {
350*7c478bd9Sstevel@tonic-gate return (ERR_INVAL);
351*7c478bd9Sstevel@tonic-gate }
352*7c478bd9Sstevel@tonic-gate
353*7c478bd9Sstevel@tonic-gate int
dbg_chk_error(const char * name,char code)354*7c478bd9Sstevel@tonic-gate dbg_chk_error(const char *name, char code)
355*7c478bd9Sstevel@tonic-gate {
356*7c478bd9Sstevel@tonic-gate return (0);
357*7c478bd9Sstevel@tonic-gate }
358*7c478bd9Sstevel@tonic-gate #endif
359