PC partitions and big disks
This should make the error much clearer when partition exceeds 2 TiB on a PC partition map (currently, all user gets is a "out of partition" error which is hard to figure out if you're unaware of the 2 TiB limit).
Comments?
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.)
* include/grub/types.h (ULONG_MAX32): New macro. (ULONG_MAX64): Likewise.
(ULONG_MAX): Use ULONG_MAX32 / ULONG_MAX64 to define it.
* util/misc.c (grub_util_warn): New function.
* util/biosdisk.c (grub_util_biosdisk_get_grub_dev): Issue a warning when disk->total_sectors' exceeds ULONG_MAX32 on pc' partmap.
include/grub/types.h +5 -2
@@ -92,10 +92,13 @@typedef grub_int32_t grub_ssize_t ;#endif +#define ULONG_MAX32 4294967295UL +#define ULONG_MAX64 18446744073709551615UL +#if GRUB_CPU_SIZEOF_VOID_P ==8 -# define ULONG_MAX 18446744073709551615UL +# define ULONG_MAX ULONG_MAX64#else -# define ULONG_MAX 4294967295UL +# define ULONG_MAX ULONG_MAX32#endif /* The type for representing a file offset. */
util/biosdisk.c +3 -0
@@ -738,6 +738,9 @@if (pcdata) { +if (disk->total_sectors >ULONG_MAX32 ) +grub_util_warn ("Size of disk exceeds maximum permitted by partition map" ); +if (pcdata->bsd_part <0 )grub_util_info ("DOS partition %d starts from %lu" , pcdata->dos_part, partition->start);
util/misc.c +13 -0
@@ -58,6 +58,19 @@ }void +grub_util_warn (const char *fmt, ...) +{ +va_list ap; + +fprintf (stderr,"%s: warning: " , progname); +va_start (ap, fmt); +vfprintf (stderr, fmt, ap); +va_end (ap); +fputc ('\n' , stderr); +fflush (stderr); +} + +void grub_util_error (const char *fmt, ...) {va_list ap;
Quoted 4 lines · Robert Millan
void
util/misc.c +2
-0+grub_util_warn (const char *fmt, ...) +{
util/misc.c line 72
Quoted 10 lines
util/misc.c +10
-0+va_list ap; + +fprintf (stderr,"%s: warning: " , progname); +va_start (ap, fmt); +vfprintf (stderr, fmt, ap); +va_end (ap); +fputc ('\n' , stderr); +fflush (stderr); +} +
Ah, this addition is because I needed a way to print a warning unconditionaly, which we don't currently have (_error does that but aborts, _info only prints in verbose mode).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.)
Quoted 5 lines · Robert Millan
This should make the error much clearer when partition exceeds 2 TiB on a PC partition map (currently, all user gets is a "out of partition" error which is hard to figure out if you're unaware of the 2 TiB limit).
Comments?
See below :-)
Quoted 11 lines
Signature · 10 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) * include/grub/types.h (ULONG_MAX32): New macro. (ULONG_MAX64): Likewise. (ULONG_MAX): Use ULONG_MAX32 / ULONG_MAX64 to define it.
Please call use a GRUB_* prefix.
Quoted 4 lines
*
util/misc.c(grub_util_warn): New function.*
util/biosdisk.c(grub_util_biosdisk_get_grub_dev): Issue a warning whendisk->total_sectors' exceeds ULONG_MAX32 onpc' partmap.
Why a warning and not an error? Or perhaps another part of GRUB should return an error?
--
Marco
Quoted 24 lines · Marco Gerards
Quoted 5 lines · Robert Millan
This should make the error much clearer when partition exceeds 2 TiB on a PC partition map (currently, all user gets is a "out of partition" error which is hard to figure out if you're unaware of the 2 TiB limit).
Comments?
See below :-)
Quoted 11 lines
Signature · 10 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) * include/grub/types.h (ULONG_MAX32): New macro. (ULONG_MAX64): Likewise. (ULONG_MAX): Use ULONG_MAX32 / ULONG_MAX64 to define it.Please call use a GRUB_* prefix.
Quoted 7 lines
Quoted 4 lines
*
util/misc.c(grub_util_warn): New function.*
util/biosdisk.c(grub_util_biosdisk_get_grub_dev): Issue a warning whendisk->total_sectors' exceeds ULONG_MAX32 onpc' partmap.Why a warning and not an error? Or perhaps another part of GRUB should return an error?
Uhm. The person who reported this later told me that the partmap was in fact not pc' but gpt'. The problem this patch intended to address may still apply, but without reproducing it first, I'd prefer not to run the risk of "fixing" something that wasn't broken.
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.)
Quoted 30 lines · Robert Millan
Quoted 29 lines · Marco Gerards
Quoted 5 lines · Robert Millan
This should make the error much clearer when partition exceeds 2 TiB on a PC partition map (currently, all user gets is a "out of partition" error which is hard to figure out if you're unaware of the 2 TiB limit).
Comments?
See below :-)
Quoted 11 lines
Signature · 10 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) * include/grub/types.h (ULONG_MAX32): New macro. (ULONG_MAX64): Likewise. (ULONG_MAX): Use ULONG_MAX32 / ULONG_MAX64 to define it.Please call use a GRUB_* prefix.
Quoted 4 lines
*
util/misc.c(grub_util_warn): New function.*
util/biosdisk.c(grub_util_biosdisk_get_grub_dev): Issue a warning whendisk->total_sectors' exceeds ULONG_MAX32 onpc' partmap.
Quoted 7 lines
Quoted 2 lines
Why a warning and not an error? Or perhaps another part of GRUB should return an error?
Uhm. The person who reported this later told me that the partmap was in fact not
pc' butgpt'. The problem this patch intended to address may still apply, but without reproducing it first, I'd prefer not to run the risk of "fixing" something that wasn't broken.
Ok, fine for me. Please don't forget to add the GRUB_ prefix before committing :-)
--
Marco