If user input in a last sector dialog was out of range and with suffix, and if
this was followed by accepting the default value, then the used last sector was
erroneously default - 1.
Reported-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
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>
This moves the code for renaming SGI bootfile from command_prompt() to
sgi_set_bootfilename() function.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
This accidentally fixes a mistake printing the "Partition n is deleted"
message as the 'i' variable get decremented or incremented in case of
logical partitions.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
This allows the creation of a new label if the disk already has an existing
SGI disklabel without working around this problem such as creating a DOS
disklabel or overwriting with zero the partition table (problem reported in
'Gentoo Linux/MIPS Handbook').
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>
This adds a welcome message with util-linux version number, information
about fdisk behaviour that doesn't write to disk after a command (unlike
gparted) and a warning about possible data loss.
The message appears just before the first command prompt.
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>
The default response is 'p' until three primary partitions are created,
then 'e'.
The original idea is from Karel Zak.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Mainly this appends a colon for the prompt, reverses order of the list,
reports the number of primary partitions used and unused.
Old version:
Command action
e extended
p primary partition (1-4)
p
New version:
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select: p
Old version:
Command action
l logical (5 or over)
p primary partition (1-4)
l
New version:
Partition type:
p primary (0 primary, 1 extended, 3 free)
l logical (numbered from 5)
Select: l
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>
Simple replacement code with hardcoded y/n responses to allow
compilation on systems without rpmatch() such as Cygwin.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Don't use open() in get_boot() if it's called with an argument try_only,
because the file has already been opened by the caller.
Signed-off-by: Markus Rinne <markus.ka.rinne@gmail.com>
# modprobe scsi_debug dev_size_mb=1024 sector_size=4096
# fdisk /dev/sdb
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4, default 1):
Using default value 1
First sector (256-262143, default 256): 257
Last sector, +sectors or +size{K,M,G} (257-262143, default 262143): +100M
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
32 heads, 32 sectors/track, 256 cylinders, total 262144 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 262144 bytes
Disk identifier: 0x16db2bb0
Device Boot Start End Blocks Id System
/dev/sdb1 257 25855 102396 83 Linux
Partition 1 does not start on physical sector boundary.
^^^^^^^^
The warning is nonsense. The logical and physical sector size is the
same. It means that every LBA is always aligned to physical sector
boundary.
Note that this bug does not mean that fdisk produces unaligned
partitions. The problem is that fdisk forces to use bigger gaps
between aligned LBAs, for example:
correctly aligned LBA are: 256, 257, 258, ... [N+1]
fdisk assumes: 256, 264, 272, ... [N+(sector_size/512)]
Reported-by: JOB NELSON <job_nelson@hotmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
All fdisk code uses sector_size variable, so there should not be an
exception where we use 512-byte sectors.
Signed-off-by: Karel Zak <kzak@redhat.com>