aboutsummaryrefslogtreecommitdiff
path: root/sbin/dump/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/dump/main.c')
-rw-r--r--sbin/dump/main.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 167812bce7d5..127b5ca33f97 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -59,6 +59,7 @@ static const char rcsid[] =
#include <errno.h>
#include <fcntl.h>
#include <fstab.h>
+#include <libufs.h>
#include <limits.h>
#include <signal.h>
#include <stdint.h>
@@ -84,11 +85,6 @@ long dev_bsize = 1; /* recalculated below */
long blocksperfile; /* output blocks per file */
char *host = NULL; /* remote host (if any) */
-/*
- * Possible superblock locations ordered from most to least likely.
- */
-static int sblock_try[] = SBLOCKSEARCH;
-
static char *getmntpt(char *, int *);
static long numarg(const char *, long, long);
static void obsolete(int *, char **[]);
@@ -104,7 +100,7 @@ main(int argc, char *argv[])
struct fstab *dt;
char *map, *mntpt;
int ch, mode, mntflags;
- int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
+ int i, ret, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
int just_estimate = 0;
ino_t maxino;
char *tmsg;
@@ -437,19 +433,16 @@ main(int argc, char *argv[])
msgtail("to %s\n", tape);
sync();
- sblock = (struct fs *)sblock_buf;
- for (i = 0; sblock_try[i] != -1; i++) {
- sblock->fs_fsize = SBLOCKSIZE; /* needed in blkread */
- blkread(sblock_try[i]>>dev_bshift, (char *) sblock, SBLOCKSIZE);
- if ((sblock->fs_magic == FS_UFS1_MAGIC ||
- (sblock->fs_magic == FS_UFS2_MAGIC &&
- sblock->fs_sblockloc == sblock_try[i])) &&
- sblock->fs_bsize <= MAXBSIZE &&
- sblock->fs_bsize >= sizeof(struct fs))
- break;
+ if ((ret = sbget(diskfd, &sblock, -1)) != 0) {
+ switch (ret) {
+ case ENOENT:
+ warn("Cannot find file system superblock");
+ return (1);
+ default:
+ warn("Unable to read file system superblock");
+ return (1);
+ }
}
- if (sblock_try[i] == -1)
- quit("Cannot find file system superblock\n");
dev_bsize = sblock->fs_fsize / fsbtodb(sblock, 1);
dev_bshift = ffs(dev_bsize) - 1;
if (dev_bsize != (1 << dev_bshift))