| Summary: | Confusing error msg when dumping a filesystem by mount point thats not in /etc/fstab | ||
|---|---|---|---|
| Product: | Base System | Reporter: | bob <bob> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | Unspecified | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->closed Committed (with slight adjustments), thanks! This should have been fixed years ago. |
When dumping a filesystem by specifying its mount point (rather than its special file name) if there is no entry in fstab for the filesystem dump fails with what can be a misleading error message. For example if I dump /bsd (which has no fstab entry I get): bob@luke-pf /usr/src/sbin/dump> dump -0ab 32 -f /dev/null /bsd DUMP: Date of this level 0 dump: Sat Jul 24 13:21:19 1999 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /bsd to /dev/null DUMP: bad sblock magic number What has happened here is that dump, because it did not find an entry for /bsd in /etc/fstab has opened the directory /bsd and tried to dump it (and, of course, failed since it has no superblock). Fix: I have implemented a simple additional check to see that the open file (should be the filesystem) isn't a directory (as it will be in this case). If it is a directory, the changed code prints a warning message to assist the user in diagnosing what he has done wrong. The output from dump will now look like this: bob@luke-pf /usr/src/sbin/dump> /usr/obj/usr/src/sbin/dump/dump -0ab 32 -f /d > DUMP: Date of this level 0 dump: Sat Jul 24 13:47:39 1999 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /bsd to /dev/null DUMP: WARNING: /bsd will be processed as a directory, not a filesystem DUMP: bad sblock magic number DUMP: The ENTIRE dump is aborted. There are, no doubt, other and likely better ways to solve this problem but this worked for me (next time I won't spend so much time tracking down what's really wrong). Here is a patch for the change should you be interested: #include "dump.h" #include "pathnames.h" @@ -104,6 +105,7 @@ register int ch; int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1; ino_t maxino; + struct stat sb; spcl.c_date = 0; (void)time((time_t *)&spcl.c_date); @@ -327,6 +333,11 @@ msg("Cannot open %s\n", disk); exit(X_STARTUP); } + if (fstat(diskfd, &sb)) + quit("unable to fstat filesystem"); + if (S_ISDIR(sb.st_mode)) + msg("WARNING: %s will be processed as a directory, not a filesystem\n", + disk); sync(); sblock = (struct fs *)sblock_buf; bread(SBOFF, (char *) sblock, SBSIZE);--I4VUJ8bqnoj2LHxCkOKTozhyISjpAIYfoyuy279EhA8Easyy Content-Type: text/plain; name="file.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="file.diff" Index: src/sbin/dump/main.c =================================================================== RCS file: /usr/cvs/FreeBSD/src/sbin/dump/main.c,v retrieving revision 1.18 diff -u -r1.18 main.c --- main.c 1998/09/16 20:52:12 1.18 +++ main.c 1999/07/24 18:47:32 @@ -68,6 +68,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/stat.h> How-To-Repeat: Run dump against a mounted filesystem that has no entry in /etc/fstab and specifify its mount point rather than the special file path.