aboutsummaryrefslogtreecommitdiff
path: root/sbin/dump/main.c
diff options
context:
space:
mode:
authorIan Dowse <iedowse@FreeBSD.org>2001-11-16 22:13:44 +0000
committerIan Dowse <iedowse@FreeBSD.org>2001-11-16 22:13:44 +0000
commita50e99d1375020d28e8cd976041e0d7ceef123ff (patch)
treef5aa4730c8c33e933a46c435cc4c05b93a1a8df3 /sbin/dump/main.c
parent7b9716bad2dfb6a96487470ef002ead85c17a464 (diff)
downloadsrc-a50e99d1375020d28e8cd976041e0d7ceef123ff.tar.gz
src-a50e99d1375020d28e8cd976041e0d7ceef123ff.zip
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>
Notes
Notes: svn path=/head/; revision=86470
Diffstat (limited to 'sbin/dump/main.c')
-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 0e3b3f6f0e1a..eb9c232916b2 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);