Now that the kernel is able to load modules itself,

remove all the code which was trying to do so.
This code was nasty in several ways, it was hiding
the kernel bug where the kernel was unable to properly
load a module, and it was quitting if it wasn't able
to load the module.  The consequence is that an ABI
breakage of the vfsconf API would have broken *every*
mount utility.
This commit is contained in:
mux 2002-08-03 16:03:21 +00:00
parent e01d9e52fc
commit 2051522c35
16 changed files with 26 additions and 254 deletions

View File

@ -79,8 +79,6 @@ mount_ufs(argc, argv)
struct ufs_args args; struct ufs_args args;
int ch, mntflags; int ch, mntflags;
char *fs_name; char *fs_name;
struct vfsconf vfc;
int error = 0;
mntflags = 0; mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */ optind = optreset = 1; /* Reset for parse of new argv. */
@ -109,21 +107,7 @@ mount_ufs(argc, argv)
else else
args.export.ex_flags = 0; args.export.ex_flags = 0;
error = getvfsbyname("ufs", &vfc); if (mount("ufs", fs_name, mntflags, &args) < 0) {
if (error && vfsisloadable("ufs")) {
if (vfsload("ufs")) {
warn("vfsload(ufs)");
return (1);
}
endvfsent(); /* flush old table */
error = getvfsbyname("ufs", &vfc);
}
if (error) {
warnx("ufs filesystem is not available");
return (1);
}
if (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0) {
switch (errno) { switch (errno) {
case EMFILE: case EMFILE:
warnx("%s on %s: mount table full", warnx("%s on %s: mount table full",

View File

@ -90,7 +90,6 @@ main(int argc, char **argv)
struct iso_args args; struct iso_args args;
int ch, mntflags, opts; int ch, mntflags, opts;
char *dev, *dir, mntpath[MAXPATHLEN]; char *dev, *dir, mntpath[MAXPATHLEN];
struct vfsconf vfc;
int error, verbose; int error, verbose;
mntflags = opts = verbose = 0; mntflags = opts = verbose = 0;
@ -172,17 +171,7 @@ main(int argc, char **argv)
printf("using starting sector %d\n", args.ssector); printf("using starting sector %d\n", args.ssector);
} }
error = getvfsbyname("cd9660", &vfc); if (mount("cd9660", mntpath, mntflags, &args) < 0)
if (error && vfsisloadable("cd9660")) {
if (vfsload("cd9660"))
err(EX_OSERR, "vfsload(cd9660)");
endvfsent(); /* flush cache */
error = getvfsbyname("cd9660", &vfc);
}
if (error)
errx(1, "cd9660 filesystem is not available");
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
err(1, "%s", args.fspec); err(1, "%s", args.fspec);
exit(0); exit(0);
} }

View File

@ -75,8 +75,6 @@ main(argc, argv)
struct iovec iov[6]; struct iovec iov[6];
int ch, mntflags; int ch, mntflags;
char *fs_name, *options, *fspec, mntpath[MAXPATHLEN]; char *fs_name, *options, *fspec, mntpath[MAXPATHLEN];
struct vfsconf vfc;
int error;
options = NULL; options = NULL;
mntflags = 0; mntflags = 0;
@ -105,21 +103,10 @@ main(argc, argv)
(void)checkpath(fs_name, mntpath); (void)checkpath(fs_name, mntpath);
(void)rmslashes(fspec, fspec); (void)rmslashes(fspec, fspec);
error = getvfsbyname("ext2fs", &vfc);
if (error && vfsisloadable("ext2fs")) {
if (vfsload("ext2fs")) {
err(EX_OSERR, "vfsload(ext2fs)");
}
endvfsent(); /* flush cache */
error = getvfsbyname("ext2fs", &vfc);
}
if (error)
errx(EX_OSERR, "ext2fs filesystem is not available");
iov[0].iov_base = "fstype"; iov[0].iov_base = "fstype";
iov[0].iov_len = sizeof("fstype"); iov[0].iov_len = sizeof("fstype");
iov[1].iov_base = vfc.vfc_name; iov[1].iov_base = "ext2fs";
iov[1].iov_len = strlen(vfc.vfc_name) + 1; iov[1].iov_len = strlen(iov[1].iov_base) + 1;
iov[2].iov_base = "fspath"; iov[2].iov_base = "fspath";
iov[2].iov_len = sizeof("fspath"); iov[2].iov_len = sizeof("fspath");
iov[3].iov_base = mntpath; iov[3].iov_base = mntpath;

View File

@ -66,14 +66,9 @@ main(argc, argv)
{ {
struct hpfs_args args; struct hpfs_args args;
struct stat sb; struct stat sb;
int c, mntflags, set_gid, set_uid, set_mask,error; int c, mntflags, set_gid, set_uid, set_mask;
int forcerw = 0; int forcerw = 0;
char *dev, *dir, ndir[MAXPATHLEN+1]; char *dev, *dir, ndir[MAXPATHLEN+1];
#if __FreeBSD_version >= 300000
struct vfsconf vfc;
#else
struct vfsconf *vfc;
#endif
mntflags = set_gid = set_uid = set_mask = 0; mntflags = set_gid = set_uid = set_mask = 0;
(void)memset(&args, '\0', sizeof(args)); (void)memset(&args, '\0', sizeof(args));
@ -148,35 +143,7 @@ main(argc, argv)
args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
} }
#if __FreeBSD_version >= 300000 if (mount("hpfs", dir, mntflags, &args) < 0)
error = getvfsbyname("hpfs", &vfc);
if(error && vfsisloadable("hpfs")) {
if(vfsload("hpfs"))
#else
vfc = getvfsbyname("hpfs");
if(!vfc && vfsisloadable("hpfs")) {
if(vfsload("hpfs"))
#endif
err(EX_OSERR, "vfsload(hpfs)");
endvfsent(); /* clear cache */
#if __FreeBSD_version >= 300000
error = getvfsbyname("hpfs", &vfc);
#else
vfc = getvfsbyname("hpfs");
#endif
}
#if __FreeBSD_version >= 300000
if (error)
#else
if (!vfc)
#endif
errx(EX_OSERR, "hpfs filesystem is not available");
#if __FreeBSD_version >= 300000
if (mount(vfc.vfc_name, dir, mntflags, &args) < 0)
#else
if (mount(vfc->vfc_index, dir, mntflags, &args) < 0)
#endif
err(EX_OSERR, "%s", dev); err(EX_OSERR, "%s", dev);
exit (0); exit (0);

View File

@ -88,9 +88,8 @@ main(argc, argv)
{ {
struct msdosfs_args args; struct msdosfs_args args;
struct stat sb; struct stat sb;
int c, error, mntflags, set_gid, set_uid, set_mask; int c, mntflags, set_gid, set_uid, set_mask;
char *dev, *dir, mntpath[MAXPATHLEN]; char *dev, *dir, mntpath[MAXPATHLEN];
struct vfsconf vfc;
mntflags = set_gid = set_uid = set_mask = 0; mntflags = set_gid = set_uid = set_mask = 0;
(void)memset(&args, '\0', sizeof(args)); (void)memset(&args, '\0', sizeof(args));
@ -173,17 +172,7 @@ main(argc, argv)
args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
} }
error = getvfsbyname("msdosfs", &vfc); if (mount("msdosfs", mntpath, mntflags, &args) < 0)
if (error && vfsisloadable("msdosfs")) {
if (vfsload("msdosfs"))
err(EX_OSERR, "vfsload(msdosfs)");
endvfsent(); /* clear cache */
error = getvfsbyname("msdosfs", &vfc);
}
if (error)
errx(EX_OSERR, "msdos filesystem is not available");
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
err(EX_OSERR, "%s", dev); err(EX_OSERR, "%s", dev);
exit (0); exit (0);

View File

@ -247,8 +247,6 @@ main(argc, argv)
int mntflags, altflags, nfssvc_flag, num; int mntflags, altflags, nfssvc_flag, num;
char *name, *p, *spec; char *name, *p, *spec;
char mntpath[MAXPATHLEN]; char mntpath[MAXPATHLEN];
struct vfsconf vfc;
int error = 0;
mntflags = 0; mntflags = 0;
altflags = 0; altflags = 0;
@ -436,17 +434,7 @@ main(argc, argv)
/* resolve the mountpoint with realpath(3) */ /* resolve the mountpoint with realpath(3) */
(void)checkpath(name, mntpath); (void)checkpath(name, mntpath);
error = getvfsbyname("nfs", &vfc); if (mount("nfs", mntpath, mntflags, nfsargsp))
if (error && vfsisloadable("nfs")) {
if(vfsload("nfs"))
err(EX_OSERR, "vfsload(nfs)");
endvfsent(); /* clear cache */
error = getvfsbyname("nfs", &vfc);
}
if (error)
errx(EX_OSERR, "nfs filesystem is not available");
if (mount(vfc.vfc_name, mntpath, mntflags, nfsargsp))
err(1, "%s", mntpath); err(1, "%s", mntpath);
exit(0); exit(0);

View File

@ -70,13 +70,8 @@ main(argc, argv)
{ {
struct ntfs_args args; struct ntfs_args args;
struct stat sb; struct stat sb;
int c, mntflags, set_gid, set_uid, set_mask, error; int c, mntflags, set_gid, set_uid, set_mask;
char *dev, *dir, mntpath[MAXPATHLEN]; char *dev, *dir, mntpath[MAXPATHLEN];
#if __FreeBSD_version >= 300000
struct vfsconf vfc;
#else
struct vfsconf *vfc;
#endif
mntflags = set_gid = set_uid = set_mask = 0; mntflags = set_gid = set_uid = set_mask = 0;
(void)memset(&args, '\0', sizeof(args)); (void)memset(&args, '\0', sizeof(args));
@ -146,35 +141,7 @@ main(argc, argv)
args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
} }
#if __FreeBSD_version >= 300000 if (mount("ntfs", mntpath, mntflags, &args) < 0)
error = getvfsbyname("ntfs", &vfc);
if(error && vfsisloadable("ntfs")) {
if(vfsload("ntfs"))
#else
vfc = getvfsbyname("ntfs");
if(!vfc && vfsisloadable("ntfs")) {
if(vfsload("ntfs"))
#endif
err(EX_OSERR, "vfsload(ntfs)");
endvfsent(); /* clear cache */
#if __FreeBSD_version >= 300000
error = getvfsbyname("ntfs", &vfc);
#else
vfc = getvfsbyname("ntfs");
#endif
}
#if __FreeBSD_version >= 300000
if (error)
#else
if (!vfc)
#endif
errx(EX_OSERR, "ntfs filesystem is not available");
#if __FreeBSD_version >= 300000
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
#else
if (mount(vfc->vfc_index, mntpath, mntflags, &args) < 0)
#endif
err(EX_OSERR, "%s", dev); err(EX_OSERR, "%s", dev);
exit (0); exit (0);

View File

@ -77,7 +77,6 @@ main(argc, argv)
int ch, mntflags; int ch, mntflags;
char source[MAXPATHLEN]; char source[MAXPATHLEN];
char target[MAXPATHLEN]; char target[MAXPATHLEN];
struct vfsconf vfc;
int error; int error;
mntflags = 0; mntflags = 0;
@ -104,20 +103,10 @@ main(argc, argv)
errx(EX_USAGE, "%s (%s) and %s are not distinct paths", errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
argv[0], target, argv[1]); argv[0], target, argv[1]);
error = getvfsbyname("nullfs", &vfc);
if (error && vfsisloadable("nullfs")) {
if(vfsload("nullfs"))
err(EX_OSERR, "vfsload(nullfs)");
endvfsent();
error = getvfsbyname("nullfs", &vfc);
}
if (error)
errx(EX_OSERR, "null/loopback filesystem is not available");
iov[0].iov_base = "fstype"; iov[0].iov_base = "fstype";
iov[0].iov_len = sizeof("fstype"); iov[0].iov_len = sizeof("fstype");
iov[1].iov_base = vfc.vfc_name; iov[1].iov_base = "nullfs";
iov[1].iov_len = strlen(vfc.vfc_name) + 1; iov[1].iov_len = strlen("nullfs") + 1;
iov[2].iov_base = "fspath"; iov[2].iov_base = "fspath";
iov[2].iov_len = sizeof("fspath"); iov[2].iov_len = sizeof("fspath");
iov[3].iov_base = source; iov[3].iov_base = source;

View File

@ -76,7 +76,6 @@ main(int argc, char *argv[]) {
struct nwfs_args mdata; struct nwfs_args mdata;
struct ncp_conn_loginfo li; struct ncp_conn_loginfo li;
struct stat st; struct stat st;
struct vfsconf vfc;
struct nw_entry_info einfo; struct nw_entry_info einfo;
struct tm *tm; struct tm *tm;
time_t ltime; time_t ltime;
@ -97,16 +96,6 @@ main(int argc, char *argv[]) {
} }
} }
error = getvfsbyname(NWFS_VFSNAME, &vfc);
if (error && vfsisloadable(NWFS_VFSNAME)) {
if(vfsload(NWFS_VFSNAME))
err(EX_OSERR, "vfsload("NWFS_VFSNAME")");
endvfsent();
error = getvfsbyname(NWFS_VFSNAME, &vfc);
}
if (error)
errx(EX_OSERR, "NetWare filesystem is not available");
if(ncp_initlib()) exit(1); if(ncp_initlib()) exit(1);
mntflags = error = 0; mntflags = error = 0;

View File

@ -108,7 +108,6 @@ main(argc, argv)
char mountpt[MAXPATHLEN]; char mountpt[MAXPATHLEN];
int mntflags = 0; int mntflags = 0;
char tag[32]; char tag[32];
struct vfsconf vfc;
mode_t um; mode_t um;
qelem q; qelem q;
@ -175,17 +174,7 @@ main(argc, argv)
sprintf(tag, "portal:%d", getpid()); sprintf(tag, "portal:%d", getpid());
args.pa_config = tag; args.pa_config = tag;
error = getvfsbyname("portalfs", &vfc); rc = mount("portalfs", mountpt, mntflags, &args);
if (error && vfsisloadable("portalfs")) {
if (vfsload("portalfs"))
err(EX_OSERR, "vfsload(portalfs)");
endvfsent();
error = getvfsbyname("portalfs", &vfc);
}
if (error)
errx(EX_OSERR, "portal filesystem is not available");
rc = mount(vfc.vfc_name, mountpt, mntflags, &args);
if (rc < 0) if (rc < 0)
err(1, NULL); err(1, NULL);

View File

@ -66,7 +66,7 @@ static struct mntopt mopts[] = {
{ NULL } { NULL }
}; };
static const char *fsname; static char *fsname;
static volatile sig_atomic_t caughtsig; static volatile sig_atomic_t caughtsig;
static void usage(void) __dead2; static void usage(void) __dead2;
@ -84,7 +84,6 @@ main(argc, argv)
{ {
int ch, mntflags; int ch, mntflags;
char mntpath[MAXPATHLEN]; char mntpath[MAXPATHLEN];
struct vfsconf vfc;
struct iovec iov[4]; struct iovec iov[4];
int error; int error;
@ -120,23 +119,13 @@ main(argc, argv)
if (argc != 2) if (argc != 2)
usage(); usage();
error = getvfsbyname(fsname, &vfc);
if (error && vfsisloadable(fsname)) {
if(vfsload(fsname))
err(EX_OSERR, "vfsload(%s)", fsname);
endvfsent();
error = getvfsbyname(fsname, &vfc);
}
if (error)
errx(EX_OSERR, "%s filesystem not available", fsname);
/* resolve the mountpoint with realpath(3) */ /* resolve the mountpoint with realpath(3) */
(void)checkpath(argv[1], mntpath); (void)checkpath(argv[1], mntpath);
iov[0].iov_base = "fstype"; iov[0].iov_base = "fstype";
iov[0].iov_len = sizeof("fstype"); iov[0].iov_len = sizeof("fstype");
iov[1].iov_base = vfc.vfc_name; iov[1].iov_base = fsname;
iov[1].iov_len = strlen(vfc.vfc_name) + 1; iov[1].iov_len = strlen(iov[1].iov_base) + 1;
iov[2].iov_base = "fspath"; iov[2].iov_base = "fspath";
iov[2].iov_len = sizeof("fstype"); iov[2].iov_len = sizeof("fstype");
iov[3].iov_base = mntpath; iov[3].iov_base = mntpath;
@ -161,7 +150,7 @@ main(argc, argv)
* or the user didn't recompile his kernel. * or the user didn't recompile his kernel.
*/ */
if (error && (errno == EOPNOTSUPP || errno == ENOSYS || caughtsig)) if (error && (errno == EOPNOTSUPP || errno == ENOSYS || caughtsig))
error = mount(vfc.vfc_name, mntpath, mntflags, NULL); error = mount(fsname, mntpath, mntflags, NULL);
if (error) if (error)
err(EX_OSERR, NULL); err(EX_OSERR, NULL);

View File

@ -73,8 +73,7 @@ main(int argc, char **argv)
struct iovec iov[6]; struct iovec iov[6];
int ch, mntflags, opts; int ch, mntflags, opts;
char *dev, *dir, mntpath[MAXPATHLEN]; char *dev, *dir, mntpath[MAXPATHLEN];
struct vfsconf vfc; int verbose;
int error, verbose;
mntflags = opts = verbose = 0; mntflags = opts = verbose = 0;
while ((ch = getopt(argc, argv, "o:v")) != -1) while ((ch = getopt(argc, argv, "o:v")) != -1)
@ -109,20 +108,11 @@ main(int argc, char **argv)
* UDF filesystems are not writeable. * UDF filesystems are not writeable.
*/ */
mntflags |= MNT_RDONLY; mntflags |= MNT_RDONLY;
error = getvfsbyname("udf", &vfc);
if (error && vfsisloadable("udf")) {
if (vfsload("udf"))
err(EX_OSERR, "vfsload(udf)");
endvfsent(); /* flush cache */
error = getvfsbyname("udf", &vfc);
}
if (error)
errx(1, "udf filesystem is not available");
iov[0].iov_base = "fstype"; iov[0].iov_base = "fstype";
iov[0].iov_len = sizeof("fstype"); iov[0].iov_len = sizeof("fstype");
iov[1].iov_base = vfc.vfc_name; iov[1].iov_base = "udf";
iov[1].iov_len = strlen(vfc.vfc_name) + 1; iov[1].iov_len = strlen(iov[1].iov_base) + 1;
iov[2].iov_base = "fspath"; iov[2].iov_base = "fspath";
iov[2].iov_len = sizeof("fspath"); iov[2].iov_len = sizeof("fspath");
iov[3].iov_base = mntpath; iov[3].iov_base = mntpath;

View File

@ -101,8 +101,6 @@ main(argc, argv)
int ch, count, gnentries, mntflags, nentries; int ch, count, gnentries, mntflags, nentries;
char *gmapfile, *mapfile, buf[20]; char *gmapfile, *mapfile, buf[20];
char source[MAXPATHLEN], target[MAXPATHLEN]; char source[MAXPATHLEN], target[MAXPATHLEN];
struct vfsconf vfc;
int error;
mntflags = 0; mntflags = 0;
mapfile = gmapfile = NULL; mapfile = gmapfile = NULL;
@ -227,17 +225,7 @@ main(argc, argv)
args.gnentries = gnentries; args.gnentries = gnentries;
args.gmapdata = gmapdata; args.gmapdata = gmapdata;
error = getvfsbyname("umapfs", &vfc); if (mount("umapfs", argv[1], mntflags, &args))
if (error && vfsisloadable("umapfs")) {
if(vfsload("umapfs"))
err(1, "vfsload(umapfs)");
endvfsent();
error = getvfsbyname("umapfs", &vfc);
}
if (error)
errx(1, "umap filesystem is not available");
if (mount(vfc.vfc_name, argv[1], mntflags, &args))
err(1, NULL); err(1, NULL);
exit(0); exit(0);
} }

View File

@ -78,8 +78,7 @@ main(argc, argv)
int ch, mntflags; int ch, mntflags;
char source[MAXPATHLEN]; char source[MAXPATHLEN];
char target[MAXPATHLEN]; char target[MAXPATHLEN];
struct vfsconf vfc; int iovcnt;
int error, iovcnt;
iovcnt = 6; iovcnt = 6;
mntflags = 0; mntflags = 0;
@ -121,20 +120,10 @@ main(argc, argv)
errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths", errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths",
argv[0], target, argv[1], source); argv[0], target, argv[1], source);
error = getvfsbyname("unionfs", &vfc);
if (error && vfsisloadable("unionfs")) {
if (vfsload("unionfs"))
err(EX_OSERR, "vfsload(unionfs)");
endvfsent(); /* flush cache */
error = getvfsbyname("unionfs", &vfc);
}
if (error)
errx(EX_OSERR, "union filesystem is not available");
iov[0].iov_base = "fstype"; iov[0].iov_base = "fstype";
iov[0].iov_len = strlen(iov[0].iov_base) + 1; iov[0].iov_len = strlen(iov[0].iov_base) + 1;
iov[1].iov_base = vfc.vfc_name; iov[1].iov_base = "unionfs";
iov[1].iov_len = strlen(vfc.vfc_name) + 1; iov[1].iov_len = strlen(iov[1].iov_base) + 1;
iov[2].iov_base = "fspath"; iov[2].iov_base = "fspath";
iov[2].iov_len = strlen(iov[2].iov_base) + 1; iov[2].iov_len = strlen(iov[2].iov_base) + 1;
iov[3].iov_base = source; iov[3].iov_base = source;

View File

@ -76,7 +76,6 @@ main(int argc, char *argv[]) {
struct nwfs_args mdata; struct nwfs_args mdata;
struct ncp_conn_loginfo li; struct ncp_conn_loginfo li;
struct stat st; struct stat st;
struct vfsconf vfc;
struct nw_entry_info einfo; struct nw_entry_info einfo;
struct tm *tm; struct tm *tm;
time_t ltime; time_t ltime;
@ -97,16 +96,6 @@ main(int argc, char *argv[]) {
} }
} }
error = getvfsbyname(NWFS_VFSNAME, &vfc);
if (error && vfsisloadable(NWFS_VFSNAME)) {
if(vfsload(NWFS_VFSNAME))
err(EX_OSERR, "vfsload("NWFS_VFSNAME")");
endvfsent();
error = getvfsbyname(NWFS_VFSNAME, &vfc);
}
if (error)
errx(EX_OSERR, "NetWare filesystem is not available");
if(ncp_initlib()) exit(1); if(ncp_initlib()) exit(1);
mntflags = error = 0; mntflags = error = 0;

View File

@ -108,7 +108,6 @@ main(argc, argv)
char mountpt[MAXPATHLEN]; char mountpt[MAXPATHLEN];
int mntflags = 0; int mntflags = 0;
char tag[32]; char tag[32];
struct vfsconf vfc;
mode_t um; mode_t um;
qelem q; qelem q;
@ -175,17 +174,7 @@ main(argc, argv)
sprintf(tag, "portal:%d", getpid()); sprintf(tag, "portal:%d", getpid());
args.pa_config = tag; args.pa_config = tag;
error = getvfsbyname("portalfs", &vfc); rc = mount("portalfs", mountpt, mntflags, &args);
if (error && vfsisloadable("portalfs")) {
if (vfsload("portalfs"))
err(EX_OSERR, "vfsload(portalfs)");
endvfsent();
error = getvfsbyname("portalfs", &vfc);
}
if (error)
errx(EX_OSERR, "portal filesystem is not available");
rc = mount(vfc.vfc_name, mountpt, mntflags, &args);
if (rc < 0) if (rc < 0)
err(1, NULL); err(1, NULL);