|
|
This diff lets dumpfs(8) retry with raw device on failure.
For example, if you run "dumpfs /dev/wd0a" it will automatically
fallback to /dev/rwd0a if /dev/wd0a cannot be opened (busy, etc.).
Please let me know what you think.
Thanks,
Lawrence
Index: dumpfs.c
===================================================================
RCS file: /cvs/src/sbin/dumpfs/dumpfs.c,v
retrieving revision 1.25
diff -u -p -r1.25 dumpfs.c
--- dumpfs.c 8 Jun 2008 03:00:20 -0000 1.25
+++ dumpfs.c 13 Jul 2008 21:08:23 -0000
@@ -65,6 +65,7 @@ static const char rcsid[] = "$OpenBSD: d
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
union {
@@ -136,11 +137,19 @@ open_disk(const char *name)
{
int fd, i, sbtry[] = SBLOCKSEARCH;
ssize_t n;
+ char rawspec[MAXPATHLEN], *p;
- /* XXX - should retry w/raw device on failure */
+ /* Retry with raw device on failure. */
if ((fd = open(name, O_RDONLY, 0)) < 0) {
- warn("%s", name);
- return(-1);
+ if ((p = strrchr(name, '/')) != NULL)
+ snprintf(rawspec, sizeof(rawspec), "%.*s/r%s",
+ (int)(p - name), name, p + 1);
+ else
+ snprintf(rawspec, sizeof(rawspec), "r%s", name);
+ if ((fd = open(rawspec, O_RDONLY, 0)) < 0) {
+ warn("%s", rawspec);
+ return(-1);
+ }
}
/* Read superblock, could be UFS1 or UFS2. */
|
|