summaryrefslogtreecommitdiffstats
path: root/fdisk
Commit message (Collapse)AuthorAgeFilesLines
* cfdisk: close the program when terminal isn't presentFrancesco Cosoleto2010-12-301-6/+17
| | | | | | | | | | | cfdisk was getting characters without checking ERR return code, causing an endless while loop in do_curses_fdisk() or in other functions when the terminal is lost. [kzak@redhat.com: - fix coding style, remove CR macro] Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: use canonicalized names for -l (and sfdisk -d)Karel Zak2010-12-174-23/+32
| | | | | | | .. no more /dev/dm-X in "fdisk -l" and "sfdisk -d" output, always use /dev/mapper/<name>. Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: add option to use maximum partition sizeKarel Zak2010-12-092-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Based on patch from Alex Bligh <alex@alex.org.uk>, Alex wrote: By default, omitting a size parameter means that the maximum sized partition is used. However, this option is not available in conjunction with the -N flag, as under such circumstances the default is the current size of the partition. This patch allows a size to be specified as "+" in which case the maximum sized partition is used, irrespective of the setting of the -N flag. This allows partitions to be programatically resized to their maximum size, by (for instance): echo ",+," | sfdisk -N1 /dev/sda This is non-trivial to do without the patch, as -N makes the default size the existing size. As there is (without this patch) no way of reading the maximum size, the only option is to delete the partition and recreate it. This is undesirable for a number of reasons (e.g. errors between delete and recreate). Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/686124 Signed-off-by: Karel Zak <kzak@redhat.com>
* rename util-linux-ng back to util-linuxKarel Zak2010-11-303-7/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: fix freespace boundaries calculation on SGI disklabelKarel Zak2010-11-291-0/+3
| | | | | | | Thanks to Aurelien Jarno <aurelien@aurel32.net> Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=510130 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [strutils] general purpose string handling functionsDavidlohr Bueso2010-11-231-1/+1
| | | | | | | | | | | | | This patch replaces a few functions used throughout the source: * Renames getnum (from schedutils) to strtol_or_err * Moves strtosize (from lib/strtosize.c) * Moves xstrncpy (from include/xstrncpy.h) * Adds strnlen, strnchr and strndup if not available (remove it from libmount utils) A few Makefile.am files were modified to compile accordingly along with trivial renaming in schedutils source code. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* sfdisk: save errno before calling perrorForest Bond2010-10-071-1/+4
| | | | | | | | | | | | errno is saved into a local variable to avoid it getting trampled by perror before it is checked to determine the return value. This issue seems quite rare, but I have seen it when running sfdisk via gksudo and using the --quiet command-line option. From what I can tell, this combination triggers loading of translations in perror, which (at least on my machine) ends up changing the value of errno. Signed-off-by: Forest Bond <forest@alittletooquiet.net>
* fdisk: eliminate redundant call to open()Markus Rinne2010-09-301-8/+8
| | | | | | | 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>
* cfdisk: don't use size of device based on cylindersKarel Zak2010-09-061-12/+5Star
| | | | | | | | | This patch is enough to make cfdisk usable on non-DOS disks where partitioning is not based on CHS. cfdisk should not print error messages for such disks. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=630340 Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: fix alignment check for non-512-byte logical sectorsKarel Zak2010-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # 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>
* fdisk: don't keep internally device size in 512-byte sectorsKarel Zak2010-08-231-15/+14Star
| | | | | | | 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>
* cfdisk: fix n+1 againKarel Zak2010-08-091-1/+1
| | | | | Reported-by: J B <jb.1234abcd@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: update MBR after ID changeKarel Zak2010-08-091-4/+15
| | | | | Reported-by: Bernard Pidoux <bpidoux@free.fr> Signed-off-by: Karel Zak <kzak@redhat.com>
* cfdisk: fix n+1 bug in error messageKarel Zak2010-08-091-2/+2
| | | | | | | | | | # cfdisk -Ps <devname> correctly uses 1..N range for partition numbers, unfortunately some error messages use 0..N. This is confusing. Reported-by: J B <jb.1234abcd@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: fix use of non portable typeFrançois Revol2010-07-261-1/+1
| | | | | Signed-off-by: François Revol <revol@free.fr> Signed-off-by: Karel Zak <kzak@redhat.com>
* cfdisk: get_string not calculating correct limitsKarel Zak2010-07-191-3/+8
| | | | | Reported-by: James L. Hammons <jlhamm@acm.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* cfdisk: search for ncursesw/ncurses.hMike Frysinger2010-07-071-0/+2
| | | | | | | | Some distros install the wide version of ncurses side by side with the non-wide version and place the wide headers in an ncursesw/ subdir. So detect that behavior and include the right header with cfdisk. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* cfdisk: fix --with-slangKarel Zak2010-07-012-2/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* po: merge changesKarel Zak2010-06-301-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: improve the description of -c and -u options on man pageBenno Schulenberg2010-06-301-66/+61Star
| | | | | | | Also doublespace sentences, hyphenate compound adjectives, alphabetize the options (except for -CHS), and further tweak some descriptions. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* cfdisk: fix warning: implicit declaration of function ‘wcwidth’Karel Zak2010-06-211-0/+1
| | | | | Reported-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: extend -c and -u options to support old DOS stuffKarel Zak2010-06-162-24/+49
| | | | | | | | | | | | | | | | | The DOS mode and cylinders as display units are disabled by default now. For users who need old DOS behavior is it necessary to extend -c (compatibility) and -u (units) command line options. The change is backwardly compatible (so people who already uses -u and -c are not affected with this change). New form: -c[=<mode>] where <mode> is 'dos' or 'nondos' (default) -u[=<units>] where <units> is 'cylinders' or 'sectors' (default) For example old deprecated DOS behavior could be enabled by: fdisk -u=cylinders -c=dos /dev/sda Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: disable DOS mode and cylinders by defaultKarel Zak2010-06-152-13/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: remove erroneous <size> argument from -u option in help textBenno Schulenberg2010-06-151-3/+3
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* fdisk: untangle the reporting of deprecated mode and unitBenno Schulenberg2010-06-151-9/+3Star
| | | | | | | | | Translatable messages should not be split into parts that are conditionally concatenated. Preferably they should each form a complete message. Signed-off-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: replace ../ with $top_srcdirKarel Zak2010-05-241-3/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* cfdisk: support non-ascii characters in inputKarel Zak2010-05-072-9/+48
| | | | | | | | | | | | | | | | | | | | | | | | | On Sat, Apr 03, 2010 at 12:58:48PM +0000, Jorge wrote: > When you want to write changes to disk you're asked for a > confirmation, like this one: > > Are you sure you want to write the partition table to disk? (yes > or no) > > There is no problem on the English version, but when you launch the > program in Spanish you get this: > > ¿Está seguro de que desea escribir la tabla de particiones en el > disco? > (sí o no): > > You can't type the "í" character. Trying to do so will end in no > input at all. That is, typing in my keyboard "´" then "i" leads to > nothing. So you can't write changes to disk, and you must launch the > program in English for it to operate. Reported-by: Jorge <yo@jorgesuarezdelis.name> Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/205327 Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: improve 'move begin of partition' commandKarel Zak2010-04-281-5/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'b' command ("move beginning of data in a partition") implementation is too restricted. For example: Device Boot Start End Blocks Id System /dev/sdb1 2048 22527 10240 83 Linux .... Partition number (1-4): 1 New beginning of data (2048-22527, default 2048): ^^^^^^^^^^ the range is defined by the current partition size. New version: Partition number (1-4): 1 New beginning of data (1-22527, default 2048): ^^^^^^^ allows to move the begin to arbitrary place if the place is not allocated by any other partition. This is useful for people who don't want to use the default partitioning (1MiB offset, 1MiB grain). The 'b' command is expert command and does not force users to use an aligned LBA (fdisk(8) still prints warning (in 'p' command) if any partition is not aligned to the physical sector boundary). Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: improve add partition dialogKarel Zak2010-04-281-4/+12
| | | | | | | | | | | | old version: Partition number (1-4): new version: Partition number (1-4, default 1): where the default value is the first non-used primary partition. Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: replace bzero with memsetJon Ringle2010-03-311-2/+2
| | | | | | | Work on this was done in commit c0f19ccff73aa0ec5e9f3b61b932ea4a8bf4e6ed, however a couple of bzero call sites were missed Signed-off-by: Jon Ringle <jon@ringle.org>
* fdisk: fix -b <sectorsize>Karel Zak2010-03-192-7/+15
| | | | | | | | | | | | | | | | | The old fdisk (<2.17) does not differentiate between logical and physical sector size, it uses the <sectorsize> for everything. Now, we have logical and physical sectors size, but the -b option changes the logical size only. The second bug is that "fdisk -b <sz>" does not read topology information (it means that all I/O limits and physical sector size are 512 (default). The backwardly compatible bug fix is to override both sizes, logical and physical if "-b" is used. In future we can add a special option for physical size only. Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: correctly truncate and align translated partition namesPádraig Brady2010-03-162-4/+15
| | | | | | | | | | | * fdisk/Makefile.am: Depend on the mbsalign module. * fdisk/fdisk.c: Align using mbsalign rather than printf. [kzak@redhat.com: - use size_t for width to fix gcc warning] Reported-by: Makoto Kato <m_kato@ga2.so-net.ne.jp> Signed-off-by: Pádraig Brady <P@draigBrady.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: fix 'p' output for sun labelKarel Zak2010-02-261-9/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: swap VTOC values for warning messagesKarel Zak2010-02-191-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: make sure writes make it to disk in write_partitions()Bryn M. Reeves2010-02-181-0/+5
| | | | | | Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=565946 Signed-off-by: Bryn M. Reeves <bmr@errorists.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: don't use 1MiB grain on small devicesKarel Zak2010-02-151-3/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: use 1MiB offset and grain always when possibleKarel Zak2010-02-151-5/+14
| | | | | | | | | | It would be nice to minimize dependence between the disk layout and disk topology. We have to follow disk topology for alignment_offset and huge (> 1MiB) I/O sizes only. For all others disks we can use 1MiB grain and 1MiB offset. Reported-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: add -c option (switch off DOS mode)Karel Zak2010-02-152-3/+15
| | | | | | | | * add -c to allows to switch off DOS mode from command line * recommend sectors (command 'u' or option -u) Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: fix ALIGN_UPKarel Zak2010-02-151-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: fallback for topology valuesKarel Zak2010-02-151-1/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: cleanup help, add -h optionKarel Zak2010-02-153-34/+28Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: use more elegant way to count and check alignmentKarel Zak2010-02-121-33/+34
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* cfdisk: set '[New]' as default item on menu for non allocated space instead ↵Francesco Cosoleto2010-02-121-1/+1
| | | | | | of '[Help]'. Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
* cfdisk: set '[Quit]' as default menu item on first run instead of '[Bootable]'.Francesco Cosoleto2010-02-111-1/+3
| | | | Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
* fdisk: cleanup warningsKarel Zak2010-02-091-37/+23Star
| | | | | | | | | | | | | | | | | | | | | | | * don't print: The number of cylinders for this disk is set to 12161. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) we really don't care about MS-DOS or extremely old LILO. * inform users that DOS-compatible mode is bad and deprecated thing (It's difficult to use 2048 sectors grain or 4KiB sectors or alignment_offset in DOS mode where all is based on cylinders...) * don't check for cylinders boundary in non-DOS mode * inform about sector and I/O sizes Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: fix default first sectorKarel Zak2010-02-091-5/+4Star
| | | | | | | | The previous release 2.17 introduces aligned defaults for the first and last sectors on the partition. Unfortunately, there is endless loop when the code looks for first unused aligned sector. Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: cleanup alignment, default to 1MiB offsetKarel Zak2010-02-091-21/+66
| | | | | | | | | | | | | | | | | | | | * add heuristic to detect that the device does not provide topology information. We can use topology if: - alignment_offset is not 0 - or optimal_io_size is not 0 - or minimal_io_size is not power of 2 * default to 1MiB offset for the start of the first partition if topology is unknown. This (2048 512-byte sectors) is Windows Vista default. * use optimal_io_size, minimal_io_size or 1MiB as a grain for partitions alignment Note that this all is used when DOS-compatible mode is disabled. Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: fix check_alignment()Karel Zak2010-02-091-5/+5
| | | | | | | The old version of check_alignment() does not work with extended partitions. Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: don't check alignment_offset against geometryKarel Zak2010-02-091-12/+3Star
| | | | | | | | | | The alignment_offset is compensation for DOS compatible partitioning. It usually matches with disk geometry (e.g. 63 sectors), but the offset is also exported from phy.disks to RAIDs there the geometry don't match with the offset. So.. don't print unnecessary warning. Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: use "optimal I/O size" in warningsKarel Zak2010-01-281-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>