summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-04-19 14:28:45 +0000
committerpeter <peter@FreeBSD.org>1999-04-19 14:28:45 +0000
commit4bea125ebd87b687c9dc6abc62e41308d82937c7 (patch)
tree829d345f00ea1b8d8befaa9c04346faabbeb1786 /lib
parent725616780f5038b63e9b282f9a49c2ede2b46ceb (diff)
downloadFreeBSD-src-4bea125ebd87b687c9dc6abc62e41308d82937c7.zip
FreeBSD-src-4bea125ebd87b687c9dc6abc62e41308d82937c7.tar.gz
vfsload maps into kldload only now, no more fork/exec of modload(8).
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/getvfsent.c86
1 files changed, 1 insertions, 85 deletions
diff --git a/lib/libc/gen/getvfsent.c b/lib/libc/gen/getvfsent.c
index 8aa147d..bf3ca20 100644
--- a/lib/libc/gen/getvfsent.c
+++ b/lib/libc/gen/getvfsent.c
@@ -21,8 +21,6 @@
#undef getvfsbyname
#define vfsconf ovfsconf
-#define _PATH_MODLOAD "/sbin/modload" /* XXX should be in header file */
-
static struct vfsconf *_vfslist = 0;
static struct vfsconf _vfsconf;
static size_t _vfslistlen = 0;
@@ -162,100 +160,18 @@ endvfsent(void)
_vfs_index = 0;
}
-static const char *vfs_lkmdirs[] = {
- "/lkm",
- "/usr/lkm",
- 0,
- 0
-};
-#define NLKMDIRS ((sizeof vfs_lkmdirs) / (sizeof vfs_lkmdirs[0]))
-
-static const char *
-vfspath(const char *name)
-{
- static char pnbuf[MAXPATHLEN];
- char *userdir = getenv("LKMDIR");
- int i;
-
- if(userdir && getuid() == geteuid() && getuid() == 0) {
- vfs_lkmdirs[NLKMDIRS - 2] = userdir;
- }
-
- for(i = 0; vfs_lkmdirs[i]; i++) {
- snprintf(pnbuf, sizeof pnbuf, "%s/%s_mod.o", vfs_lkmdirs[i], name);
- if( ! access(pnbuf, R_OK) )
- return pnbuf;
- }
-
- return 0;
-}
-
int
vfsisloadable(const char *name)
{
-#if 0
- int fd;
-
- fd = open("/dev/lkm", O_RDWR, 0);
- if(fd < 0) {
- return 0;
- }
- close(fd);
-
- return !!vfspath(name);
-#else
return 1;
-#endif
}
int
vfsload(const char *name)
{
- const char *path;
- char name_mod[sizeof("_mod") + strlen(name)];
- pid_t pid;
int status;
status = kldload(name);
- if (status != -1)
- return 0;
-
- path = vfspath(name);
- if(!path) {
- errno = ENOENT;
- return -1;
- }
-
- pid = fork();
- if(pid < 0)
- return -1;
-
- if(pid > 0) {
- waitpid(pid, &status, 0);
- if(WIFEXITED(status)) {
- errno = WEXITSTATUS(status);
- return errno ? -1 : 0;
- }
- errno = EINVAL; /* not enough errno values, >sigh< */
- return -1;
- }
-
- status = -1;
- unsetenv("TMPDIR");
- if(status) {
- status = chdir(_PATH_VARTMP);
- }
- if(status) {
- status = chdir(_PATH_TMP);
- }
- if(status) {
- exit(errno);
- }
-
- snprintf(name_mod, sizeof name_mod, "%s%s", name, "_mod");
- status = execl(_PATH_MODLOAD, "modload", "-e", name_mod, "-o",
- name_mod, "-u", "-q", path, (const char *)0);
-
- exit(status ? errno : 0);
+ return status == -1 ? status : 0;
}
OpenPOWER on IntegriCloud