int size;
struct image_type_params *tparams = imagetool_get_type(params.type);
- if (pad >= sizeof(zeros)) {
- fprintf(stderr, "%s: Can't pad to %d\n",
- params.cmdname, pad);
- exit(EXIT_FAILURE);
- }
-
memset(zeros, 0, sizeof(zeros));
if (params.vflag) {
exit (EXIT_FAILURE);
}
} else if (pad > 1) {
- if (write(ifd, (char *)&zeros, pad) != pad) {
- fprintf(stderr, "%s: Write error on %s: %s\n",
- params.cmdname, params.imagefile,
- strerror(errno));
- exit(EXIT_FAILURE);
+ while (pad > 0) {
+ int todo = sizeof(zeros);
+
+ if (todo > pad)
+ todo = pad;
+ if (write(ifd, (char *)&zeros, todo) != todo) {
+ fprintf(stderr, "%s: Write error on %s: %s\n",
+ params.cmdname, params.imagefile,
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ pad -= todo;
}
}