Deleted Added
sdiff udiff text old ( 241806 ) new ( 241807 )
full compact
1/* $NetBSD: fsck.c,v 1.30 2003/08/07 10:04:15 agc Exp $ */
2
3/*
4 * Copyright (c) 1996 Christos Zoulas. All rights reserved.
5 * Copyright (c) 1980, 1989, 1993, 1994
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 21 unchanged lines hidden (view full) ---

30 * SUCH DAMAGE.
31 *
32 * From: @(#)mount.c 8.19 (Berkeley) 4/19/94
33 * From: $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp
34 * $NetBSD: fsck.c,v 1.30 2003/08/07 10:04:15 agc Exp $
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sbin/fsck/fsck.c 241806 2012-10-21 12:01:11Z uqs $");
39
40#include <sys/param.h>
41#include <sys/mount.h>
42#include <sys/queue.h>
43#include <sys/wait.h>
44#define FSTYPENAMES
45#include <sys/disklabel.h>
46#include <sys/ioctl.h>

--- 21 unchanged lines hidden (view full) ---

68 char *options;
69 TAILQ_ENTRY(entry) entries;
70};
71
72static char *options = NULL;
73static int flags = 0;
74static int forceflag = 0;
75
76static int checkfs(const char *, const char *, const char *, char *, pid_t *);
77static int selected(const char *);
78static void addoption(char *);
79static const char *getoptions(const char *);
80static void addentry(struct fstypelist *, const char *, const char *);
81static void maketypelist(char *);
82static void catopt(char **, const char *);
83static void mangle(char *, int *, const char ***, int *);
84static const char *getfslab(const char *);
85static void usage(void) __dead2;
86static int isok(struct fstab *);
87
88int
89main(int argc, char *argv[])
90{
91 struct fstab *fs;

--- 90 unchanged lines hidden (view full) ---

182 strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
183
184
185 for (; argc--; argv++) {
186 const char *spec, *mntpt, *type, *cp;
187 char device[MAXPATHLEN];
188 struct statfs *mntp;
189
190 spec = *argv;
191 cp = strrchr(spec, '/');
192 if (cp == 0) {
193 (void)snprintf(device, sizeof(device), "%s%s",
194 _PATH_DEV, spec);
195 spec = device;
196 }
197 mntp = getmntpt(spec);

--- 82 unchanged lines hidden (view full) ---

280 return (1);
281 printf("%s: DEFER FOR BACKGROUND CHECKING\n", fs->fs_spec);
282 return (0);
283}
284
285
286static int
287checkfs(const char *pvfstype, const char *spec, const char *mntpt,
288 char *auxopt, pid_t *pidp)
289{
290 const char **argv;
291 pid_t pid;
292 int argc, i, status, maxargc;
293 char *optbuf, execbase[MAXPATHLEN];
294 char *vfstype = NULL;
295 const char *extra = NULL;
296
297#ifdef __GNUC__
298 /* Avoid vfork clobbering */

--- 8 unchanged lines hidden (view full) ---

307 * from the disklabel work for "4.2BSD" filesystems. It does a
308 * very limited subset of transliteration to a normalised form of
309 * filesystem name, and we do not seem to enforce a filesystem
310 * name character set.
311 */
312 vfstype = strdup(pvfstype);
313 if (vfstype == NULL)
314 perr("strdup(pvfstype)");
315 for (i = 0; i < strlen(vfstype); i++) {
316 vfstype[i] = tolower(vfstype[i]);
317 if (vfstype[i] == ' ')
318 vfstype[i] = '_';
319 }
320
321 extra = getoptions(vfstype);
322 optbuf = NULL;
323 if (options)

--- 32 unchanged lines hidden (view full) ---

356 free(vfstype);
357 return (1);
358
359 case 0: /* Child. */
360 if ((flags & CHECK_DEBUG) && auxopt == NULL)
361 _exit(0);
362
363 /* Go find an executable. */
364 execvP(execbase, _PATH_SYSPATH, (char * const *)argv);
365 if (spec)
366 warn("exec %s for %s in %s", execbase, spec, _PATH_SYSPATH);
367 else
368 warn("exec %s in %s", execbase, _PATH_SYSPATH);
369 _exit(1);
370 /* NOTREACHED */
371
372 default: /* Parent. */

--- 120 unchanged lines hidden (view full) ---

493 (void)snprintf(s + i, j, ",%s", o);
494 } else
495 s = estrdup(o);
496 *sp = s;
497}
498
499
500static void
501mangle(char *opts, int *argcp, const char ***argvp, int *maxargcp)
502{
503 char *p, *s;
504 int argc, maxargc;
505 const char **argv;
506
507 argc = *argcp;
508 argv = *argvp;
509 maxargc = *maxargcp;

--- 20 unchanged lines hidden (view full) ---

530 }
531
532 *argcp = argc;
533 *argvp = argv;
534 *maxargcp = maxargc;
535}
536
537
538const static char *
539getfslab(const char *str)
540{
541 struct disklabel dl;
542 int fd;
543 char p;
544 const char *vfstype;
545 u_char t;
546

--- 38 unchanged lines hidden ---