From 526ba6d32b79b714f8c5cd54892d80b60b24f9a4 Mon Sep 17 00:00:00 2001 From: Maxime Henrion Date: Sat, 3 Aug 2002 16:03:21 +0000 Subject: [PATCH] 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. --- sbin/mount/mount_ufs.c | 18 +----------- sbin/mount_cd9660/mount_cd9660.c | 13 +-------- sbin/mount_ext2fs/mount_ext2fs.c | 17 ++--------- sbin/mount_hpfs/mount_hpfs.c | 37 ++---------------------- sbin/mount_msdosfs/mount_msdosfs.c | 15 ++-------- sbin/mount_nfs/mount_nfs.c | 14 +-------- sbin/mount_ntfs/mount_ntfs.c | 37 ++---------------------- sbin/mount_nullfs/mount_nullfs.c | 15 ++-------- sbin/mount_nwfs/mount_nwfs.c | 11 ------- sbin/mount_portalfs/mount_portalfs.c | 13 +-------- sbin/mount_std/mount_std.c | 19 +++--------- sbin/mount_udf/mount_udf.c | 16 ++-------- sbin/mount_umapfs/mount_umapfs.c | 14 +-------- sbin/mount_unionfs/mount_unionfs.c | 17 ++--------- usr.sbin/mount_nwfs/mount_nwfs.c | 11 ------- usr.sbin/mount_portalfs/mount_portalfs.c | 13 +-------- 16 files changed, 26 insertions(+), 254 deletions(-) diff --git a/sbin/mount/mount_ufs.c b/sbin/mount/mount_ufs.c index dee0ddf5db8..f15ef9aa960 100644 --- a/sbin/mount/mount_ufs.c +++ b/sbin/mount/mount_ufs.c @@ -79,8 +79,6 @@ mount_ufs(argc, argv) struct ufs_args args; int ch, mntflags; char *fs_name; - struct vfsconf vfc; - int error = 0; mntflags = 0; optind = optreset = 1; /* Reset for parse of new argv. */ @@ -109,21 +107,7 @@ mount_ufs(argc, argv) else args.export.ex_flags = 0; - error = getvfsbyname("ufs", &vfc); - 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) { + if (mount("ufs", fs_name, mntflags, &args) < 0) { switch (errno) { case EMFILE: warnx("%s on %s: mount table full", diff --git a/sbin/mount_cd9660/mount_cd9660.c b/sbin/mount_cd9660/mount_cd9660.c index dff7ac84c6e..09be846187d 100644 --- a/sbin/mount_cd9660/mount_cd9660.c +++ b/sbin/mount_cd9660/mount_cd9660.c @@ -90,7 +90,6 @@ main(int argc, char **argv) struct iso_args args; int ch, mntflags, opts; char *dev, *dir, mntpath[MAXPATHLEN]; - struct vfsconf vfc; int error, verbose; mntflags = opts = verbose = 0; @@ -172,17 +171,7 @@ main(int argc, char **argv) printf("using starting sector %d\n", args.ssector); } - error = getvfsbyname("cd9660", &vfc); - 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) + if (mount("cd9660", mntpath, mntflags, &args) < 0) err(1, "%s", args.fspec); exit(0); } diff --git a/sbin/mount_ext2fs/mount_ext2fs.c b/sbin/mount_ext2fs/mount_ext2fs.c index b8aeae340ce..d05a0ff4adc 100644 --- a/sbin/mount_ext2fs/mount_ext2fs.c +++ b/sbin/mount_ext2fs/mount_ext2fs.c @@ -75,8 +75,6 @@ main(argc, argv) struct iovec iov[6]; int ch, mntflags; char *fs_name, *options, *fspec, mntpath[MAXPATHLEN]; - struct vfsconf vfc; - int error; options = NULL; mntflags = 0; @@ -105,21 +103,10 @@ main(argc, argv) (void)checkpath(fs_name, mntpath); (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_len = sizeof("fstype"); - iov[1].iov_base = vfc.vfc_name; - iov[1].iov_len = strlen(vfc.vfc_name) + 1; + iov[1].iov_base = "ext2fs"; + iov[1].iov_len = strlen(iov[1].iov_base) + 1; iov[2].iov_base = "fspath"; iov[2].iov_len = sizeof("fspath"); iov[3].iov_base = mntpath; diff --git a/sbin/mount_hpfs/mount_hpfs.c b/sbin/mount_hpfs/mount_hpfs.c index 1b360cbfd95..67f03399f63 100644 --- a/sbin/mount_hpfs/mount_hpfs.c +++ b/sbin/mount_hpfs/mount_hpfs.c @@ -66,14 +66,9 @@ main(argc, argv) { struct hpfs_args args; 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; 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; (void)memset(&args, '\0', sizeof(args)); @@ -148,35 +143,7 @@ main(argc, argv) args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } -#if __FreeBSD_version >= 300000 - 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 + if (mount("hpfs", dir, mntflags, &args) < 0) err(EX_OSERR, "%s", dev); exit (0); diff --git a/sbin/mount_msdosfs/mount_msdosfs.c b/sbin/mount_msdosfs/mount_msdosfs.c index b70b5b1ff9c..187dc13304c 100644 --- a/sbin/mount_msdosfs/mount_msdosfs.c +++ b/sbin/mount_msdosfs/mount_msdosfs.c @@ -88,9 +88,8 @@ main(argc, argv) { struct msdosfs_args args; 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]; - struct vfsconf vfc; mntflags = set_gid = set_uid = set_mask = 0; (void)memset(&args, '\0', sizeof(args)); @@ -173,17 +172,7 @@ main(argc, argv) args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } - error = getvfsbyname("msdosfs", &vfc); - 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) + if (mount("msdosfs", mntpath, mntflags, &args) < 0) err(EX_OSERR, "%s", dev); exit (0); diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index f0629c2a5d6..825febede1b 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -247,8 +247,6 @@ main(argc, argv) int mntflags, altflags, nfssvc_flag, num; char *name, *p, *spec; char mntpath[MAXPATHLEN]; - struct vfsconf vfc; - int error = 0; mntflags = 0; altflags = 0; @@ -436,17 +434,7 @@ main(argc, argv) /* resolve the mountpoint with realpath(3) */ (void)checkpath(name, mntpath); - error = getvfsbyname("nfs", &vfc); - 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)) + if (mount("nfs", mntpath, mntflags, nfsargsp)) err(1, "%s", mntpath); exit(0); diff --git a/sbin/mount_ntfs/mount_ntfs.c b/sbin/mount_ntfs/mount_ntfs.c index 5269b867a37..dfa68e67f09 100644 --- a/sbin/mount_ntfs/mount_ntfs.c +++ b/sbin/mount_ntfs/mount_ntfs.c @@ -70,13 +70,8 @@ main(argc, argv) { struct ntfs_args args; 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]; -#if __FreeBSD_version >= 300000 - struct vfsconf vfc; -#else - struct vfsconf *vfc; -#endif mntflags = set_gid = set_uid = set_mask = 0; (void)memset(&args, '\0', sizeof(args)); @@ -146,35 +141,7 @@ main(argc, argv) args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } -#if __FreeBSD_version >= 300000 - 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 + if (mount("ntfs", mntpath, mntflags, &args) < 0) err(EX_OSERR, "%s", dev); exit (0); diff --git a/sbin/mount_nullfs/mount_nullfs.c b/sbin/mount_nullfs/mount_nullfs.c index 5af8daa9640..2b0f8e79818 100644 --- a/sbin/mount_nullfs/mount_nullfs.c +++ b/sbin/mount_nullfs/mount_nullfs.c @@ -77,7 +77,6 @@ main(argc, argv) int ch, mntflags; char source[MAXPATHLEN]; char target[MAXPATHLEN]; - struct vfsconf vfc; int error; mntflags = 0; @@ -104,20 +103,10 @@ main(argc, argv) errx(EX_USAGE, "%s (%s) and %s are not distinct paths", 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_len = sizeof("fstype"); - iov[1].iov_base = vfc.vfc_name; - iov[1].iov_len = strlen(vfc.vfc_name) + 1; + iov[1].iov_base = "nullfs"; + iov[1].iov_len = strlen("nullfs") + 1; iov[2].iov_base = "fspath"; iov[2].iov_len = sizeof("fspath"); iov[3].iov_base = source; diff --git a/sbin/mount_nwfs/mount_nwfs.c b/sbin/mount_nwfs/mount_nwfs.c index 8e37b092a58..af00071b927 100644 --- a/sbin/mount_nwfs/mount_nwfs.c +++ b/sbin/mount_nwfs/mount_nwfs.c @@ -76,7 +76,6 @@ main(int argc, char *argv[]) { struct nwfs_args mdata; struct ncp_conn_loginfo li; struct stat st; - struct vfsconf vfc; struct nw_entry_info einfo; struct tm *tm; 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); mntflags = error = 0; diff --git a/sbin/mount_portalfs/mount_portalfs.c b/sbin/mount_portalfs/mount_portalfs.c index c07eed99f52..baad22fffa8 100644 --- a/sbin/mount_portalfs/mount_portalfs.c +++ b/sbin/mount_portalfs/mount_portalfs.c @@ -108,7 +108,6 @@ main(argc, argv) char mountpt[MAXPATHLEN]; int mntflags = 0; char tag[32]; - struct vfsconf vfc; mode_t um; qelem q; @@ -175,17 +174,7 @@ main(argc, argv) sprintf(tag, "portal:%d", getpid()); args.pa_config = tag; - error = getvfsbyname("portalfs", &vfc); - 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); + rc = mount("portalfs", mountpt, mntflags, &args); if (rc < 0) err(1, NULL); diff --git a/sbin/mount_std/mount_std.c b/sbin/mount_std/mount_std.c index 1113e672c17..00421a1e695 100644 --- a/sbin/mount_std/mount_std.c +++ b/sbin/mount_std/mount_std.c @@ -66,7 +66,7 @@ static struct mntopt mopts[] = { { NULL } }; -static const char *fsname; +static char *fsname; static volatile sig_atomic_t caughtsig; static void usage(void) __dead2; @@ -84,7 +84,6 @@ main(argc, argv) { int ch, mntflags; char mntpath[MAXPATHLEN]; - struct vfsconf vfc; struct iovec iov[4]; int error; @@ -120,23 +119,13 @@ main(argc, argv) if (argc != 2) 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) */ (void)checkpath(argv[1], mntpath); iov[0].iov_base = "fstype"; iov[0].iov_len = sizeof("fstype"); - iov[1].iov_base = vfc.vfc_name; - iov[1].iov_len = strlen(vfc.vfc_name) + 1; + iov[1].iov_base = fsname; + iov[1].iov_len = strlen(iov[1].iov_base) + 1; iov[2].iov_base = "fspath"; iov[2].iov_len = sizeof("fstype"); iov[3].iov_base = mntpath; @@ -161,7 +150,7 @@ main(argc, argv) * or the user didn't recompile his kernel. */ if (error && (errno == EOPNOTSUPP || errno == ENOSYS || caughtsig)) - error = mount(vfc.vfc_name, mntpath, mntflags, NULL); + error = mount(fsname, mntpath, mntflags, NULL); if (error) err(EX_OSERR, NULL); diff --git a/sbin/mount_udf/mount_udf.c b/sbin/mount_udf/mount_udf.c index 45a346daea0..057512791b2 100644 --- a/sbin/mount_udf/mount_udf.c +++ b/sbin/mount_udf/mount_udf.c @@ -73,8 +73,7 @@ main(int argc, char **argv) struct iovec iov[6]; int ch, mntflags, opts; char *dev, *dir, mntpath[MAXPATHLEN]; - struct vfsconf vfc; - int error, verbose; + int verbose; mntflags = opts = verbose = 0; while ((ch = getopt(argc, argv, "o:v")) != -1) @@ -109,20 +108,11 @@ main(int argc, char **argv) * UDF filesystems are not writeable. */ 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_len = sizeof("fstype"); - iov[1].iov_base = vfc.vfc_name; - iov[1].iov_len = strlen(vfc.vfc_name) + 1; + iov[1].iov_base = "udf"; + iov[1].iov_len = strlen(iov[1].iov_base) + 1; iov[2].iov_base = "fspath"; iov[2].iov_len = sizeof("fspath"); iov[3].iov_base = mntpath; diff --git a/sbin/mount_umapfs/mount_umapfs.c b/sbin/mount_umapfs/mount_umapfs.c index 82e3efb3f18..06964bf08f9 100644 --- a/sbin/mount_umapfs/mount_umapfs.c +++ b/sbin/mount_umapfs/mount_umapfs.c @@ -101,8 +101,6 @@ main(argc, argv) int ch, count, gnentries, mntflags, nentries; char *gmapfile, *mapfile, buf[20]; char source[MAXPATHLEN], target[MAXPATHLEN]; - struct vfsconf vfc; - int error; mntflags = 0; mapfile = gmapfile = NULL; @@ -227,17 +225,7 @@ main(argc, argv) args.gnentries = gnentries; args.gmapdata = gmapdata; - error = getvfsbyname("umapfs", &vfc); - 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)) + if (mount("umapfs", argv[1], mntflags, &args)) err(1, NULL); exit(0); } diff --git a/sbin/mount_unionfs/mount_unionfs.c b/sbin/mount_unionfs/mount_unionfs.c index 724c9b31cbb..069e4fb10bd 100644 --- a/sbin/mount_unionfs/mount_unionfs.c +++ b/sbin/mount_unionfs/mount_unionfs.c @@ -78,8 +78,7 @@ main(argc, argv) int ch, mntflags; char source[MAXPATHLEN]; char target[MAXPATHLEN]; - struct vfsconf vfc; - int error, iovcnt; + int iovcnt; iovcnt = 6; mntflags = 0; @@ -121,20 +120,10 @@ main(argc, argv) errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths", 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_len = strlen(iov[0].iov_base) + 1; - iov[1].iov_base = vfc.vfc_name; - iov[1].iov_len = strlen(vfc.vfc_name) + 1; + iov[1].iov_base = "unionfs"; + iov[1].iov_len = strlen(iov[1].iov_base) + 1; iov[2].iov_base = "fspath"; iov[2].iov_len = strlen(iov[2].iov_base) + 1; iov[3].iov_base = source; diff --git a/usr.sbin/mount_nwfs/mount_nwfs.c b/usr.sbin/mount_nwfs/mount_nwfs.c index 8e37b092a58..af00071b927 100644 --- a/usr.sbin/mount_nwfs/mount_nwfs.c +++ b/usr.sbin/mount_nwfs/mount_nwfs.c @@ -76,7 +76,6 @@ main(int argc, char *argv[]) { struct nwfs_args mdata; struct ncp_conn_loginfo li; struct stat st; - struct vfsconf vfc; struct nw_entry_info einfo; struct tm *tm; 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); mntflags = error = 0; diff --git a/usr.sbin/mount_portalfs/mount_portalfs.c b/usr.sbin/mount_portalfs/mount_portalfs.c index c07eed99f52..baad22fffa8 100644 --- a/usr.sbin/mount_portalfs/mount_portalfs.c +++ b/usr.sbin/mount_portalfs/mount_portalfs.c @@ -108,7 +108,6 @@ main(argc, argv) char mountpt[MAXPATHLEN]; int mntflags = 0; char tag[32]; - struct vfsconf vfc; mode_t um; qelem q; @@ -175,17 +174,7 @@ main(argc, argv) sprintf(tag, "portal:%d", getpid()); args.pa_config = tag; - error = getvfsbyname("portalfs", &vfc); - 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); + rc = mount("portalfs", mountpt, mntflags, &args); if (rc < 0) err(1, NULL);