sfdisk: warn if partition starts above 2 TiB limit
PATCH 1/1 sfdisk: warn if partition starts above 2 TiB limit
--- fdisk/sfdisk.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
fdisk/sfdisk.c +11 -0
@@ -1304,6 +1304,17 @@ partitions_ok(struct disk_desc *z) { } } +/* Do the partitions start below the DOS 2TiB limit? */ + { +for (p = partitions; p < partitions + partno; p++) +if (p->size && p->start > (unsigned long )UINT32_MAX ) { +my_warn (_ ("Warning: partition %s has starting sector %lu, " +"which is above the DOS 2 TiB limit\n" ), +PNO (p), p->start); +return 0 ; + } + } +/* At most one chain of DOS extended partitions ? */ /* It seems that the OS/2 fdisk has the additional requirement that the extended partition must be the fourth one */
Signature · 8 lines
1.7.3.4 Petr -- Petr Uzel IRC: ptr_uzl @ freenode
Karel Zak
maintainerQuoted 11 lines · Petr Uzel
Signed-off-by Petr Uzel <[email protected]>--- fdisk/sfdisk.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)fdisk/sfdisk.c +0
-0
fdisk/sfdisk.c partitions_ok(struct disk_desc *z) { · line 1310
Quoted 7 lines
fdisk/sfdisk.c +4
-0@@ -1304,6 +1304,17 @@ partitions_ok(struct disk_desc *z) { } } +/* Do the partitions start below the DOS 2TiB limit? */ + { +for (p = partitions; p < partitions + partno; p++) +if (p->size && p->start > (unsigned long )UINT32_MAX ) {
ULONG_MAX is not greater than UINT32_MAX on 32-bit archs ;-)
IMHO you have to use 64-bit number for the p->size or you have move the check to the place where (before) p->start is incremented.
fdisk/sfdisk.c partitions_ok(struct disk_desc *z) { · line 1312
Quoted 2 lines
fdisk/sfdisk.c +2
-0+ my_warn(_("Warning: partition %s has starting sector %lu, " + "which is above the DOS 2 TiB limit\n"),
The warning is incorrect. The limit is not 2 TiB, but UINT32_MAX *sectors*. It's 2TiB for 512-byte sectors, but for 4K sectors is it more...
See fdisk.fdisk.c: warn_limits().
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 32 lines · Karel Zak
Quoted 11 lines · Petr Uzel
Signed-off-by Petr Uzel <[email protected]>--- fdisk/sfdisk.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)fdisk/sfdisk.c +0
-0fdisk/sfdisk.c partitions_ok(struct disk_desc *z) { · line 1310
Quoted 7 lines
fdisk/sfdisk.c +4
-0@@ -1304,6 +1304,17 @@ partitions_ok(struct disk_desc *z) { } } +/* Do the partitions start below the DOS 2TiB limit? */ + { +for (p = partitions; p < partitions + partno; p++) +if (p->size && p->start > (unsigned long )UINT32_MAX ) {
ULONG_MAXis not greater thanUINT32_MAXon 32-bit archs ;-)IMHO you have to use 64-bit number for the
p->sizeor you have move the check to the place where (before)p->startis incremented.fdisk/sfdisk.c partitions_ok(struct disk_desc *z) { · line 1312
Quoted 2 lines
fdisk/sfdisk.c +2
-0+ my_warn(_("Warning: partition %s has starting sector %lu, " + "which is above the DOS 2 TiB limit\n"),The warning is incorrect. The limit is not 2 TiB, but
UINT32_MAX*sectors*. It's 2TiB for 512-byte sectors, but for 4K sectors is it more...
Quoted 3 lines
See
fdisk.fdisk.c:warn_limits().Karel
Thanks for the review! I'll rework the patch and resubmit.
Petr
--
Petr Uzel
IRC: ptr_uzl @ freenode