diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2010-08-12 15:26:35 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2010-08-12 15:26:35 +0000 |
commit | 28df7a8f22deae9662a3826a934c7533f9078393 (patch) | |
tree | edc8ba4521c676be4869d68359d35369e4cc8848 | |
parent | 737100069063b214f67622fd5d165a4528d40623 (diff) |
Print the real device name followed by the disklabel UID in parenthesis
when fsck is run against a disklabel UID. This allows a user to determine
which device is really being scanned.
ok krw@
-rw-r--r-- | sbin/fsck/fsutil.c | 25 | ||||
-rw-r--r-- | sbin/fsck/fsutil.h | 4 | ||||
-rw-r--r-- | sbin/fsck_ext2fs/main.c | 4 | ||||
-rw-r--r-- | sbin/fsck_ffs/main.c | 4 | ||||
-rw-r--r-- | sbin/fsck_ffs/setup.c | 15 | ||||
-rw-r--r-- | sbin/fsck_msdos/main.c | 4 |
6 files changed, 36 insertions, 20 deletions
diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c index 5f25f9ecd03..48ef4555796 100644 --- a/sbin/fsck/fsutil.c +++ b/sbin/fsck/fsutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsutil.c,v 1.17 2009/10/27 23:59:32 deraadt Exp $ */ +/* $OpenBSD: fsutil.c,v 1.18 2010/08/12 15:26:34 jsing Exp $ */ /* $NetBSD: fsutil.c,v 1.2 1996/10/03 20:06:31 christos Exp $ */ /* @@ -45,6 +45,7 @@ #include "fsutil.h" static const char *dev = NULL; +static const char *origdev = NULL; static int hot = 0; static int preen = 0; @@ -53,9 +54,10 @@ extern char *__progname; static void vmsg(int, const char *, va_list); void -setcdevname(const char *cd, int pr) +setcdevname(const char *cd, const char *ocd, int pr) { dev = cd; + origdev = ocd; preen = pr; } @@ -86,16 +88,23 @@ errexit(const char *fmt, ...) static void vmsg(int fatal, const char *fmt, va_list ap) { - if (!fatal && preen) - (void) printf("%s: ", dev); + if (!fatal && preen) { + if (origdev) + printf("%s (%s): ", dev, origdev); + else + printf("%s: ", dev); + } (void) vprintf(fmt, ap); if (fatal && preen) { - (void) printf("\n"); - (void) printf( - "%s: UNEXPECTED INCONSISTENCY; RUN %s MANUALLY.\n", - dev, __progname); + printf("\n"); + if (origdev) + printf("%s (%s): ", dev, origdev); + else + printf("%s: ", dev); + printf("UNEXPECTED INCONSISTENCY; RUN %s MANUALLY.\n", + __progname); exit(8); } } diff --git a/sbin/fsck/fsutil.h b/sbin/fsck/fsutil.h index e7d9d28e421..6535bfa10ef 100644 --- a/sbin/fsck/fsutil.h +++ b/sbin/fsck/fsutil.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fsutil.h,v 1.5 2006/05/27 22:30:09 thib Exp $ */ +/* $OpenBSD: fsutil.h,v 1.6 2010/08/12 15:26:34 jsing Exp $ */ /* $NetBSD: fsutil.h,v 1.3 1996/10/03 20:06:31 christos Exp $ */ /* @@ -43,7 +43,7 @@ char *rawname(char *); char *unrawname(char *); char *blockcheck(char *); const char *cdevname(void); -void setcdevname(const char *, int); +void setcdevname(const char *, const char *, int); int hotroot(void); void *emalloc(size_t); void *erealloc(void *, size_t); diff --git a/sbin/fsck_ext2fs/main.c b/sbin/fsck_ext2fs/main.c index f72eff884a4..e12aa0c1d1b 100644 --- a/sbin/fsck_ext2fs/main.c +++ b/sbin/fsck_ext2fs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.16 2009/10/27 23:59:32 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.17 2010/08/12 15:26:34 jsing Exp $ */ /* $NetBSD: main.c,v 1.1 1997/06/11 11:21:50 bouyer Exp $ */ /* @@ -153,7 +153,7 @@ checkfilesys(char *filesys, char *mntpt, long auxdata, int child) if (preen && child) (void)signal(SIGQUIT, voidquit); - setcdevname(filesys, preen); + setcdevname(filesys, NULL, preen); if (debug && preen) pwarn("starting\n"); switch (setup(filesys)) { diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 74fecbd750f..b4817ce9626 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.35 2010/07/09 08:06:37 otto Exp $ */ +/* $OpenBSD: main.c,v 1.36 2010/08/12 15:26:34 jsing Exp $ */ /* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */ /* @@ -154,7 +154,7 @@ checkfilesys(char *filesys, char *mntpt, long auxdata, int child) if (preen && child) (void)signal(SIGQUIT, voidquit); - setcdevname(filesys, preen); + setcdevname(filesys, NULL, preen); if (debug && preen) pwarn("starting\n"); switch (setup(filesys)) { diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 896f394b1fd..590c3ea105a 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.45 2010/06/15 14:25:09 jsing Exp $ */ +/* $OpenBSD: setup.c,v 1.46 2010/08/12 15:26:34 jsing Exp $ */ /* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */ /* @@ -61,6 +61,7 @@ int calcsb(char *, int, struct fs *); static struct disklabel *getdisklabel(char *, int); static int readsb(int); static int cmpsb(struct fs *, struct fs *); +static char rdevname[MAXPATHLEN]; long numdirs, listmax, inplast; @@ -91,6 +92,11 @@ setup(char *dev) printf("Can't open %s: %s\n", dev, strerror(errno)); return (0); } + if (strncmp(dev, realdev, PATH_MAX) != 0) { + blockcheck(unrawname(realdev)); + strlcpy(rdevname, realdev, sizeof(rdevname)); + setcdevname(rdevname, dev, preen); + } if (fstat(fsreadfd, &statb) < 0) { printf("Can't stat %s: %s\n", realdev, strerror(errno)); close(fsreadfd); @@ -103,10 +109,11 @@ setup(char *dev) return (0); } } - if (strncmp(dev, realdev, PATH_MAX) != 0) - blockcheck(unrawname(realdev)); - if (preen == 0) + if (preen == 0) { printf("** %s", realdev); + if (strncmp(dev, realdev, PATH_MAX) != 0) + printf(" (%s)", dev); + } if (nflag || (fswritefd = opendev(dev, O_WRONLY, 0, NULL)) < 0) { fswritefd = -1; if (preen) diff --git a/sbin/fsck_msdos/main.c b/sbin/fsck_msdos/main.c index 75fe0f366bc..78faff06500 100644 --- a/sbin/fsck_msdos/main.c +++ b/sbin/fsck_msdos/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.16 2009/10/27 23:59:33 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.17 2010/08/12 15:26:34 jsing Exp $ */ /* $NetBSD: main.c,v 1.8 1996/10/17 20:29:53 cgd Exp $ */ /* @@ -97,7 +97,7 @@ main(int argc, char *argv[]) usage(); while (argc-- > 0) { - setcdevname(*argv, preen); + setcdevname(*argv, NULL, preen); erg = checkfilesys(*argv++); if (erg > ret) ret = erg; |