summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2000-10-14 02:44:56 +0000
committeradrian <adrian@FreeBSD.org>2000-10-14 02:44:56 +0000
commitee143d47ad6c41a3590bdb5ed28c7bd5bf6ffff8 (patch)
tree590596b4f266eeab393a09a10ebc6e3d2dca44d9 /sbin
parent3de1cbc0796b0350b63069fc4bf7972a8e05d2ff (diff)
downloadFreeBSD-src-ee143d47ad6c41a3590bdb5ed28c7bd5bf6ffff8.zip
FreeBSD-src-ee143d47ad6c41a3590bdb5ed28c7bd5bf6ffff8.tar.gz
Pre-IFS commit. Commit IFS-aware fsck and mount utilities.
mount_ifs: repocopy of sbin/mount, with most of the intelligence ripped out and "ufs" replaced with "ifs" in the right places. It will only mount a single filesystem, rather than the -t <type> magic that our real mount does. fsck_ifs: repocopy of sbin/fsck_ffs, but the directory structure stuff (pass2 and some refcount checks) has been #ifdef'ed out. src/sbin/Makefile: Build these two utilities There is probably cruft code left in both which can be removed at a later date, especially in mount_ifs, but I trust that people will not try mount_ifs -a .. Note: there are no man pages installed for these two commands as I haven't actually written them yet.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/Makefile2
-rw-r--r--sbin/fsck_ifs/Makefile6
-rw-r--r--sbin/fsck_ifs/main.c7
-rw-r--r--sbin/fsck_ifs/pass4.c5
-rw-r--r--sbin/fsck_ifs/setup.c2
-rw-r--r--sbin/mount_ifs/Makefile6
-rw-r--r--sbin/mount_ifs/extern.h6
-rw-r--r--sbin/mount_ifs/mount.c185
-rw-r--r--sbin/mount_ifs/mount_ufs.c24
-rw-r--r--sbin/mount_ifs/vfslist.c96
10 files changed, 37 insertions, 302 deletions
diff --git a/sbin/Makefile b/sbin/Makefile
index 56e6c6a..6cb4d8f 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -17,6 +17,7 @@ SUBDIR= adjkerntz \
dumpfs \
dumpon \
fsck \
+ fsck_ifs \
fsck_ffs \
fsdb \
fsirand \
@@ -37,6 +38,7 @@ SUBDIR= adjkerntz \
mount \
mount_cd9660 \
mount_ext2fs \
+ mount_ifs \
mount_msdos \
mount_nfs \
mount_ntfs \
diff --git a/sbin/fsck_ifs/Makefile b/sbin/fsck_ifs/Makefile
index e1c106f..234b54d 100644
--- a/sbin/fsck_ifs/Makefile
+++ b/sbin/fsck_ifs/Makefile
@@ -1,10 +1,8 @@
# $FreeBSD$
# @(#)Makefile 8.2 (Berkeley) 4/27/95
-PROG= fsck_ffs
-LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_ufs
-LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_4.2bsd
-MAN8= fsck_ffs.8
+PROG= fsck_ifs
+NOMAN= true
SRCS= dir.c fsutil.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
pass5.c setup.c utilities.c ffs_subr.c ffs_tables.c
CFLAGS+=-W
diff --git a/sbin/fsck_ifs/main.c b/sbin/fsck_ifs/main.c
index 1e8a5b4..2c263da 100644
--- a/sbin/fsck_ifs/main.c
+++ b/sbin/fsck_ifs/main.c
@@ -241,9 +241,12 @@ checkfilesys(filesys, mntpt, auxdata, child)
/*
* 2: traverse directories from root to mark all connected directories
*/
+#ifdef NOTFORIFS
if (preen == 0)
printf("** Phase 2 - Check Pathnames\n");
pass2();
+#endif
+ printf("** Skipping phase 2 for IFS\n");
/*
* 3: scan inodes looking for disconnected directories
@@ -345,7 +348,7 @@ checkfilesys(filesys, mntpt, auxdata, child)
args.fspec = 0;
args.export.ex_flags = 0;
args.export.ex_root = 0;
- ret = mount("ufs", mntbuf->f_mntonname,
+ ret = mount("ifs", mntbuf->f_mntonname,
mntbuf->f_flags | MNT_UPDATE | MNT_RELOAD, &args);
if (ret == 0)
return (0);
@@ -380,7 +383,7 @@ getmntpt(name)
return (NULL);
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
for (i = 0; i < mntsize; i++) {
- if (strcmp(mntbuf[i].f_fstypename, "ufs") != 0)
+ if (strcmp(mntbuf[i].f_fstypename, "ifs") != 0)
continue;
devname = mntbuf[i].f_mntfromname;
if (*devname != '/') {
diff --git a/sbin/fsck_ifs/pass4.c b/sbin/fsck_ifs/pass4.c
index 0012c50..2a8e43b 100644
--- a/sbin/fsck_ifs/pass4.c
+++ b/sbin/fsck_ifs/pass4.c
@@ -73,9 +73,12 @@ pass4()
case DFOUND:
n = inoinfo(inumber)->ino_linkcnt;
if (n) {
+#if NOTFORIFS
adjust(&idesc, (short)n);
+#endif
break;
}
+#if NOTFORIFS
for (zlnp = zlnhead; zlnp; zlnp = zlnp->next) {
if (zlnp->zlncnt == inumber) {
zlnp->zlncnt = zlnhead->zlncnt;
@@ -86,10 +89,10 @@ pass4()
break;
}
}
+#endif
break;
case DSTATE:
- clri(&idesc, "UNREF", 1);
break;
case DCLEAR:
diff --git a/sbin/fsck_ifs/setup.c b/sbin/fsck_ifs/setup.c
index 6c4098c..b9c3148 100644
--- a/sbin/fsck_ifs/setup.c
+++ b/sbin/fsck_ifs/setup.c
@@ -292,10 +292,12 @@ setup(dev)
}
numdirs = sblock.fs_cstotal.cs_ndir;
dirhash = numdirs;
+#if NOTFORIFS
if (numdirs == 0) {
printf("numdirs is zero, try using an alternate superblock\n");
goto badsb;
}
+#endif
inplast = 0;
listmax = numdirs + 10;
inpsort = (struct inoinfo **)calloc((unsigned)listmax,
diff --git a/sbin/mount_ifs/Makefile b/sbin/mount_ifs/Makefile
index 96c996d..0969ac2 100644
--- a/sbin/mount_ifs/Makefile
+++ b/sbin/mount_ifs/Makefile
@@ -1,9 +1,9 @@
# @(#)Makefile 8.6 (Berkeley) 5/8/95
# $FreeBSD$
-PROG= mount
-SRCS= mount.c mount_ufs.c getmntopts.c vfslist.c
-MAN8= mount.8
+PROG= mount_ifs
+SRCS= mount.c mount_ufs.c getmntopts.c
+NOMAN= true
# We do NOT install the getmntopts.3 man page.
.include <bsd.prog.mk>
diff --git a/sbin/mount_ifs/extern.h b/sbin/mount_ifs/extern.h
index bc11a03..9306b4f 100644
--- a/sbin/mount_ifs/extern.h
+++ b/sbin/mount_ifs/extern.h
@@ -26,9 +26,5 @@
* $FreeBSD$
*/
-/* vfslist.c */
-int checkvfsname __P((const char *, const char **));
-const char **makevfslist __P((char *));
-
/* mount_ufs.c */
-int mount_ufs __P((int, char *const *));
+int mount_ifs __P((int, char *const *));
diff --git a/sbin/mount_ifs/mount.c b/sbin/mount_ifs/mount.c
index 3177776..521be4a 100644
--- a/sbin/mount_ifs/mount.c
+++ b/sbin/mount_ifs/mount.c
@@ -134,179 +134,8 @@ main(argc, argv)
int all, ch, i, init_flags, mntsize, rval, have_fstab;
char *options;
- all = init_flags = 0;
- options = NULL;
- vfslist = NULL;
- vfstype = "ufs";
- while ((ch = getopt(argc, argv, "adfo:prwt:uv")) != -1)
- switch (ch) {
- case 'a':
- all = 1;
- break;
- case 'd':
- debug = 1;
- break;
- case 'f':
- init_flags |= MNT_FORCE;
- break;
- case 'o':
- if (*optarg)
- options = catopt(options, optarg);
- break;
- case 'p':
- fstab_style = 1;
- verbose = 1;
- break;
- case 'r':
- init_flags |= MNT_RDONLY;
- break;
- case 't':
- if (vfslist != NULL)
- errx(1, "only one -t option may be specified");
- vfslist = makevfslist(optarg);
- vfstype = optarg;
- break;
- case 'u':
- init_flags |= MNT_UPDATE;
- break;
- case 'v':
- verbose = 1;
- break;
- case 'w':
- init_flags &= ~MNT_RDONLY;
- break;
- case '?':
- default:
- usage();
- /* NOTREACHED */
- }
- argc -= optind;
- argv += optind;
-
-#define BADTYPE(type) \
- (strcmp(type, FSTAB_RO) && \
- strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
-
- rval = 0;
- switch (argc) {
- case 0:
- if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
- err(1, "getmntinfo");
- if (all) {
- while ((fs = getfsent()) != NULL) {
- if (BADTYPE(fs->fs_type))
- continue;
- if (checkvfsname(fs->fs_vfstype, vfslist))
- continue;
- if (hasopt(fs->fs_mntops, "noauto"))
- continue;
- if (!(init_flags & MNT_UPDATE) &&
- ismounted(fs, mntbuf, mntsize))
- continue;
- if (mountfs(fs->fs_vfstype, fs->fs_spec,
- fs->fs_file, init_flags, options,
- fs->fs_mntops))
- rval = 1;
- }
- } else if (fstab_style) {
- for (i = 0; i < mntsize; i++) {
- if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
- continue;
- putfsent(&mntbuf[i]);
- }
- } else {
- for (i = 0; i < mntsize; i++) {
- if (checkvfsname(mntbuf[i].f_fstypename,
- vfslist))
- continue;
- prmount(&mntbuf[i]);
- }
- }
- exit(rval);
- case 1:
- if (vfslist != NULL)
- usage();
-
- if (init_flags & MNT_UPDATE) {
- mntfromname = NULL;
- have_fstab = 0;
- if ((mntbuf = getmntpt(*argv)) == NULL)
- errx(1, "not currently mounted %s", *argv);
- /*
- * Only get the mntflags from fstab if both mntpoint
- * and mntspec are identical. Also handle the special
- * case where just '/' is mounted and 'spec' is not
- * identical with the one from fstab ('/dev' is missing
- * in the spec-string at boot-time).
- */
- if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) {
- if (strcmp(fs->fs_spec,
- mntbuf->f_mntfromname) == 0 &&
- strcmp(fs->fs_file,
- mntbuf->f_mntonname) == 0) {
- have_fstab = 1;
- mntfromname = mntbuf->f_mntfromname;
- } else if (argv[0][0] == '/' &&
- argv[0][1] == '\0') {
- fs = getfsfile("/");
- have_fstab = 1;
- mntfromname = fs->fs_spec;
- }
- }
- if (have_fstab) {
- options = update_options(options, fs->fs_mntops,
- mntbuf->f_flags);
- } else {
- mntfromname = mntbuf->f_mntfromname;
- options = update_options(options, NULL,
- mntbuf->f_flags);
- }
- rval = mountfs(mntbuf->f_fstypename, mntfromname,
- mntbuf->f_mntonname, init_flags, options, 0);
- break;
- }
- rmslashes(*argv, *argv);
- if ((fs = getfsfile(*argv)) == NULL &&
- (fs = getfsspec(*argv)) == NULL)
- errx(1, "%s: unknown special file or file system",
- *argv);
- if (BADTYPE(fs->fs_type))
- errx(1, "%s has unknown file system type",
- *argv);
- rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file,
- init_flags, options, fs->fs_mntops);
- break;
- case 2:
- /*
- * If -t flag has not been specified, the path cannot be
- * found, spec contains either a ':' or a '@', and the
- * spec is not a file with those characters, then assume
- * that an NFS filesystem is being specified ala Sun.
- */
- if (vfslist == NULL && strpbrk(argv[0], ":@") != NULL &&
- access(argv[0], 0) == -1)
- vfstype = "nfs";
- rval = mountfs(vfstype,
- argv[0], argv[1], init_flags, options, NULL);
- break;
- default:
- usage();
- /* NOTREACHED */
- }
-
- /*
- * If the mount was successfully, and done by root, tell mountd the
- * good news. Pid checks are probably unnecessary, but don't hurt.
- */
- if (rval == 0 && getuid() == 0 &&
- (mountdfp = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
- if (fscanf(mountdfp, "%d", &pid) == 1 &&
- pid > 0 && kill(pid, SIGHUP) == -1 && errno != ESRCH)
- err(1, "signal mountd");
- (void)fclose(mountdfp);
- }
-
- exit(rval);
+ mount_ifs(argc, argv);
+ /* NOTREACHED */
}
int
@@ -440,8 +269,8 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
free(optbuf);
return (1);
case 0: /* Child. */
- if (strcmp(vfstype, "ufs") == 0)
- exit(mount_ufs(argc, (char * const *) argv));
+ if (strcmp(vfstype, "ifs") == 0)
+ exit(mount_ifs(argc, (char * const *) argv));
/* Go find an executable. */
for (edir = edirs; *edir; edir++) {
@@ -688,10 +517,8 @@ void
usage()
{
- (void)fprintf(stderr, "%s\n%s\n%s\n",
-"usage: mount [-dfpruvw] [-o options] [-t ufs | external_type] special node",
-" mount [-adfpruvw] [-t ufs | external_type]",
-" mount [-dfpruvw] special | node");
+ (void)fprintf(stderr, "%s\n",
+"usage: mount [-dfpruvw] [-o options] special node");
exit(1);
}
diff --git a/sbin/mount_ifs/mount_ufs.c b/sbin/mount_ifs/mount_ufs.c
index 18180b8..65dc32e 100644
--- a/sbin/mount_ifs/mount_ufs.c
+++ b/sbin/mount_ifs/mount_ufs.c
@@ -58,7 +58,7 @@ static const char rcsid[] =
#include "extern.h"
#include "mntopts.h"
-static void ufs_usage __P((void));
+static void ifs_usage __P((void));
static struct mntopt mopts[] = {
MOPT_STDOPTS,
@@ -71,7 +71,7 @@ static struct mntopt mopts[] = {
};
int
-mount_ufs(argc, argv)
+mount_ifs(argc, argv)
int argc;
char * const argv[];
{
@@ -90,13 +90,13 @@ mount_ufs(argc, argv)
break;
case '?':
default:
- ufs_usage();
+ ifs_usage();
}
argc -= optind;
argv += optind;
if (argc != 2)
- ufs_usage();
+ ifs_usage();
args.fspec = argv[0]; /* The name of the device file. */
fs_name = argv[1]; /* The mount point. */
@@ -108,17 +108,17 @@ mount_ufs(argc, argv)
else
args.export.ex_flags = 0;
- error = getvfsbyname("ufs", &vfc);
- if (error && vfsisloadable("ufs")) {
- if (vfsload("ufs")) {
- warn("vfsload(ufs)");
+ error = getvfsbyname("ifs", &vfc);
+ if (error && vfsisloadable("ifs")) {
+ if (vfsload("ifs")) {
+ warn("vfsload(ifs)");
return (1);
}
endvfsent(); /* flush old table */
- error = getvfsbyname("ufs", &vfc);
+ error = getvfsbyname("ifs", &vfc);
}
if (error) {
- warnx("ufs filesystem is not available");
+ warnx("ifs filesystem is not available");
return (1);
}
@@ -147,8 +147,8 @@ mount_ufs(argc, argv)
}
static void
-ufs_usage()
+ifs_usage()
{
- (void)fprintf(stderr, "usage: mount_ufs [-o options] special node\n");
+ (void)fprintf(stderr, "usage: mount_ifs [-o options] special node\n");
exit(1);
}
diff --git a/sbin/mount_ifs/vfslist.c b/sbin/mount_ifs/vfslist.c
deleted file mode 100644
index d820188..0000000
--- a/sbin/mount_ifs/vfslist.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * Copyright (c) 1995
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)vfslist.c 8.1 (Berkeley) 5/8/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <err.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "extern.h"
-
-static int skipvfs;
-
-int
-checkvfsname(vfsname, vfslist)
- const char *vfsname;
- const char **vfslist;
-{
-
- if (vfslist == NULL)
- return (0);
- while (*vfslist != NULL) {
- if (strcmp(vfsname, *vfslist) == 0)
- return (skipvfs);
- ++vfslist;
- }
- return (!skipvfs);
-}
-
-const char **
-makevfslist(fslist)
- char *fslist;
-{
- const char **av;
- int i;
- char *nextcp;
-
- if (fslist == NULL)
- return (NULL);
- if (fslist[0] == 'n' && fslist[1] == 'o') {
- fslist += 2;
- skipvfs = 1;
- }
- for (i = 0, nextcp = fslist; *nextcp; nextcp++)
- if (*nextcp == ',')
- i++;
- if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) {
- warnx("malloc failed");
- return (NULL);
- }
- nextcp = fslist;
- i = 0;
- av[i++] = nextcp;
- while ((nextcp = strchr(nextcp, ',')) != NULL) {
- *nextcp++ = '\0';
- av[i++] = nextcp;
- }
- av[i++] = NULL;
- return (av);
-}
OpenPOWER on IntegriCloud