* [PATCH] sfdisk: warn if partition starts above 2 TiB limit
@ 2011-07-01 11:11 Petr Uzel
2011-07-01 13:11 ` Karel Zak
0 siblings, 1 reply; 3+ messages in thread
From: Petr Uzel @ 2011-07-01 11:11 UTC (permalink / raw)
To: util-linux
[-- Attachment #1: Type: text/plain, Size: 973 bytes --]
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
fdisk/sfdisk.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index 4ed5d37..d498371 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -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 */
--
1.7.3.4
Petr
--
Petr Uzel
IRC: ptr_uzl @ freenode
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sfdisk: warn if partition starts above 2 TiB limit
2011-07-01 11:11 [PATCH] sfdisk: warn if partition starts above 2 TiB limit Petr Uzel
@ 2011-07-01 13:11 ` Karel Zak
2011-07-01 13:33 ` Petr Uzel
0 siblings, 1 reply; 3+ messages in thread
From: Karel Zak @ 2011-07-01 13:11 UTC (permalink / raw)
To: util-linux
On Fri, Jul 01, 2011 at 01:11:56PM +0200, Petr Uzel wrote:
>
> Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
> ---
> fdisk/sfdisk.c | 11 +++++++++++
> 1 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
> index 4ed5d37..d498371 100644
> --- a/fdisk/sfdisk.c
> +++ b/fdisk/sfdisk.c
> @@ -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.
> + 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
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sfdisk: warn if partition starts above 2 TiB limit
2011-07-01 13:11 ` Karel Zak
@ 2011-07-01 13:33 ` Petr Uzel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Uzel @ 2011-07-01 13:33 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]
On Fri, Jul 01, 2011 at 03:11:40PM +0200, Karel Zak wrote:
> On Fri, Jul 01, 2011 at 01:11:56PM +0200, Petr Uzel wrote:
> >
> > Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
> > ---
> > fdisk/sfdisk.c | 11 +++++++++++
> > 1 files changed, 11 insertions(+), 0 deletions(-)
> >
> > diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
> > index 4ed5d37..d498371 100644
> > --- a/fdisk/sfdisk.c
> > +++ b/fdisk/sfdisk.c
> > @@ -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.
>
> > + 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
Thanks for the review! I'll rework the patch and resubmit.
Petr
--
Petr Uzel
IRC: ptr_uzl @ freenode
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-01 13:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-01 11:11 [PATCH] sfdisk: warn if partition starts above 2 TiB limit Petr Uzel
2011-07-01 13:11 ` Karel Zak
2011-07-01 13:33 ` Petr Uzel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.