[klibc] [PATCH] kinit

Volker Dormeyer volker at ixolution.de
Wed Mar 10 00:45:05 PST 2004


Hello all,

I experienced some problems with "kinit". It had problems to determine my
root device (/dev/hda3) and to create /dev/root with the appropriate major
and minor device number. I don't use udev or devfs on this system so far.

The patch I wrote to solve it is attached to this email.

I would like to extend "kinit" a bit:

  * Removing the pivot_root stuff and instead mount the real root over the
    initramfs root. Whereas the initramfs has to be cleaned up before.

  * Allow a user to load some kernel modules by kinit. I mean the modules
    could be located in some kind of config file like /etc/kinit.modules or
    something like that.

  * Another thing I am thinking about is to call a user defined script from
    within kinit to allow a user to do some user defined stuff. Like
    initialising volume groups and so on without replacing kinit
    completely.

I think "kinit" could be quite convinient, then.
What do you think about this? Any comments?

Regards,
Volker

-- 
 Volker Dormeyer	<volker at ixolution.de>
			<v.dormeyer at t-online.de>
-------------- next part --------------
--- klibc-0.115_dev/kinit/kinit.c	2003-06-01 08:18:41.000000000 +0200
+++ klibc-0.115/kinit/kinit.c	2004-03-10 00:12:08.000000000 +0100
@@ -182,7 +182,7 @@ char *get_arg(int argc, char *argv[], co
 
 	for (i = 1; i < argc; i++) {
 		if (argv[i] && strncmp(argv[i], name, len) == 0 &&
-		    (argv[i][len] == '\0')) {
+		    (argv[i][len] != '\0')) {
 			ret = argv[i] + len;
 			break;
 		}
--- klibc-0.115_dev/kinit/do_mounts.c	2003-06-01 08:21:09.000000000 +0200
+++ klibc-0.115/kinit/do_mounts.c	2004-03-10 00:11:55.000000000 +0100
@@ -24,7 +24,7 @@ try_name(char *name, int part)
 	char buf[BUF_SZ];
 	int range;
 	dev_t res;
-	char *s;
+	char *s, *p;
 	int len;
 	int fd;
 
@@ -39,6 +39,11 @@ try_name(char *name, int part)
 	if (len <= 0 || len == BUF_SZ || buf[len - 1] != '\n')
 		goto fail;
 	buf[len - 1] = '\0';
+
+	for (p = buf; *p; p++) {
+	  if (*p == ':')
+	    *p = '\0';
+	}
 	res = (dev_t) strtoul(buf, &s, 16);
 	if (*s)
 		goto fail;
@@ -63,7 +68,7 @@ try_name(char *name, int part)
 
 	/* if partition is within range - we got it */
 	if (part < range)
-		return res + part;
+		return (res << 8) + part;
 
 fail:
 	return (dev_t) 0;


More information about the klibc mailing list