Re: daemon-less kmod & Alpha no-go!

Steven N. Hirsch (shirsch@ibm.net)
Mon, 20 Apr 1998 21:06:30 -0400 (EDT)


On Mon, 20 Apr 1998, Greg Zornetzer wrote:

> Hi Steven,
>
> Can you check if the waitpid() call in request_module is actually causing
> a wait, or if it is just being ignored? Happened to some code that I was
> writing very similar to the daemonless kmod patch.

Ok, here's what I used for testing.

echo "/root/kmod_test/kmod_test" > /proc/sys/kernel/modprobe

where kmod_test is this little snippet of do-nothing code:

-------------( cut here )------------------------------

#include <stdlib.h>
#include <stdio.h>

#include <unistd.h>
#include <syslog.h>

int
main ( int argc, char **argv )
{
char msg[128];
int i;

sprintf(msg, "kmod_test: Invoked as \"kmod_test");

for (i=1; i<argc; i++) {
strcat(msg, " ");
strcat(msg, argv[i]);
}

strcat(msg, "\"\n\n");
syslog(LOG_NOTICE, "%s", msg);

syslog(LOG_NOTICE, "uid = %d\n", getuid());
syslog(LOG_NOTICE, "gid = %d\n\n", getgid());

syslog(LOG_NOTICE, "Sleeping for 5 seconds...");

sleep(5);

syslog(LOG_NOTICE, "Done!\n");

return 0;
}

------------( cut here )------------------------------

plus, this little patch to kmod.c:

--- kmod.c.orig Mon Apr 20 19:56:45 1998
+++ kmod.c Mon Apr 20 20:02:41 1998
@@ -91,7 +91,9 @@
printk(KERN_ERR "kmod: fork failed, errno %d\n", -pid);
return pid;
}
+ printk (KERN_ERR "kmod: About to wait on pid %d\n", pid);
waitpid_result = waitpid(pid, NULL, 0);
+ printk (KERN_ERR "kmod: Done waiting on pid %d\n", pid);
if (waitpid_result != pid) {
printk (KERN_ERR "kmod: waitpid(%d,NULL,0) failed, returning %d.\n",
pid, waitpid_result);

------------------------------------------------------

Here are the results from the logs after trying:

$ mount -t vfat /dev/sda1 /dosC

Apr 20 20:55:14 alpha kernel: kmod: About to wait on pid 425
Apr 20 20:55:14 alpha kmod_test: kmod_test: Invoked as "kmod_test -s -k vfat"
Apr 20 20:55:14 alpha kmod_test: uid = 0
Apr 20 20:55:14 alpha kmod_test: gid = 0
Apr 20 20:55:14 alpha kmod_test: Sleeping for 5 seconds...

(ZZZzzzzz)

Apr 20 20:55:19 alpha kmod_test: Done!
Apr 20 20:55:19 alpha kernel: kmod: Done waiting on pid 425

>From my analysis, it looks like:

a) The fake modprobe utility is getting called with the correct arguments
and credentials.

b) wait() is really, truly waiting.

What to try next? Remember, this kernel works just fine with the stock
2.1.97 kmod.

Steve

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu