Subject: [patch]: minor addinitrd.c cleanup

From: Guido Guenther <[email-masked]>
Date: Sun, 14 Apr 2002 17:04:56 +0200

Hi,
patch makes sure we:
 - don't overwrite an existing .data section in the ecoff
 - opens the original kernel image read only
applies to 2.4 as well as 2.5.
 -- Guido
Index: arch/mips/boot/addinitrd.c
===================================================================
RCS file: /cvs/linux/arch/mips/boot/addinitrd.c,v
retrieving revision 1.1.6.1
diff -u -u -r1.1.6.1 addinitrd.c
--- arch/mips/boot/addinitrd.c	2001/12/13 21:22:23	1.1.6.1
+++ arch/mips/boot/addinitrd.c	2002/04/14 14:59:50
@@ -2,6 +2,8 @@
  * addinitrd - program to add a initrd image to an ecoff kernel
  *
  * (C) 1999 Thomas Bogendoerfer
+ *     2002 Guido Guenther <[email-masked]>
+ *
  */
 
 #include <sys/types.h>
@@ -54,7 +56,7 @@
 		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");
@@ -65,7 +67,10 @@
 	/*
 	 * check whether the file is good for us
 	 */
-	/* TBD */
+	if( eaout.dsize || esecs[1].s_size ) {
+		fprintf(2,".data section not empty. Giving up!\n");
+		exit(1);
+	}
 
 	/*
 	 * check, if we have to swab words