summaryrefslogtreecommitdiffstats
path: root/fdisk/sfdisk.c
Commit message (Collapse)AuthorAgeFilesLines
* build-sys: rename fdisk -> fdisks/, convert to moduleKarel Zak2012-06-261-3242/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: cleanup strtoxx_or_err()Karel Zak2012-05-151-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: fix compiler warning [-Wunused-result]Petr Uzel2012-04-271-1/+1
| | | | | | | sfdisk.c: In function ‘do_fdisk’: sfdisk.c:3212:11: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result] Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* sfdisk: improve F_MEGABYTE headerBernhard Voelker2012-04-231-4/+4
| | | | Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
* fdisk: make CHS user values more robustDavidlohr Bueso2012-04-231-4/+5
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* Merge branch 'close_stream' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2012-04-111-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'close_stream' of git://github.com/kerolasa/lelux-utiliteetit: disk-utils: verify writing to streams was successful fdisk: verify writing to streams was successful getopt: verify writing to streams was successful hwclock: verify writing to streams was successful login-utils: verify writing to streams was successful misc-utils: verify writing to streams was successful mount: verify writing to streams was successful partx: verify writing to streams was successful schedutils: verify writing to streams was successful sys-utils: verify writing to streams was successful term-utils: verify writing to streams was successful text-utils: verify writing to streams was successful include: add stream error checking facility Conflicts: fdisk/fdisk.c
| * fdisk: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | sfdisk: fix calculation due to type mismatch (ix86)Petr Uzel2012-04-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instructing sfdisk to create one partition spanning across entire disk (",,") on 32bit system, if the disk is sufficiently large (~2TB) leads to wrong calculation in compute_start_sect() due to type mismatch. Can be reproduced as: -------------------------- linux-3ln5:~ # modprobe scsi_debug virtual_gb=2000 linux-3ln5:~ # sfdisk /dev/sda <<< ',,' Checking that no-one is using this disk right now ... OK Disk /dev/sda: 261083 cylinders, 255 heads, 63 sectors/track sfdisk: ERROR: sector 0 does not have an msdos signature sfdisk: /dev/sda: unrecognized partition table type Old situation: sfdisk: No partitions found no room for partition descriptor sfdisk: bad input -------------------------- Addresses: https://bugzilla.novell.com/show_bug.cgi?id=754789 Reported-by: Dan Mares <dan.mares@norcrossgroup.com> Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* | sfdisk: make -l less verbose about missing PTKarel Zak2012-04-061-8/+10
|/ | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* checkxalloc: nudge regex, fix newfound instancesDave Reisner2012-03-201-4/+2Star
| | | | | | | | | | | | | | | | Using the -w flag with grep actually fought against us here, and hid some instances where xalloc functions weren't used. Discard it in favor of an explicit word boundary as a prefix to the function name, and extend our requirements on the trailing side of the pattern. This also fixes the few new instances that were overlooked because of the regex's deficiency. [kzak@redhat.com: - fix also newfound in findmnt - remove unnecessary checks after xallocs] Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: use rpmatch to yes/no questionSami Kerola2012-03-181-10/+9Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sfdisk: free variable which got the allocation [cppcheck]Sami Kerola2012-02-081-3/+6
| | | | | | | | | [fdisk/sfdisk.c:358]: (error) Memory leak: ss [kzak@redhat.com: - free after error] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: remove dead assigmentKarel Zak2012-02-021-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: cleanup fd usageKarel Zak2012-02-021-4/+6
|
* sfdisk: fix typo in cdrom detectionKarel Zak2012-02-021-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: fix fd leakKarel Zak2012-02-021-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: add comment to keep static analysers happyKarel Zak2012-01-311-0/+1
|
* sfdisk: fix poor coding styleKarel Zak2012-01-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: remove duplicate includesKarel Zak2012-01-171-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: use is_blkdevDavidlohr Bueso2012-01-051-10/+3Star
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* sfdisk: remove PACKED macroKarel Zak2012-01-051-17/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: remove do_warnDavidlohr Bueso2012-01-051-47/+36Star
| | | | | | Replace it with warnx() instead. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* sfdisk: remove fatalDavidlohr Bueso2012-01-041-39/+26Star
| | | | | | | | | | Since fatal() exists with a standard 1 code, it can easily be replaced by errx(3). The xalloc lib is also introduced in this patch. [kzak@redhat,com: - fix coding style] Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: use CDROM_GET_CAPABILITY ioctlDavidlohr Bueso2012-01-021-28/+9Star
| | | | | | And replace the current archaic logic of is_ide_cdrom_or_tape(). Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* sfdisk: warn if partition exceeds partition table limitsPetr Uzel2011-09-271-3/+41
| | | | | | | | | | | Warn the user if the partition to be created exceeds limits imposed by the DOS partition table, which is: * partition has to start on sector < 2^32 * partition size has to be < 2^32 sectors For 512-byte logical sector size, these limits are ~2.2 TiB. Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* sfdisk: use unsigned long long to internally represent sector numberPetr Uzel2011-09-271-29/+29
| | | | | | | | | | Unsigned long is only 4 bytes long on i586, which is not enough to represent sector number on todays large disks. Use unsigned long long, which is 8 bytes long, to store the sector numbers internally, so that we could later make some sanity checks and warn the user if the sector numbers exceed the limits imposed by DOS partition table format. Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* sfdisk: introduce get_ull() functionPetr Uzel2011-09-271-0/+38
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* sfdisk: get_disksize() returns long longPetr Uzel2011-09-271-3/+3
| | | | | | | unsigned long is 4 bytes long on i586, which is not enough for big HDD's with 512B sectors. Use unsigned long long, which is 8 bytes. Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* sfdisk: make the cylinder boundary check less fatalPetr Uzel2011-09-271-2/+4
| | | | | | | If the specified format is not cylinders, make the cylinder boundary check only print a warning and proceed anyways. Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* sfdisk: fix weird indentation in msdos_partition()Petr Uzel2011-09-271-6/+5Star
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* sfdisk: file descriptor is of int typePetr Uzel2011-09-271-1/+1
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* sfdisk: make some tests conditional to !LinuxGiulio Orsero2011-08-231-8/+6Star
| | | | | | | | | | | | | | | | | | | This patch makes the following tests/actions conditional to "!Linux": - Force cylinders as format instead of MB, even if user asked for MB. This solves a bug where if you use "-L -uM", set 1 as starting MB and the disk is larger than a certain size (about 1GB) the partition would start at sector 1 instead of 1MB due to cyl rounding. - Warn about partitions not starting/ending on cyl boundaries. - Check if CHS is ok. I used the "!Linux" notation since it was already used elsewhere in the code. Signed-off-by: Giulio Orsero <giulioo@pobox.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: slice help text into small chunks and improve its wordingBenno Schulenberg2011-08-161-55/+56
| | | | | | | [kzak@redhat.com: - use fputs(), - use <var> convention] Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* sfdisk: indent usage()Karel Zak2011-08-161-42/+41Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: correct '--inside-order' to '--inside-outer' in documentationBenno Schulenberg2011-08-151-2/+2
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* sfdisk: remove inconsistent and wasteful newlines in the _() callsBenno Schulenberg2011-08-151-70/+43Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* sfdisk: improve descriptions of options --no-reread and --show-extendedBenno Schulenberg2011-08-151-4/+4
| | | | | | Also keep the two geometry options (-g and -G) together by moving -A. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* sfdisk: gettextize each warning as a wholeBenno Schulenberg2011-08-151-4/+4
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* sfdisk: fix coding style.Karel Zak2011-06-291-918/+998
| | | | | | | | | | | | The style in the file is really horrible and unreadable. This patch uses: indent -linux -i4 -psl -brf sfdisk.c to fix the style. The ideal solution is to call the indent with only -linux option, but it's too invasive... Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: fix for data type mismatchesSami Kerola2011-06-141-6/+7
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sfdisk: fix implicit overflowSami Kerola2011-05-301-1/+1
| | | | | | sfdisk.c:1650:6: warning: overflow in implicit constant conversion [-Woverflow] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sfdisk: previously undocumented options to usageSami Kerola2011-05-301-21/+50
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sfdisk: help screen formatSami Kerola2011-05-301-45/+48
| | | | | | | Readability improvement by making the help screen to look like majority of command line utilities. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sfdisk: declare unused function attributesSami Kerola2011-05-301-4/+16
| | | | | | Add `__attribute__ ((__unused__))' where needed. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sfdisk: returns non-zero on failed BLKRRPART ioctlAndrea Galbusera2011-05-061-8/+17
| | | | | | | | | | | Make sfdisk(8) return non-zero value on failed BLKRRPART ioctl(). This will happen for either partition table re-reads after partition changes or on explicit use of -R switch. The function reread_disk_partition() was changed from 'void' to 'int' and now returns a result to let the calling functions decide to exit(1). Signed-off-by: Andrea Galbusera <gizero@gmail.com>
* sfdisk: rename warn to my_warnFabian Groffen2011-02-141-51/+51
| | | | | | | To avoid a conflict with the warn function from err.h, renamed warn to my_warn, as the functionality of both is not the same. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* fdisk: use canonicalized names for -l (and sfdisk -d)Karel Zak2010-12-171-16/+17
| | | | | | | .. 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-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* 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>