X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/19021c16ffef5393aebedf009c57a86b11b996c2..bee264713c3605130894f9eb4c166d7f729a25a7:/tools/firmware-utils/src/ptgen.c diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index 2d78eae53..d94aabb5f 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -114,7 +114,7 @@ static void to_chs(long sect, unsigned char chs[3]) { static inline unsigned long round_to_cyl(long sect) { int cyl_size = heads * sectors; - return sect + cyl_size - ((sect % cyl_size) ?: cyl_size); + return sect + cyl_size - (sect % cyl_size); } /* check the partition sizes and write the partition table */ @@ -140,9 +140,10 @@ static int gen_ptable(int nr) if (verbose) fprintf(stderr, "Partition %d: start=%ld, end=%ld, size=%ld\n", i, (long) start * 512, ((long) start + (long) len) * 512, (long) len * 512); printf("%ld\n", ((long) start * 512)); + printf("%ld\n", ((long) len * 512)); } - if ((fd = open(filename, O_WRONLY|O_CREAT, 0644)) < 0) { + if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) { fprintf(stderr, "Can't open output file '%s'\n",filename); return -1; }