[PATCH] Generate correct initrd.addrsize file for System z (#647827)

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

 



The previous fix just updated the generic.ins files, but that was not
enough.  We also needed to modify geninitrdsz.c to compute the size of
the initrd.img file and add that to the initrd.addrsize file.  Get the
load address from the generic.ins file.
---
 bootdisk/s390/generic.ins  |    2 +-
 bootdisk/s390x/generic.ins |    2 +-
 scripts/mk-images.s390     |    6 +++---
 utils/geninitrdsz.c        |   42 +++++++++++++++++++++++++++++++-----------
 4 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/bootdisk/s390/generic.ins b/bootdisk/s390/generic.ins
index 2f513db..b991dfd 100644
--- a/bootdisk/s390/generic.ins
+++ b/bootdisk/s390/generic.ins
@@ -2,4 +2,4 @@
 images/kernel.img 0x00000000
 images/initrd.img 0x02000000
 images/generic.prm 0x00010480
-images/initrd.size 0x00010408
+images/initrd.addrsize 0x00010408
diff --git a/bootdisk/s390x/generic.ins b/bootdisk/s390x/generic.ins
index 2f513db..b991dfd 100644
--- a/bootdisk/s390x/generic.ins
+++ b/bootdisk/s390x/generic.ins
@@ -2,4 +2,4 @@
 images/kernel.img 0x00000000
 images/initrd.img 0x02000000
 images/generic.prm 0x00010480
-images/initrd.size 0x00010408
+images/initrd.addrsize 0x00010408
diff --git a/scripts/mk-images.s390 b/scripts/mk-images.s390
index 9dff2de..afb616e 100644
--- a/scripts/mk-images.s390
+++ b/scripts/mk-images.s390
@@ -8,8 +8,8 @@ makeBootImages() {
 	    --initrdsize 20000 \
 	    --loaderbin loader \
 	    --modules "$INITRDMODS $S390MODS"
-	sz=$(ls -l $TOPDESTPATH/images/initrd.img | awk '{print $5}')
-	$GENINITRDSZ $sz $TOPDESTPATH/images/initrd.size
+	addr=$(grep "/initrd.img" $BOOTDISKDIR/generic.ins | cut -d ' ' -f 2)
+	$GENINITRDSZ $addr $TOPDESTPATH/images/initrd.img $TOPDESTPATH/images/initrd.addrsize
 	cp -vf $KERNELROOT/boot/${KERNELNAME}-${version} $TOPDESTPATH/images/kernel.img
 
 	cp -v $BOOTDISKDIR/generic.prm $TOPDESTPATH/images/generic.prm
@@ -26,7 +26,7 @@ makeBootImages() {
 [images-$KERNELARCH]
 kernel = images/kernel.img
 initrd = images/initrd.img
-initrd.size = images/initrd.size
+initrd.addrsize = images/initrd.addrsize
 generic.prm = images/generic.prm
 generic.ins = generic.ins
 cdboot.img = images/cdboot.img
diff --git a/utils/geninitrdsz.c b/utils/geninitrdsz.c
index 01d1cf1..ed7caab 100644
--- a/utils/geninitrdsz.c
+++ b/utils/geninitrdsz.c
@@ -1,7 +1,7 @@
 /*
- * Generate initrd.size file for zSeries platforms.
+ * Generate initrd.addrsize file for zSeries platforms.
  * Takes an integer argument and writes out the binary representation of
- * that value to the initrd.size file.
+ * that value to the initrd.addrsize file.
  * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=197773
  */
 
@@ -17,27 +17,47 @@
 #include <string.h>
 
 int main(int argc,char **argv) {
+    char *prog = basename(argv[0]);
+    struct stat initrd_sbuf;
     unsigned int zero = 0;
-    int fd;
-    unsigned int size;
+    unsigned int addr, size;
+    int fd, rc;
+    char *tmp;
     mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
 
-    if (argc != 3) {
-        printf("Usage: %s [integer size] [output file]\n", basename(argv[0]));
-        printf("Example: %s 12288475 initrd.size\n", basename(argv[0]));
+    if (argc != 4) {
+        printf("Usage: %s [address] [initrd file] [output file]\n", prog);
+        printf("Example: %s 0x2000000 initrd.img initrd.addrsize\n", prog);
         return 0;
     }
 
-    size = htonl(atoi(argv[1]));
-    fd = open(argv[2], O_CREAT | O_RDWR, mode);
+    rc = stat(argv[2], &initrd_sbuf);
+    if (rc) {
+        perror("Error getting initrd stats ");
+        return rc;
+    }
+
+    addr = htonl(strtoul(argv[1], &tmp, 0));
+    size = htonl(initrd_sbuf.st_size);
+    fd = open(argv[3], O_CREAT | O_RDWR, mode);
+
+    if (write(fd, &zero, sizeof(int)) == -1) {
+        perror("writing first zero");
+        return errno;
+    }
+
+    if (write(fd, &addr, sizeof(int)) == -1) {
+        perror("writing addr");
+        return errno;
+    }
 
     if (write(fd, &zero, sizeof(int)) == -1) {
-        perror("writing initrd.size (zero)");
+        perror("writing second zero");
         return errno;
     }
 
     if (write(fd, &size, sizeof(int)) == -1) {
-        perror("writing initrd.size (size)");
+        perror("writing size");
         return errno;
     }
 
-- 
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux