aboutsummaryrefslogtreecommitdiff
path: root/sbin/tunefs/tunefs.c
diff options
context:
space:
mode:
authorIan Dowse <iedowse@FreeBSD.org>2001-09-30 14:57:08 +0000
committerIan Dowse <iedowse@FreeBSD.org>2001-09-30 14:57:08 +0000
commit47f07d95baf5eb2a5a9e53f1614532cca566f79d (patch)
tree81e9cb5f41069016ffa31562baf8c6821759db50 /sbin/tunefs/tunefs.c
parent256ab0ef06f4ec187fffc14e12627297bfffa0b9 (diff)
downloadsrc-47f07d95baf5eb2a5a9e53f1614532cca566f79d.tar.gz
src-47f07d95baf5eb2a5a9e53f1614532cca566f79d.zip
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.
Notes
Notes: svn path=/head/; revision=84166
Diffstat (limited to 'sbin/tunefs/tunefs.c')
-rw-r--r--sbin/tunefs/tunefs.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c
index 80f08e0e7d17..7861fd36369d 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);
}