When the device cannot be opened, there's no point calling fatal() when we can
just use err(3). When any other kind of fatal error occurs it's Ok, in addition
we can also go ahead and close the descriptor before exiting the program as
it's currently leaking.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
This splits check_dos_label() and dos_init() off from get_boot() and gets
rid of the invalid flag 0x00000 warning message due to a check for MBR
signs in zeroized buffer:
memset(MBRbuffer, 0, 512);
if (what == create_empty_dos)
goto got_dos_table;
[...]
got_dos_table:
if (!valid_part_table_flag(MBRbuffer)) {
[...]
if (!valid_part_table_flag(pe->sectorbuffer))
fprintf(stderr, _("Warning: invalid flag 0x%04x of partition "
[...]
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
create_sunlabel() should create a new empty SUN disklabel without checking data
itself writes to memory and initialize internal related fdisk variables.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
DOS and SGI label menus are unchanged. BSD label command
descriptions change slightly to use a common form.
This also removes an useless menu entry in SUN label menu to
edit bsd disklabel.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Using a variable for each supported partition table type doesn't seem necessary.
This fixes also a minor bug in switching from SGI label to SUN label: the expert
menu isn't available as sgi_label variable remains set to true.
Code a bit more clear as *_label names have similarity with names such as
"sgilabel", "struct sun_label".
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
after
Do you really want to quit? n
the read_chars() has to re-print the original prompt and ask again
for new input. For example:
Partition number (1-4, default 3): <-- CTRL-D
Do you really want to quit? n
Partition number (1-4, default 3): 3 <-- ask again
First sector (411648-1023999, default 411648):
Signed-off-by: Karel Zak <kzak@redhat.com>
gcc 4.4 produces tons of
"dereferencing type-punned pointer will break strict-aliasing rules"
warnings for fdisk code where is
char buffer[BUFSIZ];
((struct disklabel *) MBRBuffer)->foo
There are two ways how fix the problem:
1/ union {
char buffer[BUFSIZ], struct disklabel label
} MBRBuffer;
2/ use allocated buffer, this way seems less invasive.
This patch implements 2/.
Old version:
$ make -C fdisk | grep -c warning
236
New version:
$ make -C fdisk | grep -c warning
0
About aliasing:
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40665
- http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html
- C99
Signed-off-by: Karel Zak <kzak@redhat.com>