summaryrefslogtreecommitdiffstats
path: root/sbin/dump
diff options
context:
space:
mode:
authoriedowse <iedowse@FreeBSD.org>2001-11-16 22:13:44 +0000
committeriedowse <iedowse@FreeBSD.org>2001-11-16 22:13:44 +0000
commit46b1ffa3a1ebc2abe2a2488df702a68d8f15d6ae (patch)
treef5aa4730c8c33e933a46c435cc4c05b93a1a8df3 /sbin/dump
parent4e3498d275605c3150b9dfdcece37f1e362b21a6 (diff)
downloadFreeBSD-src-46b1ffa3a1ebc2abe2a2488df702a68d8f15d6ae.zip
FreeBSD-src-46b1ffa3a1ebc2abe2a2488df702a68d8f15d6ae.tar.gz
Give a sensible error message when the filesystem to be dumped is
not listed in /etc/fstab. Previously, the user would be greeted with "DUMP: bad sblock magic number" when dump tried to parse the directory contents as an FFS filesystem. PR: bin/12789 Submitted by: Bob Willcox <bob@pmr.com>
Diffstat (limited to 'sbin/dump')
-rw-r--r--sbin/dump/main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 0e3b3f6..eb9c232 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -97,6 +97,7 @@ main(argc, argv)
int argc;
char *argv[];
{
+ struct stat sb;
register ino_t ino;
register int dirty;
register struct dinode *dp;
@@ -336,10 +337,12 @@ main(argc, argv)
else
msgtail("to %s\n", tape);
- if ((diskfd = open(disk, O_RDONLY)) < 0) {
- msg("Cannot open %s\n", disk);
- exit(X_STARTUP);
- }
+ if ((diskfd = open(disk, O_RDONLY)) < 0)
+ err(X_STARTUP, "Cannot open %s", disk);
+ if (fstat(diskfd, &sb) != 0)
+ err(X_STARTUP, "%s: stat", disk);
+ if (S_ISDIR(sb.st_mode))
+ errx(X_STARTUP, "%s: unknown file system", disk);
sync();
sblock = (struct fs *)sblock_buf;
bread(SBOFF, (char *) sblock, SBSIZE);
OpenPOWER on IntegriCloud