[PATCH] Update mk-s390-cdboot.c to work with large kernel images (#184648)

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

 



IBM's update to mk-s390-cdboot.c to support large kernel images and
large initrd images.
---
 utils/mk-s390-cdboot.c |   47 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/utils/mk-s390-cdboot.c b/utils/mk-s390-cdboot.c
index 99d4fef..4a58258 100644
--- a/utils/mk-s390-cdboot.c
+++ b/utils/mk-s390-cdboot.c
@@ -122,7 +122,8 @@ int main (int argc, char **argv) {
 
     printf("writing kernel...\n");
     while (1) {
-        rc = fread(buffer, BUFFER_LEN, 1, fd2);
+        rc = fread(buffer, 1, 1, fd2);
+
         if (rc == 0) {
             break;
         }
@@ -132,17 +133,23 @@ int main (int argc, char **argv) {
             abort();
         }
 
-        wc = fwrite(buffer, BUFFER_LEN, 1, fd1);
+        wc = fwrite(buffer, 1, 1, fd1);
         if (feof(fd1) || ferror(fd1)) {
             fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
             abort();
         }
+
+        if (wc != rc) {
+          fprintf(stderr, "could only write %i of %i bytes of kernel\n",
+                  wc, rc);
+        }
     }
 
     printf("writing initrd...\n");
     fseek(fd1, initrd_start, SEEK_SET);
     while (1) {
-        rc = fread(buffer, BUFFER_LEN, 1, fd3);
+        rc = fread(buffer, 1, 1, fd3);
+
         if (rc == 0) {
             break;
         }
@@ -152,11 +159,16 @@ int main (int argc, char **argv) {
             abort();
         }
 
-        wc = fwrite(buffer, BUFFER_LEN, 1, fd1);
+        wc = fwrite(buffer, 1, 1, fd1);
         if (feof(fd1) || ferror(fd1)) {
             fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
             abort();
         }
+
+        if (wc != rc) {
+          fprintf(stderr, "could only write %i of %i bytes of initrd\n",
+                  wc, rc);
+        }
     }
 
     if (fseek(fd3, 0, SEEK_END) == -1) {
@@ -175,12 +187,17 @@ int main (int argc, char **argv) {
         abort();
     }
 
-    wc = fwrite(&start_psw_address, 4, 1, fd1);
+    wc = fwrite(&start_psw_address, 1, 4, fd1);
     if (feof(fd1) || ferror(fd1)) {
         fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
         abort();
     }
 
+    if (wc != 4) {
+        fprintf(stderr, "could only write %i of %i bytes of PSW address\n",
+                wc, 4);
+    }
+
     printf("writing initrd address and size...\n");
     printf("INITRD start: 0x%016llx\n",  initrd_start);
     printf("INITRD size : 0x%016llx\n", initrd_size);
@@ -190,23 +207,33 @@ int main (int argc, char **argv) {
         abort();
     }
 
-    wc = fwrite(&initrd_start, 8, 1, fd1);
+    wc = fwrite(&initrd_start, 1, 8, fd1);
     if (feof(fd1) || ferror(fd1)) {
         fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
         abort();
     }
 
+    if (wc != 8) {
+        fprintf(stderr, "could only write %i of %i bytes of INITRD start\n",
+                wc, 8);
+    }
+
     if (fseek(fd1, 0x10410, SEEK_SET) == -1) {
         fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
         abort();
     }
 
-    wc = fwrite(&initrd_size, 8, 1, fd1);
+    wc = fwrite(&initrd_size, 1, 8, fd1);
     if (feof(fd1) || ferror(fd1)) {
         fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
         abort();
     }
 
+    if (wc != 8) {
+        fprintf(stderr, "could only write %i of %i bytes of INITRD size\n",
+                wc, 8);
+    }
+
     printf("writing parmfile...\n");
     if (fseek(fd1, 0x10480, SEEK_SET) == -1) {
         fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
@@ -215,6 +242,7 @@ int main (int argc, char **argv) {
 
     while (1) {
         rc = fread(buffer, 1, 1, fd4);
+
         if (rc == 0) {
             break;
         }
@@ -229,6 +257,11 @@ int main (int argc, char **argv) {
             fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
             abort();
         }
+
+        if (wc != 1) {
+            fprintf(stderr, "could only write %i of %i bytes of parmfile\n",
+                    wc, 1);
+        }
     }
 
     if (fclose(fd1) == EOF) {
-- 
1.6.0.3

_______________________________________________
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