Re: loop-AES: passing command line arguments to init [patch]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martin Godisch wrote:
> I'd like to introduce a patch for loop-AES-v2.0d. The patch requires diet
> libc [1] in order to pass linuxrc command line arguments (non-kernel boot
> parameters, e.g. runlevel selection) to init. It doesn't require diet libc
> to be present, everything should work as before if it isn't. The resulting
> binary (linked against diet libc) is nearly 1k smaller than the one linked
> with -nostartfiles.

How about this one? Your patch had little bit messed up parameter and
environment processing. This version simply copies what kernel passed to
linuxrc and passes them directly to init. This version also includes the
insmod.modutils patch that you sent me earlier.

When sending patches for loop-AES, please CC me if you want me to see them.
I'm usually subscribed to linux-crypto list, but every now and then I get
silently dropped from the list.  :(

-- 
Jari Ruusu  1024R/3A220F51 5B 4B F9 BB D3 3F 52 E9  DB 1D EB E3 24 0E A9 DD


--- ../loop-AES-v2.0d/build-initrd.sh	Thu Nov 20 15:56:39 2003
+++ build-initrd.sh	Sun Dec 28 19:26:22 2003
@@ -2,7 +2,7 @@
 #
 #  build-initrd.sh
 #
-#  Written by Jari Ruusu, November 20 2003
+#  Written by Jari Ruusu, December 28 2003
 #
 #  Copyright 2001,2002,2003 by Jari Ruusu.
 #  Redistribution of this file is permitted under the GNU Public License.
@@ -170,6 +170,11 @@
 # If enabled, rootsetup program (+libs) _must_ be manually copied to /boot.
 USEROOTSETUP=0
 
+# 1 = use diet libc to pass linuxrc arguments (e.g. runlevel) to init
+# 0 = if you don't have diet libc
+# The diet libc can be found at http://www.fefe.de/dietlibc/
+USEDIETLIBC=0
+
 # 1 = load extra module, 0 = don't load
 # If this is enabled, module must be manually copied to
 # /boot/modules-KERNELRELEASE/ directory under name like foomatic.o
@@ -267,8 +272,14 @@
 # define HaltKernel() reboot(0xfee1dead, 672274793, 0xCDEF0123)
 #endif
 
+#if ${USEDIETLIBC}
+static char ** argv_init;
+static char ** envp_init;
+extern char ** environ;
+#else
 static char * argv_init[] = { "init", 0, };
 static char * envp_init[] = { "HOME=/", "TERM=linux", 0, };
+#endif
 
 void strCat(char *d, char *s)
 {
@@ -337,12 +348,21 @@
     doHalt();
 }
 
+#if ${USEDIETLIBC}
+int main(int argc, char **argv)
+#else
 void _start()
+#endif
 {
     int x = 0;
     struct utsname un;
     char buf[300];
 
+#if ${USEDIETLIBC}
+    argv_init = argv;
+    envp_init = environ;
+#endif
+
 #if ${USEPIVOT}
     if(getpid() != 1) {
         /* pivot_root was configured, but kernel has */
@@ -536,7 +556,11 @@
 }
 EOF
 
-gcc -Wall -O2 -s -static -nostartfiles -pipe tmp-c-$$.c -o tmp-c-$$
+if [ ${USEDIETLIBC} == 1 ] ; then
+    diet gcc -Wall -O2 -s -static -pipe tmp-c-$$.c -o tmp-c-$$
+else
+    gcc -Wall -O2 -s -static -nostartfiles -pipe tmp-c-$$.c -o tmp-c-$$
+fi
 rm -f tmp-c-$$.[co]
 
 x=`cat tmp-c-$$ | wc -c`
@@ -659,6 +683,9 @@
 z="/sbin/losetup"
 if [ ${USEMODULE}${EXTRAMODULELOAD1}${EXTRAMODULELOAD2}${EXTRAMODULELOAD3}${EXTRAMODULELOAD4}${EXTRAMODULELOAD5} != 000000 ] ; then
     z="${z} /sbin/insmod"
+    if [ -r ${SOURCEROOT}/sbin/insmod.modutils ] ; then
+        z="${z} /sbin/insmod.modutils"
+    fi
     if [ -r ${SOURCEROOT}/sbin/insmod.old ] ; then
         z="${z} /sbin/insmod.old"
     fi
-
Linux-crypto:  cryptography in and on the Linux system
Archive:       http://mail.nl.linux.org/linux-crypto/



[Index of Archives]     [Kernel]     [Linux Crypto]     [Gnu Crypto]     [Gnu Classpath]     [Netfilter]     [Bugtraq]
  Powered by Linux