summaryrefslogtreecommitdiffstats
path: root/fdisk
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* fdisk: use optimal_io_sizeKarel Zak2010-01-281-11/+13
| | | | | | | | | * rename the minimum_io_size variable to io_size * use blkid_topology_get_optimal_io_size() for io_size initialization * use blkid_topology_get_minimum_io_size() as a fallback solution for io_size initialization Signed-off-by: Karel Zak <kzak@redhat.com>
* cfdisk: use libblkidMatthias König2010-01-222-206/+49Star
| | | | | | | | | | | | | Let cfdisk use the internal libblkid if available to get the filesystem type and label. [kzak@redhat.com: - remove old FS probing code from cfdisk - remove "Linux" prefix for filesystem names - enlarge fstype field in partition_info - restrict probing area by partition size] Signed-off-by: Matthias König <mk@phasorlab.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: don't include scsi.hKarel Zak2010-01-131-5/+0Star
| | | | | | | The fdisksunlabel.c header file is unnecessary for fdisk/fdisksunlabel.h. Reported-by: Thomas Stalder <thomas@netsolux.ch> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: sleep-after-sync and fsync usageKarel Zak2010-01-063-9/+5Star
| | | | | | | | | | | | | | | | | | | | It seems that sleep() after sync() is unnecessary legacy. It's very probably unnecessary since kernel 1.3.20. For example the libparted does not to use sleep() at all. It seems that more important is fsync() usage in fdisks. For more details see http://marc.theaimsgroup.com/?l=linux-kernel&m=105545785306867&w=3 http://marc.theaimsgroup.com/?l=linux-kernel&m=105545848607353&w=3 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=276369 Currently we use fsync() in fdisk only. This patch also add fsync() to sfdisk and cfdisk. Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=276369 Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=502639 Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: confused about disk sizeKarel Zak2010-01-041-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The size of disk in the sfdisk command is based on number of cylinders (this is probably legacy from CHS epoch). That's wrong because partitions are addressed in sectors (LBA), so cylinders don't provide necessary resolution (granularity). On Sat, Jan 02, 2010 at 01:01:16PM +0100, Giulio wrote: > $ cat /sys/block/sda/size > 184549376 > > $ sfdisk -d /dev/sda > part.dump > $ cat part.dump > # partition table of /dev/sda > unit: sectors > > /dev/sda1 : start= 2048, size= 2097152, Id=83 > /dev/sda2 : start= 2099200, size= 12582912, Id=83 > /dev/sda3 : start= 14682112, size= 84934656, Id=83 > /dev/sda4 : start= 99616768, size= 84932608, Id=83 > > > $ sfdisk -L /dev/sda < part.dump > Checking that no-one is using this disk right now ... > OK > > Disk /dev/sda: 11487 cylinders, 255 heads, 63 sectors/track > Old situation: > Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 > > Device Boot Start End #cyls #blocks Id System > /dev/sda1 0+ 130- 131- 1048576 83 Linux > /dev/sda2 130+ 913- 784- 6291456 83 Linux > /dev/sda3 913+ 6200- 5287- 42467328 83 Linux > /dev/sda4 6200+ 11487- 5287- 42466304 83 Linux > Warning: given size (84932608) exceeds max allowable size (84921887) disk size: based on number of cylinders: 11487 * 8225280 = 94483791360 bytes based on number of sectors: 184549376 * 512 = 94489280512 bytes end of 4th partition (LBA in bytes): (99616768 + 84932608) * 512 = 94489280512 Reported-by: Giulio <giulioo@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* po: fix msgid bugsKarel Zak2009-12-101-4/+4
| | | | | Reported-by: Petr Pisar <petr.pisar@atlas.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: fix blkid CFLAGS in fdisk/Makefile.amKarel Zak2009-11-201-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: offer aligned first sectorKarel Zak2009-11-181-10/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Typical "new partition" dialog looks like: Partition number (1-4): 1 First sector (4-818687, default 4): ^^^^^^^^^ The range (e.g. 4-818687) depends on fdisk mode (DOS/non-DOS), but the default value should be always aligned. For example RAID5 device in the DOS mode: Disk /dev/md0: 419 MB, 419168256 bytes 2 heads, 4 sectors/track, 102336 cylinders, total 818688 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 65536 bytes Disk identifier: 0x081479c3 .... Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (4-818687, default 128): <---- !!! Using default value 128 Last sector, +sectors or +size{K,M,G} (128-818687, default 818687): +10M Command (m for help): p .... Device Boot Start End Blocks Id System /dev/md0p1 128 20607 10240 83 Linux For non-DOS mode the range will be: First sector (128-818687, default 128): Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: align end of partition when defined by +size{K,M,G}Karel Zak2009-11-181-13/+35
| | | | | | | | | | It's better to have disks without gaps between partitions, so it's better to align ends of partitions. Note, we don't care about end of partitions when the last sector has been explicitly requested by user. Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: check for partition boundaryKarel Zak2009-11-181-1/+14
| | | | | | | | | | | | | | Disk /dev/md0: 419 MB, 419168256 bytes 2 heads, 4 sectors/track, 102336 cylinders, total 818688 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 65536 bytes Disk identifier: 0x081479c3 Device Boot Start End Blocks Id System /dev/md0p1 200 818687 409244 83 Linux Partition 1 does not start on physical block boundary. Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: print info and recommendations about alignmentKarel Zak2009-11-181-4/+36
| | | | | | | | | | * inform user that phy.sector > log.sector * warn user when alignment_offset is not provided does, DOS-compatible mode is enabled and the default geo.sectors are not aligned * suggest to change display units to sectors (oh yes, fdisk default are cylinders...) Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: use minimal_io_size for the first partitionKarel Zak2009-11-181-12/+34
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: add basic routines for LBA alignmentKarel Zak2009-11-181-0/+73
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: read topology info from libblkidKarel Zak2009-11-182-3/+46
| | | | | | | | | | | | | | | | | | | | | | and print ('p' command) info about logical and physical sectors and alignment_offset. minimum_io_size we don't use physical sector size directly, because on RAIDs is better to use minimum_io_size (aka stripe chunk size). For disk drives is minimum_io_size the same value as physical sector size. alignment_offset For compatibility with legacy operating systems some vendors provide disks where logical and physical sectors are aligned at sector 63 (= geometry.sectors). In other words the physical 4KB sectors start at LBA -1. Then the physical boundary is at: alignment_offset + N * phy_sector_size Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: remove LT_STATIC_LDFLAGSKarel Zak2009-11-051-2/+2
| | | | | | It was really stupid idea to use *_LDFLAGS for some global variable. Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: cleanup static buildingKarel Zak2009-11-051-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: fix strict-aliasing bugsKarel Zak2009-10-176-6/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* fdisk: sgi label - remove duplicate swab16swab[16,32]() definitionsKarel Zak2009-10-162-17/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: use c.hKarel Zak2009-10-163-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: use c.h, remove obsolete #ifdefsKarel Zak2009-10-161-23/+8Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Remove now unused <sys/ioctl.h> includesGuillem Jover2009-10-092-2/+0Star
| | | | | | Those became unused with the switch to the blkdev functions. Signed-off-by: Guillem Jover <guillem@hadrons.org>
* sfdisk: dump has to be $LANG insensitiveKarel Zak2009-09-111-5/+5
| | | | | | | | | | | | | | This stupid bug has been introduced by: commit add5133f4ad5136aac3ce7627e615d14893d0aeb Author: Pedro Ribeiro <p.m42.ribeiro@gmail.com> Date: Fri Oct 3 08:52:35 2008 +0200 fdisk: several strings without gettext calls ... so it shows that we need to improve our review process... :-( Address-Red-Hat-Bug: #522718 Signed-off-by: Karel Zak <kzak@redhat.com>
* cfdisk: more key alternativesJan Sarenik2009-09-071-2/+5
| | | | Signed-off-by: Jan Sarenik <jsarenik@redhat.com>
* sfdisk.8: formattingPeter Breitenlohner2009-08-171-10/+11
| | | | Signed-off-by: Peter Breitenlohner <peb@mppmu.mpg.de>
* fdisk.8: formattingPeter Breitenlohner2009-08-171-6/+18
| | | | Signed-off-by: Peter Breitenlohner <peb@mppmu.mpg.de>