aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2026-02-04 10:28:06 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2026-02-04 10:30:45 +0100
commit8aba5f6347518b09cb82a3330c574268919ed9bc (patch)
treea8964c4f6a78b19a2f927561afd33cf5f46df306 /util-linux
parent36eed984b8f06a22afa916e8ad922d7507c13688 (diff)
downloadbusybox-w32-8aba5f6347518b09cb82a3330c574268919ed9bc.tar.gz
busybox-w32-8aba5f6347518b09cb82a3330c574268919ed9bc.tar.bz2
busybox-w32-8aba5f6347518b09cb82a3330c574268919ed9bc.zip
fdisk: comment out "not a multiple of 512 bytes" warning
function old new delta bb_getsize_in_512sect 187 163 -24 .rodata 107088 107059 -29 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-53) Total: -53 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/fdisk.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 33a8d1896..470194af9 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -528,19 +528,19 @@ static uint64_t bb_getsize_in_512sect(int fd)
528 /* BLKGETSIZE64 takes pointer to uint64_t, not ullong: */ 528 /* BLKGETSIZE64 takes pointer to uint64_t, not ullong: */
529 uint64_t sz_get64; 529 uint64_t sz_get64;
530 /* BLKGETSIZE takes pointer to ulong: */ 530 /* BLKGETSIZE takes pointer to ulong: */
531 unsigned long longsectors; 531 unsigned long sectors_long;
532 532
533 if (ioctl(fd, BLKGETSIZE, &longsectors) == 0 533 if (ioctl(fd, BLKGETSIZE, &sectors_long) == 0
534 ) { 534 ) {
535 /* If in "fdisk -b 4096 /dev/512byte_sect_dev" scenario, 535 /* If in "fdisk -b 4096 /dev/512byte_sect_dev" scenario,
536 * IOW: sector size is OVERRIDDEN by user, 536 * IOW: sector size is OVERRIDDEN by user,
537 * the user tries to create 4K sector layout on a 512 sector 537 * the user tries to create 4K sector layout on a 512 sector
538 * device (presumably because the device can't operate 538 * device (presumably because the device can't operate
539 * in 4k mode on this machine, but can on another one?): 539 * in 4K mode on this machine, but can on another one?):
540 * __do NOT assume BLKGETSIZE returns 4K sectors__ - 540 * __do NOT assume BLKGETSIZE returns 4K sectors__ -
541 * it always returns 512-sized "sectors"! 541 * it always returns 512-sized "sectors"!
542 */ 542 */
543 sz64 = (uint64_t)longsectors * 512; 543 sz64 = (uint64_t)sectors_long * 512;
544 how = "BLKGETSIZE"; 544 how = "BLKGETSIZE";
545 } else { 545 } else {
546 /* BLKGETSIZE failed, assume this is a disk image */ 546 /* BLKGETSIZE failed, assume this is a disk image */
@@ -566,9 +566,10 @@ static uint64_t bb_getsize_in_512sect(int fd)
566 how, (ullong)sz64 566 how, (ullong)sz64
567 ); 567 );
568 } 568 }
569#if 0 /* this breaks "fdisk -s FILE" (util-linux 2.41.1 silently rounds down) */
569 if ((sz64 & 0x1ff) != 0) 570 if ((sz64 & 0x1ff) != 0)
570 bb_error_msg("size %llu not a multiple of 512 bytes", (ullong)sz64); 571 bb_error_msg("size %llu not a multiple of 512 bytes", (ullong)sz64);
571//bb_error_msg("%s: %llu", how, (ullong)sz64); 572#endif
572 573
573 /* Got bytes, convert to 512 byte blocks */ 574 /* Got bytes, convert to 512 byte blocks */
574 return sz64 >> 9; 575 return sz64 >> 9;