diff options
Diffstat (limited to 'sbin/fsck')
-rw-r--r-- | sbin/fsck/Makefile | 1 | ||||
-rw-r--r-- | sbin/fsck/fsck.c | 31 | ||||
-rw-r--r-- | sbin/fsck/fsutil.c | 33 | ||||
-rw-r--r-- | sbin/fsck/fsutil.h | 11 | ||||
-rw-r--r-- | sbin/fsck/preen.c | 16 |
5 files changed, 42 insertions, 50 deletions
diff --git a/sbin/fsck/Makefile b/sbin/fsck/Makefile index bc445fd..22de03c 100644 --- a/sbin/fsck/Makefile +++ b/sbin/fsck/Makefile @@ -3,7 +3,6 @@ PROG= fsck SRCS= fsck.c fsutil.c preen.c -WARNS?= 2 MAN= fsck.8 .include <bsd.prog.mk> diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c index 768e670..6bc702e 100644 --- a/sbin/fsck/fsck.c +++ b/sbin/fsck/fsck.c @@ -1,4 +1,4 @@ -/* $NetBSD: fsck.c,v 1.21 1999/04/22 04:20:53 abs Exp $ */ +/* $NetBSD: fsck.c,v 1.30 2003/08/07 10:04:15 agc Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -13,11 +13,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -35,7 +31,7 @@ * * From: @(#)mount.c 8.19 (Berkeley) 4/19/94 * From: $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp - * $NetBSD: fsck.c,v 1.21 1999/04/22 04:20:53 abs Exp $ + * $NetBSD: fsck.c,v 1.30 2003/08/07 10:04:15 agc Exp $ */ #include <sys/cdefs.h> @@ -77,14 +73,14 @@ static char *options = NULL; static int flags = 0; static int forceflag = 0; -static int checkfs(const char *, const char *, const char *, char *, pid_t *); +static int checkfs(const char *, const char *, const char *, const char *, pid_t *); static int selected(const char *); static void addoption(char *); static const char *getoptions(const char *); static void addentry(struct fstypelist *, const char *, const char *); static void maketypelist(char *); static void catopt(char **, const char *); -static void mangle(char *, int *, const char ***, int *); +static void mangle(char *, int *, const char ** volatile *, int *); static const char *getfslab(const char *); static void usage(void) __dead2; static int isok(struct fstab *); @@ -191,6 +187,7 @@ main(int argc, char *argv[]) char device[MAXPATHLEN]; struct statfs *mntp; + mntpt = NULL; spec = *argv; cp = strrchr(spec, '/'); if (cp == 0) { @@ -289,9 +286,9 @@ isok(struct fstab *fs) static int checkfs(const char *pvfstype, const char *spec, const char *mntpt, - char *auxopt, pid_t *pidp) + const char *auxopt, pid_t *pidp) { - const char **argv; + const char ** volatile argv; pid_t pid; int argc, i, status, maxargc; char *optbuf, execbase[MAXPATHLEN]; @@ -315,8 +312,8 @@ checkfs(const char *pvfstype, const char *spec, const char *mntpt, */ vfstype = strdup(pvfstype); if (vfstype == NULL) - perror("strdup(pvfstype)"); - for (i = 0; i < strlen(vfstype); i++) { + perr("strdup(pvfstype)"); + for (i = 0; i < (int)strlen(vfstype); i++) { vfstype[i] = tolower(vfstype[i]); if (vfstype[i] == ' ') vfstype[i] = '_'; @@ -365,7 +362,7 @@ checkfs(const char *pvfstype, const char *spec, const char *mntpt, _exit(0); /* Go find an executable. */ - execvP(execbase, _PATH_SYSPATH, (char * const *)argv); + execvP(execbase, _PATH_SYSPATH, __DECONST(char * const *, argv)); if (spec) warn("exec %s for %s in %s", execbase, spec, _PATH_SYSPATH); else @@ -502,7 +499,7 @@ catopt(char **sp, const char *o) static void -mangle(char *options, int *argcp, const char ***argvp, int *maxargcp) +mangle(char *opts, int *argcp, const char ** volatile *argvp, int *maxargcp) { char *p, *s; int argc, maxargc; @@ -512,7 +509,7 @@ mangle(char *options, int *argcp, const char ***argvp, int *maxargcp) argv = *argvp; maxargc = *maxargcp; - for (s = options; (p = strsep(&s, ",")) != NULL;) { + for (s = opts; (p = strsep(&s, ",")) != NULL;) { /* Always leave space for one more argument and the NULL. */ if (argc >= maxargc - 3) { maxargc <<= 1; @@ -539,7 +536,7 @@ mangle(char *options, int *argcp, const char ***argvp, int *maxargcp) } -const static char * +static const char * getfslab(const char *str) { struct disklabel dl; diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c index a4578bd..935992e 100644 --- a/sbin/fsck/fsutil.c +++ b/sbin/fsck/fsutil.c @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.c,v 1.7 1998/07/30 17:41:03 thorpej Exp $ */ +/* $NetBSD: fsutil.c,v 1.15 2006/06/05 16:52:05 christos Exp $ */ /* * Copyright (c) 1990, 1993 @@ -12,7 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fsutil.c,v 1.7 1998/07/30 17:41:03 thorpej Exp $"); +__RCSID("$NetBSD: fsutil.c,v 1.15 2006/06/05 16:52:05 christos Exp $"); #endif /* not lint */ __FBSDID("$FreeBSD$"); @@ -110,9 +110,13 @@ pwarn(const char *fmt, ...) } void -perror(const char *s) +perr(const char *fmt, ...) { - pfatal("%s (%s)", s, strerror(errno)); + va_list ap; + + va_start(ap, fmt); + vmsg(1, fmt, ap); + va_end(ap); } void @@ -132,18 +136,15 @@ devcheck(const char *origname) struct stat stslash, stchar; if (stat("/", &stslash) < 0) { - perror("/"); - printf("Can't stat root\n"); + perr("Can't stat `/'"); return (origname); } if (stat(origname, &stchar) < 0) { - perror(origname); - printf("Can't stat %s\n", origname); + perr("Can't stat %s\n", origname); return (origname); } if (!S_ISCHR(stchar.st_mode)) { - perror(origname); - printf("%s is not a char device\n", origname); + perr("%s is not a char device\n", origname); } return (origname); } @@ -156,7 +157,7 @@ getmntpt(const char *name) { struct stat devstat, mntdevstat; char device[sizeof(_PATH_DEV) - 1 + MNAMELEN]; - char *devname; + char *dev_name; struct statfs *mntbuf, *statfsp; int i, mntsize, isdev; @@ -169,10 +170,10 @@ getmntpt(const char *name) mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); for (i = 0; i < mntsize; i++) { statfsp = &mntbuf[i]; - devname = statfsp->f_mntfromname; - if (*devname != '/') { + dev_name = statfsp->f_mntfromname; + if (*dev_name != '/') { strcpy(device, _PATH_DEV); - strcat(device, devname); + strcat(device, dev_name); strcpy(statfsp->f_mntfromname, device); } if (isdev == 0) { @@ -180,7 +181,7 @@ getmntpt(const char *name) continue; return (statfsp); } - if (stat(devname, &mntdevstat) == 0 && + if (stat(dev_name, &mntdevstat) == 0 && mntdevstat.st_rdev == devstat.st_rdev) return (statfsp); } diff --git a/sbin/fsck/fsutil.h b/sbin/fsck/fsutil.h index 657668e..013b821 100644 --- a/sbin/fsck/fsutil.h +++ b/sbin/fsck/fsutil.h @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.h,v 1.4 1998/07/26 20:02:36 mycroft Exp $ */ +/* $NetBSD: fsutil.h,v 1.114 2009/10/21 01:07:46 snj Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -11,11 +11,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christos Zoulas. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -31,9 +26,9 @@ * $FreeBSD$ */ -void perror(const char *); void pfatal(const char *, ...) __printflike(1, 2); void pwarn(const char *, ...) __printflike(1, 2); +void perr(const char *, ...) __printflike(1, 2); void panic(const char *, ...) __dead2 __printflike(1, 2); const char *devcheck(const char *); const char *cdevname(void); @@ -52,4 +47,4 @@ char *estrdup(const char *); struct fstab; int checkfstab(int, int (*)(struct fstab *), - int (*) (const char *, const char *, const char *, char *, pid_t *)); + int (*) (const char *, const char *, const char *, const char *, pid_t *)); diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c index 787bed0..18f2801 100644 --- a/sbin/fsck/preen.c +++ b/sbin/fsck/preen.c @@ -78,12 +78,12 @@ static int nrun = 0, ndisks = 0; static struct diskentry *finddisk(const char *); static void addpart(const char *, const char *, const char *); static int startdisk(struct diskentry *, - int (*)(const char *, const char *, const char *, char *, pid_t *)); + int (*)(const char *, const char *, const char *, const char *, pid_t *)); static void printpart(void); int checkfstab(int flags, int (*docheck)(struct fstab *), - int (*checkit)(const char *, const char *, const char *, char *, pid_t *)) + int (*checkit)(const char *, const char *, const char *, const char *, pid_t *)) { struct fstab *fs; struct diskentry *d, *nextdisk; @@ -295,19 +295,19 @@ printpart(void) static void -addpart(const char *type, const char *devname, const char *mntpt) +addpart(const char *type, const char *dev, const char *mntpt) { - struct diskentry *d = finddisk(devname); + struct diskentry *d = finddisk(dev); struct partentry *p; TAILQ_FOREACH(p, &d->d_part, p_entries) - if (strcmp(p->p_devname, devname) == 0) { - warnx("%s in fstab more than once!\n", devname); + if (strcmp(p->p_devname, dev) == 0) { + warnx("%s in fstab more than once!\n", dev); return; } p = emalloc(sizeof(*p)); - p->p_devname = estrdup(devname); + p->p_devname = estrdup(dev); p->p_mntpt = estrdup(mntpt); p->p_type = estrdup(type); @@ -317,7 +317,7 @@ addpart(const char *type, const char *devname, const char *mntpt) static int startdisk(struct diskentry *d, int (*checkit)(const char *, const char *, - const char *, char *, pid_t *)) + const char *, const char *, pid_t *)) { struct partentry *p = TAILQ_FIRST(&d->d_part); int rv; |