diff options
author | iedowse <iedowse@FreeBSD.org> | 2001-09-30 14:57:08 +0000 |
---|---|---|
committer | iedowse <iedowse@FreeBSD.org> | 2001-09-30 14:57:08 +0000 |
commit | 71c1cedf5517c78c1753b5eed71fa0e582913980 (patch) | |
tree | 81e9cb5f41069016ffa31562baf8c6821759db50 /sbin/tunefs | |
parent | 9baef976499d8287837cc989fab55a308c2b8b60 (diff) | |
download | FreeBSD-src-71c1cedf5517c78c1753b5eed71fa0e582913980.zip FreeBSD-src-71c1cedf5517c78c1753b5eed71fa0e582913980.tar.gz |
Don't require that the special/filesystem argument translates into
a block or character device; the rest of tunefs works just fine on
filesystem images in regular files. Instead, if getfsfile() failed
and if the specified filesystem is a directory then print a more
useful "unknown file system" error.
Also, _PATH_DEV already contains a trailing slash, so don't add
another one when constructing a device path, and use errx() instead
of err() in a case where errno is meangingless.
Diffstat (limited to 'sbin/tunefs')
-rw-r--r-- | sbin/tunefs/tunefs.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c index 80f08e0e..7861fd3 100644 --- a/sbin/tunefs/tunefs.c +++ b/sbin/tunefs/tunefs.c @@ -210,16 +210,15 @@ again: if (*special != '/') { if (*special == 'r') special++; - (void)snprintf(device, sizeof(device), "%s/%s", + (void)snprintf(device, sizeof(device), "%s%s", _PATH_DEV, special); special = device; goto again; } err(1, "%s", special); } - if ((st.st_mode & S_IFMT) != S_IFBLK && - (st.st_mode & S_IFMT) != S_IFCHR) - errx(10, "%s: not a block or character device", special); + if (fs == NULL && (st.st_mode & S_IFMT) == S_IFDIR) + errx(10, "%s: unknown file system", special); getsb(&sblock, special); if (pflag) { @@ -370,7 +369,7 @@ getsb(fs, file) if (bread((daddr_t)SBOFF, (char *)fs, SBSIZE)) err(4, "%s: bad super block", file); if (fs->fs_magic != FS_MAGIC) - err(5, "%s: bad magic number", file); + errx(5, "%s: bad magic number", file); dev_bsize = fs->fs_fsize / fsbtodb(fs, 1); } |