summaryrefslogtreecommitdiffstats
path: root/sbin/tunefs
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2003-01-28 02:42:01 +0000
committerjmallett <jmallett@FreeBSD.org>2003-01-28 02:42:01 +0000
commit502261f07fc3d5a527004cbbb5ea183ab6d68cf5 (patch)
treec4e4e5be7d354c35d85a2da6dbe88f43fc999313 /sbin/tunefs
parentbf8f717d04738d08f791d48f1801614116571d8d (diff)
downloadFreeBSD-src-502261f07fc3d5a527004cbbb5ea183ab6d68cf5.zip
FreeBSD-src-502261f07fc3d5a527004cbbb5ea183ab6d68cf5.tar.gz
Fix problems with how libufs was used, with regard to mounted/active fs's,
in the new world order of libufs, where we also do statfs, and add a missing close.
Diffstat (limited to 'sbin/tunefs')
-rw-r--r--sbin/tunefs/tunefs.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c
index 2c9228a..ec1589e 100644
--- a/sbin/tunefs/tunefs.c
+++ b/sbin/tunefs/tunefs.c
@@ -79,18 +79,15 @@ void printfs(void);
int
main(int argc, char *argv[])
{
- char *special;
+ const char *special, *on;
const char *name;
- struct stat st;
int Aflag = 0, active = 0, aflag = 0;
int eflag = 0, fflag = 0, lflag = 0, mflag = 0;
int nflag = 0, oflag = 0, pflag = 0, sflag = 0;
int evalue = 0, fvalue = 0;
int mvalue = 0, ovalue = 0, svalue = 0;
char *avalue = NULL, *lvalue = NULL, *nvalue = NULL;
- struct fstab *fs;
const char *chg[2];
- char device[MAXPATHLEN];
struct ufs_args args;
struct statfs stfs;
int found_arg, ch;
@@ -193,34 +190,14 @@ main(int argc, char *argv[])
if (found_arg == 0 || argc != 1)
usage();
- special = argv[0];
- fs = getfsfile(special);
- if (fs) {
+ on = special = argv[0];
+ if (ufs_disk_fillout(&disk, special) == -1)
+ goto err;
+ if (disk.d_name != special) {
+ special = disk.d_name;
if (statfs(special, &stfs) == 0 &&
- strcmp(special, stfs.f_mntonname) == 0) {
+ strcmp(special, stfs.f_mntonname) == 0)
active = 1;
- }
- special = fs->fs_spec;
- }
-again:
- if (stat(special, &st) < 0) {
- if (*special != '/') {
- if (*special == 'r')
- special++;
- (void)snprintf(device, sizeof(device), "%s%s",
- _PATH_DEV, special);
- special = device;
- goto again;
- }
- err(1, "%s", special);
- }
- if (fs == NULL && (st.st_mode & S_IFMT) == S_IFDIR)
- errx(10, "%s: unknown file system", special);
- if (ufs_disk_fillout(&disk, special) == -1) {
- if (disk.d_error != NULL)
- errx(11, "%s: %s", special, disk.d_error);
- else
- err(12, "%s", special);
}
if (pflag) {
@@ -356,15 +333,22 @@ again:
}
}
- sbwrite(&disk, Aflag);
+ if (sbwrite(&disk, Aflag) == -1)
+ goto err;
+ ufs_disk_close(&disk);
if (active) {
bzero(&args, sizeof(args));
- if (mount("ufs", fs->fs_file,
+ if (mount("ufs", on,
stfs.f_flags | MNT_UPDATE | MNT_RELOAD, &args) < 0)
err(9, "%s: reload", special);
warnx("file system reloaded");
}
exit(0);
+err:
+ if (disk.d_error != NULL)
+ errx(11, "%s: %s", special, disk.d_error);
+ else
+ err(12, "%s", special);
}
void
OpenPOWER on IntegriCloud