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@ixolution.de>
<v.dormeyer@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;
Volker Dormeyer wrote:> > /* if partition is within range - we got it */ > if (part < range) > - return res + part; > + return (res << 8) + part; >This seems very wrong... -hpa
On Tue, Mar 09, 2004 at 08:26:15PM -0800, H. Peter Anvin <hpa@zytor.com> wrote: > Volker Dormeyer wrote: > > > > /* if partition is within range - we got it */ > > if (part < range) > >- return res + part; > >+ return (res << 8) + part; > > This seems very wrong... try_name () determined "part" with minor 3 and "res" contained major 3. Now, try_name () returned "6" and mknod () created /dev/root with major 0 and minor 6. I did a left shift of 8 bits, to give mknod () an appropriate 16 bit value of type dev_t. Hmm, I was not sure here. Does it break other setups? I thought this could be a problem in other setups, too. Regards, Volker
Volker Dormeyer wrote:> > try_name () determined "part" with minor 3 and "res" contained major 3. > Now, try_name () returned "6" and mknod () created /dev/root with > major 0 and minor 6. I did a left shift of 8 bits, to give mknod () an > appropriate 16 bit value of type dev_t. >NO NO NO NO NO NO NO NO NO NO NO NO NO... First of all, dev_t is 32 bits not 16. Use makedev() to create one. Second, if that is the case then there is many more places in that code which need fixing...> Hmm, I was not sure here. Does it break other setups? I thought this could > be a problem in other setups, too.It may be, but your code is wrong. -hpa
On Wed, Mar 10, 2004 at 10:28:30AM -0800, H. Peter Anvin <hpa@zytor.com> wrote: > Volker Dormeyer wrote: > > > >try_name () determined "part" with minor 3 and "res" contained major 3. > >Now, try_name () returned "6" and mknod () created /dev/root with > >major 0 and minor 6. I did a left shift of 8 bits, to give mknod () an > >appropriate 16 bit value of type dev_t. > > > > NO NO NO NO NO NO NO NO NO NO NO NO NO... > > First of all, dev_t is 32 bits not 16. Use makedev() to create one. Ah, I will see what I can do. It seems that using makedev () means some additional changes in do_mounts.c. Regards Volker -- Volker Dormeyer <volker@ixolution.de>