View | Details | Raw Unified | Return to bug 143732 | Differences between
and this patch

Collapse All | Expand All

(-)verify.c (-6 / +45 lines)
Lines 50-66 Link Here
50
static NODE *root;
50
static NODE *root;
51
static char path[MAXPATHLEN];
51
static char path[MAXPATHLEN];
52
52
53
static void	miss(NODE *, char *);
53
static int	miss(NODE *, char *);
54
static int	check(NODE *, char *);
54
static int	vwalk(void);
55
static int	vwalk(void);
55
56
56
int
57
int
57
mtree_verifyspec(FILE *fi)
58
mtree_verifyspec(FILE *fi)
58
{
59
{
59
	int rval;
60
	int rval = 0;
60
61
61
	root = mtree_readspec(fi);
62
	root = mtree_readspec(fi);
62
	rval = vwalk();
63
	/*
63
	miss(root, path);
64
	 * No need to walk entire tree if we are only updating the structure
65
	 * and extra files are ignored.
66
	 */
67
	if (!(uflag && eflag))
68
		rval = vwalk();
69
	rval |= miss(root, path);
64
	return (rval);
70
	return (rval);
65
}
71
}
66
72
Lines 155-169 Link Here
155
	return (rval);
161
	return (rval);
156
}
162
}
157
163
158
static void
164
static int
165
check(NODE *p, char *tail)
166
{
167
	FTSENT fts;
168
	struct stat fts_stat;
169
170
	strcpy(tail, p->name);
171
172
	/*
173
	 * It is assumed that compare() only requires fts_accpath and fts_statp
174
	 * fields in the FTSENT structure.
175
	 */
176
	fts.fts_accpath = path;
177
	fts.fts_statp = &fts_stat;
178
179
	if (stat(path, fts.fts_statp))
180
		return (0);
181
182
	p->flags |= F_VISIT;
183
	if ((p->flags & F_NOCHANGE) == 0 && compare(p->name, p, &fts))
184
		return (MISMATCHEXIT);
185
	else
186
		return (0);
187
188
	/*
189
	 * tail is not restored to '\0' as the next time tail (or path) is used
190
	 * is with a strcpy (thus overriding the '\0').  See +19 lines below.
191
	 */
192
}
193
194
static int
159
miss(NODE *p, char *tail)
195
miss(NODE *p, char *tail)
160
{
196
{
161
	int create;
197
	int create;
162
	char *tp;
198
	char *tp;
163
	const char *type, *what;
199
	const char *type, *what;
164
	int serr;
200
	int serr, rval = 0;
165
201
166
	for (; p; p = p->next) {
202
	for (; p; p = p->next) {
203
		if (uflag && eflag)
204
			rval |= check(p, tail);
167
		if (p->flags & F_OPT && !(p->flags & F_VISIT))
205
		if (p->flags & F_OPT && !(p->flags & F_VISIT))
168
			continue;
206
			continue;
169
		if (p->type != F_DIR && (dflag || p->flags & F_VISIT))
207
		if (p->type != F_DIR && (dflag || p->flags & F_VISIT))
Lines 256-259 Link Here
256
			(void)printf("%s: file flags not set: %s\n",
294
			(void)printf("%s: file flags not set: %s\n",
257
			    path, strerror(errno));
295
			    path, strerror(errno));
258
	}
296
	}
297
	return (rval);
259
}
298
}

Return to bug 143732