Something strange is going on. Consider this line:
- Code: Select all
printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%qd x %ld)\n",
mb_quot, mb_rem,
gb_quot, gb_rem,
lba,
dev_desc->blksz);
mb_quot...gb_quot are all ulongs (unsigned 32 bits integers), while lba is a lbaint_t, which is a uint64_t, which is an unsigned 64 bits value. I don't know the size of dev_desc->blksz
This is C, which means all values are pushed on stack, before printf is invoked. It's 32 bits code, so all stack entries are 32 bit.
So the stack is:
[pointer to formatstring]
[mb_quot]
[mb_rem]
[gb_quot]
[gb_rem]
[lba low]
[lba high]
[dev_desc->blksz]
In the format string %ld means 'take a 32 bit value from stack, and print it decimal, signed'. %qd means 'take a 64 bit value from stack, and print it decimal, signed'.
Now I *think* %qd isn't handled correctly, and it takes just a 32 bits value from stack. This means the blocksize is printed using [lba high], which is 1 for disks 2TiB-4TiB, and 0 for disks <2TiB. That fits with your observations.
But it the %qd itself prints a constant, 6391452, which is definitely not the value of [lba low].
An other option is that [lba high] and [low] are swapped on stack, and %qd takes nothing from stack, but just prints a constant.
Something is seriously wrong with printf.
Also:
- Code: Select all
printf("GPT: last_usable_lba incorrect: %llX > %llX\n",
le64_to_int(pgpt_head->last_usable_lba), lastlba);
gives
- Code: Select all
GPT: last_usable_lba incorrect: %lX > %lX
%llX is an equivalent of %qX, which means: take 64 bits from stack and print it hexadecimal. But it's just not evaluated.
But it's not only printf() which is wrong, the GPT is read wrong either. Did you do a 'make clean' after changing the CONFIG values?
/EDIT: Congratulations!