Deal with module name changes and autoloading.

This commit is contained in:
Peter Wemm 2001-09-20 02:15:17 +00:00
parent fdccb1e8c9
commit 4a0785aaff
2 changed files with 16 additions and 30 deletions

View File

@ -268,8 +268,7 @@ main(argc, argv)
int udpsock, tcpsock, udp6sock, tcp6sock; int udpsock, tcpsock, udp6sock, tcp6sock;
int xcreated = 0, s; int xcreated = 0, s;
int one = 1; int one = 1;
int c, error, mib[3]; int c, error;
struct vfsconf vfc;
udp6conf = tcp6conf = NULL; udp6conf = tcp6conf = NULL;
udp6sock = tcp6sock = NULL; udp6sock = tcp6sock = NULL;
@ -285,15 +284,11 @@ main(argc, argv)
have_v6 = 0; have_v6 = 0;
else else
close(s); close(s);
error = getvfsbyname("nfs", &vfc); if (modfind("nfsserver") < 0) {
if (error && vfsisloadable("nfs")) { /* Not present in kernel, try loading it */
if(vfsload("nfs")) if (kldload("nfsserver") < 0 || modfind("nfsserver") < 0)
err(1, "vfsload(nfs)"); errx(1, "NFS server is not available or loadable");
endvfsent(); /* flush cache */
error = getvfsbyname("nfs", &vfc);
} }
if (error)
errx(1, "NFS support is not available in the running kernel");
while ((c = getopt(argc, argv, "2dlnr")) != -1) while ((c = getopt(argc, argv, "2dlnr")) != -1)
switch (c) { switch (c) {
@ -377,11 +372,9 @@ main(argc, argv)
skip_v6: skip_v6:
if (!resvport_only) { if (!resvport_only) {
mib[0] = CTL_VFS; if (sysctlbyname("vfs.nfsrv.nfs_privport", NULL, NULL,
mib[1] = vfc.vfc_typenum; &resvport_only, sizeof(resvport_only)) != 0 &&
mib[2] = NFS_NFSPRIVPORT; errno != ENOENT) {
if (sysctl(mib, 3, NULL, NULL, &resvport_only,
sizeof(resvport_only)) != 0 && errno != ENOENT) {
syslog(LOG_ERR, "sysctl: %m"); syslog(LOG_ERR, "sysctl: %m");
exit(1); exit(1);
} }

View File

@ -268,8 +268,7 @@ main(argc, argv)
int udpsock, tcpsock, udp6sock, tcp6sock; int udpsock, tcpsock, udp6sock, tcp6sock;
int xcreated = 0, s; int xcreated = 0, s;
int one = 1; int one = 1;
int c, error, mib[3]; int c, error;
struct vfsconf vfc;
udp6conf = tcp6conf = NULL; udp6conf = tcp6conf = NULL;
udp6sock = tcp6sock = NULL; udp6sock = tcp6sock = NULL;
@ -285,15 +284,11 @@ main(argc, argv)
have_v6 = 0; have_v6 = 0;
else else
close(s); close(s);
error = getvfsbyname("nfs", &vfc); if (modfind("nfsserver") < 0) {
if (error && vfsisloadable("nfs")) { /* Not present in kernel, try loading it */
if(vfsload("nfs")) if (kldload("nfsserver") < 0 || modfind("nfsserver") < 0)
err(1, "vfsload(nfs)"); errx(1, "NFS server is not available or loadable");
endvfsent(); /* flush cache */
error = getvfsbyname("nfs", &vfc);
} }
if (error)
errx(1, "NFS support is not available in the running kernel");
while ((c = getopt(argc, argv, "2dlnr")) != -1) while ((c = getopt(argc, argv, "2dlnr")) != -1)
switch (c) { switch (c) {
@ -377,11 +372,9 @@ main(argc, argv)
skip_v6: skip_v6:
if (!resvport_only) { if (!resvport_only) {
mib[0] = CTL_VFS; if (sysctlbyname("vfs.nfsrv.nfs_privport", NULL, NULL,
mib[1] = vfc.vfc_typenum; &resvport_only, sizeof(resvport_only)) != 0 &&
mib[2] = NFS_NFSPRIVPORT; errno != ENOENT) {
if (sysctl(mib, 3, NULL, NULL, &resvport_only,
sizeof(resvport_only)) != 0 && errno != ENOENT) {
syslog(LOG_ERR, "sysctl: %m"); syslog(LOG_ERR, "sysctl: %m");
exit(1); exit(1);
} }