Re: Problem with ksmbfs

Steven N. Hirsch (hirsch@uvm-gen.emba.uvm.edu)
Sat, 06 Apr 1996 22:26:21 -0500


This is a multi-part message in MIME format.

--------------1261E760202849EE6ABBAEC2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Bjorn Ekwall wrote:
>
> Brian R. Doherty <doherty@rice.edu> wrote:
> >
> > When I attempt to mount a SMB filesystem with smbmount without first
> > modprobing the smbfs module, I get:
> >
> > Cannot open /lib/modules/1.3.82/smbfs.o
> > Error: Unable to start smbfs, exiting...
> >
> > I am running kerneld and have kerneld support built into the kernel.
> > smbfs.o is in /lib/modules/1.3.82/fs, and it modprobes fine. Why can't
> > kerneld / smbmount find the module?
>
> The error message comes from smbmount, not kerneld.
>
> Actually, smbmount is trying to outsmart kerneld by attempting to insmod
> the smbfs module all by itself. Unfortunately it looks in the wrong
> directory: "/lib/modules/1.3.82" instead of "/lib/modules/1.3.82/fs".
>
> I suggest that you either fix smbmount so that it looks in the _right_
> directory, or just remove the insmod call from smbmount completely...
>
> Cheers,
>
> Bjorn <bj0rn@blox.se>

Actually, I fixed this about 2 months ago and sent Volker Lendecke a patch. Not
sure why it never propogated.

Try the patch attached to this posting, and let me know if that fixes things?

- Steve

-- 
___________________________________________________________
|Steven N. Hirsch	"Anything worth doing is worth     |
|University of Vermont	 overdoing.." - Hunter S. Thompson |
|Computer Science / EE                                     |
------------------------------------------------------------

--------------1261E760202849EE6ABBAEC2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ksmbfs-patch"

Volker,

I have recently started using kerneld with Linux 1.3.57 to autoload needed modules, and noticed that "smbmount" would fail with a complaint from insmod that it couldn't locate smbfs.o. Oddly, invoking insmod (or modprobe) directly worked fine. On closer inspection, it seemed that insmod was looking in the wrong directory (/lib/modules/1.3.57 rather than /lib/modules/1.3.57/fs). After a bit of detective work, I discovered that you are directly passing a fully-formed pathname to insmod, and that this forces a bypass of its normal default path search! Since the exact location of smbfs.o may vary from system to system may I suggest some changes?

- The simplest fix is to just pass "smbfs" to insmod, as newer versions can flesh this out in an intelligent manner. This also permits removal of the kernel version test code.

- Alternately, leave all the module loading mechanics to kerneld and do not worry about testing for smbfs or loading it.

I include some patches which address both approaches. If a user is using kerneld, just uncomment "-DHAVE_KERNELD" in the makefile. Please let me know if this makes sense to you?

*** Makefile.orig Mon Dec 11 03:16:41 1995 --- Makefile Sat Jan 20 19:10:14 1996 *************** *** 5,10 **** --- 5,15 ---- UTILS = $(BINDIR)/smbmount $(BINDIR)/smbumount CFLAGS = -Wall $(INCLUDES) -O2 + + # If you are using kerneld to autoload smb support, + # uncomment this: + # CFLAGS += -DHAVE_KERNELD + CC = gcc all: $(UTILS) *** smbmount.c.orig Mon Dec 11 03:42:46 1995 --- smbmount.c Sat Jan 20 19:11:33 1996 *************** *** 3,8 **** --- 3,20 ---- * * Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke * + * 1/20/96 - Steven N. Hirsch (hirsch@emba.uvm.edu) + * + * If the smbfs support is not loaded and we are using kerneld to + * autoload modules, then we don't want to do it here. I added + * a conditional which leaves out the test and load code. + * + * Even if we _do_ want smbmount to load the module, passing a + * fully-qualified pathname to insmod causes it to bypass a + * path search. This may lead to smbfs.o not being found on + * some systems. + * + * */ #include <stdio.h> *************** *** 292,305 **** return strdup(path); } /* Returns 0 if the filesystem is in the kernel after this routine completes */ static int load_smbfs() { ! FILE *fver, *ffs; char s[1024]; - char modname[1024]; char *p, *p1; pid_t pid; int status; --- 304,318 ---- return strdup(path); } + #ifndef HAVE_KERNELD + /* Returns 0 if the filesystem is in the kernel after this routine completes */ static int load_smbfs() { ! FILE *ffs; char s[1024]; char *p, *p1; pid_t pid; int status; *************** *** 324,351 **** if (p) { return 0; } - fver = fopen("/proc/version", "r"); - if (fver == NULL) { - perror("Error: \"/proc/version\" could not be read:"); - return -1; - } - fgets(s, 1024, fver); - fclose(fver); - p = strstr(s, "version "); - if (p == NULL) { - version_error: - fprintf(stderr, "Error: Unable to determine the Linux version" - "from \"/proc/version\n"); - return -1; - } - p = strchr(p, ' ') + 1; - p1 = strchr(p, ' '); - if (p1 == NULL) { - goto version_error; - } - strcpy(modname, "/lib/modules/"); - strncat(modname, p, p1 - p); - strcat(modname, "/smbfs.o"); /* system() function without signal handling, from Stevens */ --- 337,342 ---- *************** *** 353,359 **** return 1; } else if (pid == 0) { /* child */ ! execl("/sbin/insmod", "insmod", modname, NULL); _exit(127); /* execl error */ } else { /* parent */ --- 344,350 ---- return 1; } else if (pid == 0) { /* child */ ! execl("/sbin/insmod", "insmod", "smbfs", NULL); _exit(127); /* execl error */ } else { /* parent */ *************** *** 367,372 **** --- 358,365 ---- return status; } + #endif + /* Check whether user is allowed to mount on the specified mount point */ static int mount_ok(struct stat *st) *************** *** 471,483 **** return 0; } /* Check if the smbfs filesystem is in the kernel. If not, attempt * to load the smbfs module */ if (load_smbfs() != 0) { fprintf(stderr, "Error: Unable to start smbfs, exiting...\n"); exit(1); } ! data.addr.sin_family = AF_INET; data.addr.sin_addr.s_addr = ((struct in_addr *)(h->h_addr))->s_addr; data.addr.sin_port = htons(SMB_PORT); --- 464,477 ---- return 0; } + #ifndef HAVE_KERNELD /* Check if the smbfs filesystem is in the kernel. If not, attempt * to load the smbfs module */ if (load_smbfs() != 0) { fprintf(stderr, "Error: Unable to start smbfs, exiting...\n"); exit(1); } ! #endif data.addr.sin_family = AF_INET; data.addr.sin_addr.s_addr = ((struct in_addr *)(h->h_addr))->s_addr; data.addr.sin_port = htons(SMB_PORT);