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

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



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

diff --git a/utils/mk-s390-cdboot.c b/utils/mk-s390-cdboot.c
index 99d4fef..a9484cf 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,22 @@ 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 +158,15 @@ 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,11 +185,15 @@ 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);
@@ -190,22 +204,29 @@ 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) {
@@ -215,6 +236,7 @@ int main (int argc, char **argv) {
 
     while (1) {
         rc = fread(buffer, 1, 1, fd4);
+
         if (rc == 0) {
             break;
         }
@@ -229,6 +251,10 @@ 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.2


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