vserver 1.9.5.x5
[linux-2.6.git] / arch / mips / boot / addinitrd.c
index 38261f1..8b30333 100644 (file)
@@ -2,6 +2,8 @@
  * addinitrd - program to add a initrd image to an ecoff kernel
  *
  * (C) 1999 Thomas Bogendoerfer
+ * minor modifications, cleanup: Guido Guenther <agx@sigxcpu.org>
+ * further cleanup: Maciej W. Rozycki
  */
 
 #include <sys/types.h>
@@ -54,7 +56,7 @@ int main (int argc, char *argv[])
                exit (1);
        }
 
-       if ((fd_vmlinux = open (argv[1],O_RDWR)) < 0)
+       if ((fd_vmlinux = open (argv[1],O_RDONLY)) < 0)
                 die ("open vmlinux");
        if (read (fd_vmlinux, &efile, sizeof efile) != sizeof efile)
                die ("read file header");
@@ -78,6 +80,11 @@ int main (int argc, char *argv[])
                        swab = 1;
        }
 
+       /* make sure we have an empty data segment for the initrd */
+       if (eaout.dsize || esecs[1].s_size) {
+               fprintf (stderr, "Data segment not empty. Giving up!\n");
+               exit (1);
+       }
        if ((fd_initrd = open (argv[2], O_RDONLY)) < 0)
                die ("open initrd");
        if (fstat (fd_initrd, &st) < 0)