Commit Graph

467 Commits

Author SHA1 Message Date
Karel Zak 95085ec5d6 libfdisk: (dos) use script label-id
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 9a79aa6e7a sfdisk: more update to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 347a7f7756 sfdisk: add --append
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak e54b1c6fcb sfdisk: be sensitive to PT limits
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak ea50ba5bf1 libfdisk: remove old label drives' API for parttypes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 71c895fc62 libfdisk: (sgi) add set_part() API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 7f63194ac6 libfdisk: (bsd) add set_part() API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak b305ad4065 libfdisk: use new set_part API in fdisk_set_partition_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak a48c09853c libfdisk: (gpt) check string_to_guid()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 2aeff7618e linfdisk: cleanup fsync usage
* always use fsync() if the device open read-write
 * use sync() on demand

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak d151447ba1 sfdisk: make dump format usable on stdin
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 6936c081ab libfdisk: (gpt) use generic API to change UUID and name
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak b0a484a880 libfdisk: (gpt) implement fdisk_set_partition() backend
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 0ecf3ab504 libfdisk: (dos) implement fdisk_set_partition() backend
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 0dad217785 libfdisk: add fdisk_set_partition()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak e11c668449 libfdisk: cleanup internal drivers' API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 78049787a5 libfdisk: add fdisk_copy_parttype()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 2d12903265 libfdisk: make yes/no dialogs more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 3186f4a927 sfdisk: improve UI
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak d5bee4bb59 libfdisk: cleanup script size= code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak c3bc748352 libfdisk: return partno when add new partition
* improve the way how sfdisk report results
 * the API change simplify applications

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 0051ec9bff libfdisk: fix script partitions size parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak ea987bb509 libfdisk: (dos) more carefully check for primary partitions
* check if there is space for primary partitions, if no and extended
    exists then create logical partitions

  * create extended if @pa->type is extended partition

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 59c8e95b3b libfdisk: add fdisk_partition_is_bootable()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 152788aacb fdisk: improve --list output
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:30 +02:00
Karel Zak fdb006e8b5 fdisk: move --list functionality to separated file
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:30 +02:00
Karel Zak 60ba8c362d libfdisk: fix add_logical() assert
The zero index is absolutely valid for extended partition (it means
extended partition could be the first partition on the device).

Reported-by: Christoph Hoopmann <christophhoopmann@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 11:33:46 +02:00
Sami Kerola 1bcf491a78 textual: fix couple typos in comments
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:15 +02:00
Benno Schulenberg 8d7a6285ec textual: add a comma for clarity, plus some other tweaks
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-10-01 09:37:05 +02:00
Karel Zak 7b83dcc8a8 libfdisk: add support for sfdisk-like script format
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-02 13:51:32 +02:00
Karel Zak 4b43f7c96b libfdisk: (gpt) follow label-id from script
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-01 15:01:34 +02:00
Karel Zak 9138d6f972 libfdisk: add functions to apply partitiong scripts
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-01 14:44:39 +02:00
Karel Zak ee50336c03 libfdisk: (gpt) don't align last possible LBA
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-01 14:42:12 +02:00
Karel Zak 73b7c331b3 libfdisk: rename fdisk_dump_ to fdisk_script_
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-01 11:16:21 +02:00
Karel Zak 6e5e9368a0 libfdisk: fix fdisk_delete_all_partitions()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-01 11:14:18 +02:00
Karel Zak 3c0e6b1530 libfdisk: add fdisk_apply_table() and fdisk_delete_all_partitions()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-29 11:18:29 +02:00
Karel Zak a835add045 libfdisk: improve debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-29 09:57:51 +02:00
Karel Zak b1c5a4be93 libfdisk: accept dump with quotes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-29 09:55:31 +02:00
Karel Zak 7bc31adac4 libfdisk: (dos) follow bootable setting when add partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-29 09:19:13 +02:00
Karel Zak 8d95e7e0e4 libfdisk: (gpt) allow to specify uuid and name when create new partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28 14:42:55 +02:00
Karel Zak 080633e43d libfdisk: (gpt) set_{name,uuid} functions refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28 14:16:56 +02:00
Karel Zak 62a9ef3e2f libfdisk: add reference to context to dump
* add fdisk_ref_context() function

 * context is necessary to parse label specific partition types

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28 13:03:23 +02:00
Karel Zak c7119037f0 libfdisk: use reference counting for context
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28 12:49:16 +02:00
Karel Zak c1ba586395 libfdisk: extend dump parsing function
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28 12:37:46 +02:00
Karel Zak afef428f40 libfdisk: (dos) fix typo
Reported-by: https://github.com/Mikachu
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28 10:45:58 +02:00
Karel Zak 613596b387 libfdisk: (dos) fix logical partitions add/delete code
If you delete logical partition and then create a new one than fdisk
(and cfdisk) might write EBR to the first sector on the device. That's
wrong of course; because you will lost MBR (primary partitions).

(Probably introduced by commit bcddbe9688
 where code completely clears EBR stuff.)

Reported-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-26 16:54:45 +02:00
Karel Zak 1d691b258e libfdisk: vary basic dump parsing functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-25 15:33:02 +02:00
Karel Zak cb4d680467 libfdisk: basic fdisk_dump_* functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-22 14:43:52 +02:00
Karel Zak 385810d22a libfdisk: remove debug dump function, cleanup API
The fdisk_dump_* prefix will be used for sfdisk-like functionality.
The patch also add FDISK_ prefix to fdisk_get_unit() options.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-22 10:25:35 +02:00
Karel Zak 6b11aad26b libfdisk: fix fdisk_get_optimal_iosize() and update tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-20 11:43:02 +02:00
Karel Zak 2ae3d038b9 libfdisk: move fdisk_ask_partnum() to API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-15 12:34:42 +02:00
Karel Zak 1753a234a1 libfdisk: add geometry to API, cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-15 12:16:27 +02:00
Karel Zak 4af064f3fc libfdisk: fdisk_label_is_labeltype()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-15 10:49:51 +02:00
Karel Zak 5175ae8738 libfdisk: more docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-14 21:04:01 +02:00
Karel Zak a745611d69 libfdisk: final parttype API cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-14 13:28:37 +02:00
Karel Zak 5ab3760071 libfdisk: move get_parttypes to label API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-14 12:01:38 +02:00
Karel Zak 773aae5c51 libfdisk: (gpt) allow to specify attr bit by API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-14 11:33:46 +02:00
Karel Zak 11ee1177ff libfdisk: make it possible to get fields for all labes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-14 00:27:28 +02:00
Karel Zak 72d2965c44 libfdisk: cleanup label geometry API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-14 00:09:48 +02:00
Karel Zak aa36c2cf2c libfdisk: cleanup fdisk_is_label stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 23:57:54 +02:00
Karel Zak 8d605c884a libfdisk: clean up API (alignment.c)
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 23:27:00 +02:00
Karel Zak 6a6321360d libfdisk: clean up API (context.c)
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 22:26:53 +02:00
Karel Zak 03e4220d29 include/debug: cleanup masks
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 14:13:32 +02:00
Ondrej Oprala 14ad2353cc libs/debug: accept human readable names for _DEBUG=
For example
	$ LIBMOUNT_DEBUG=tab,cache findmnt

to debug only TAB and CACHE subsystem.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 12:33:47 +02:00
Karel Zak bd85d11fba libfdisk: rename fdisk_column to fdisk_field
.. to make the API and fdisk(s) code more readable.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 11:12:27 +02:00
Karel Zak d44115f3b5 libfdisk: remove dependence on libsmartcols
It's application business to convert libfdisk_table to string.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 10:10:11 +02:00
Karel Zak c9400a1ea7 fdisk: always print warning for mis-aligned partitions
This patch restores the original fdisk behavior and always prints
information about misaligned partitions in 'p'print output.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-08 11:33:28 +02:00
Sergei Antonov 210d4595de libfdisk: (gpt) add Microsoft Storage Spaces GUID
Storage Spaces is Microsoft's logical volume management.
It has been around since Windows 8.

Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Sergei Antonov <saproj@gmail.com>
2014-07-31 10:50:42 +02:00
Benno Schulenberg 09af3db48e textual: fix some typos and inconsistencies in various messages
Fixing plain typos, miswordings, inconsistent periods, some missing
angular brackets, and a proper pluralization (even when it involves
a constant, because for some languages the precise value matters).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-23 08:56:00 +02:00
Karel Zak bc787727d4 libfdisk: make disk sync() optional
... this allows to avoid unnecessary sync() from cfdisk.

Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-15 12:32:03 +02:00
Karel Zak 2fa32bea49 Merge branch 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetit
* 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetit:
  lscpu: avoid double free
  libsmartcols: avoid variable dereference after release
  libfdisk: do not do the same thing twice in single if statement
  whereis: avoid printing uninitialized string
  setpriv: avoid alloca() use xmalloc() instead
  dmesg: avoid unnecessary variable assignment
  fdisk: avoid code duplication
  mkfs.cramfs: use defined failure name rather than magic value
  fdformat: match variable and print format types
  cfdisk: add braces to ensure operation order
  lscpu: avoid use of bzero() in favor of memset()
  setterm: remove unnecessary variable
  cal: remove unnused structure and definition
  textual: fix some typos
2014-07-14 16:03:48 +02:00
Karel Zak 7c2cfb1896 libfdisk: make first sector buffer usage more robust
$ ~/util-linux/fdisk -b 4096 xxx
	..
	Segmentation fault

The buffer has to be reinitialized always when we apply a new
device properties (e.g. sector size).

Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-14 15:05:22 +02:00
Sami Kerola 99cacc6adf libfdisk: do not do the same thing twice in single if statement
The second argument was very likely meant to be 'be->offset'.
Maintainers review & sign-off will further verify this change being
correct.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 18:35:39 +01:00
Sami Kerola 0e65dcde88 textual: fix some typos
Found with misspell-check version 2.0d.

Reference: https://github.com/lyda/misspell-check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 17:21:02 +01:00
Karel Zak 1671b2ed1a libfdisk: fix possible memory leak [clang-analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-01 13:36:37 +02:00
Karel Zak 11712b6667 libfdisk: (dos) count fisrt usable LBA to total number of used sectors
The check() function counts number of used sectors, but it counts only
partitions. This is mistake, the area before the first partition is
also "used" place (boot loaders or we have to align the first partition
to disk I/O limits, etc).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-24 10:32:25 +02:00
Karel Zak 63fb717d8c libfdisk: (dos) use check() for dos-comaptible mode only
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-24 09:40:56 +02:00
Thorsten Wilmer 9bb8caff87 libfdisk: (dos) calculation of total size based on CHS in check function
Many people report a problem with the message if (cylinders <= 1024 &&
start != total) fprintf(stderr, _("Partition %d: previous sectors %d
disagrees with " "total %d\n"), n, start, total);

This message comes from the fact that the previous code caluclates the
total number of sectors in the wrong way.

The formula should be total = (real_c * heads + h) * sectors + real_s;

As a Cylinder consists of some heads * sectors A Head consists of some
sectors and finally sectors are the smallest unit

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-24 09:40:06 +02:00
Karel Zak 2c94e10b50 libfdisk: fix fdisk_context_assign_device() comment
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-09 12:09:18 +02:00
Ruediger Meier 0b166f2482 libfdisk: fix bsd_translate_fstype() for alpha
Reported-by: Tobias Klausmann <klausman@schwarzvogel.de>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-06-09 10:43:36 +02:00
Karel Zak cbebd20d26 libfdisk: (gpt) fix last LBA code for S_ISREG
Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-30 10:51:53 +02:00
Karel Zak 73548d6e60 libfdisk: fix %ju -> %zu
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 09:52:42 +02:00
Karel Zak c1156d8564 libfdisk: (dos) improve logical partition reorder command
- use qsort to sort by EBR offsets
 - sort by EBR data partition start sectors

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-22 21:11:03 +02:00
Karel Zak 6c64adeeb6 libfdisk: (mbr) fix logical chain termination
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-22 14:54:44 +02:00
Karel Zak 9348ef2511 libfdisk: (gpt) implement 'fix order' commnad
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-18 14:00:39 +02:00
Karel Zak dd7ba60463 libfdisk: add partitions reorder operation to label API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-18 13:26:08 +02:00
Karel Zak a60087aa32 libfdisk: fix logical partition reorder command
Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-18 11:48:53 +02:00
Karel Zak 8b60872ec0 libfdisk: add generic function to check partitions order
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-16 12:51:08 +02:00
Karel Zak 11fe0448a0 libfdisk: (dos) make EBR parser more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-08 10:14:12 +02:00
Karel Zak 9c7955dabe libfdisk: make qsort_r() optional
The function is no critical for fdisk functionality. The SUN label
verification will check for less issues. All the verification code is
optional ('v' fdisk command).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-04 16:02:35 +02:00
Karel Zak 0925a9dd6c libsmartcols: clean up flags usage
* rename flags functions to scols_table_enable_*
 * rename *_no_foo() functions to _nofoo()
 * output formats are mutually exclusive, so don't use flags there
 * don't assume symbols in scols_new_table(), use scols_table_set_symbols()

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 16:09:57 +02:00
Karel Zak 5fd7160e83 libfdisk: fix freesapce detection for nested partitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:21 +02:00
Karel Zak c743bf744a cfdisk: clean up scols usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:21 +02:00
Karel Zak 7bae0563b8 libfdisk: clean up scols usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:21 +02:00
Ondrej Oprala baa3b270ec Use libsmartcols in libfdisk and cfdisk
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:18 +02:00
Karel Zak 412791a995 libfdisk: remove fdisk_colon()
It was unnecessary overkill to have colorized "foo:" prefix in fdisk
output.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-01 14:39:13 +02:00
Karel Zak e146ae4edb libfdisk: properly implement read-only mode
Don't use fallback to read-only mode in fdisk_context_assign_device(),
it's application responsibility open the device in the right mode.

The commands fdisk and cfdisk check (and report) read-only mode now.

Reported-by: Maciej Małecki <me@mmalecki.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-21 14:04:59 +01:00
Karel Zak d71bd2f0d6 libfdisk: clean up debug output
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-21 13:33:37 +01:00
Karel Zak 881410671f libfdisk: use new debug functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-21 12:35:21 +01:00
Karel Zak 9a7769141a Merge branch 'common_debug' of https://github.com/ooprala/util-linux
* 'common_debug' of https://github.com/ooprala/util-linux:
  clean up redundant macros and defines
  libfdisk: use include/debug.h
  libblkid: use include/debug.h
  libmount: further debug.h integration
  libcommon: don't mention lib versions in debug macros
  libcommon: define more debugging macros
  libmount: use macros from include/debug.h
  libcommon: add common debugging routines
2014-03-21 10:59:58 +01:00
Ondrej Oprala 274228fecc clean up redundant macros and defines
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-13 11:53:31 +01:00
Ondrej Oprala 2618b9cc1f libfdisk: use include/debug.h
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-13 11:11:27 +01:00
Karel Zak 01086b80b6 libfdisk: (gpt) use entry attributes as bitmap
* care about endianess
 * don't use by compiler packed struct with bit array for GPT
   attributes, it's more robust use it as bitmap stored in uint64_t.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-13 11:08:01 +01:00
Karel Zak 5a1b4999f7 libfdisk: update GPT partition types
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-12 13:52:01 +01:00
Benno Schulenberg 27aadd8bf6 libfdisk: avoid two compiler warnings about wrong print formats
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-03-12 12:14:34 +01:00
Karel Zak 41050b7e23 libfdisk: (bsd) fix output
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 12:33:30 +01:00
Karel Zak 8d6ec09aba libfdisk: follow requested size rather than use all available space
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 12:16:14 +01:00
Karel Zak ef97e92ba5 libfdisk: (sun) add info about whole-disk partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:15 +01:00
Karel Zak 7e241236fc libfdisk: (sgi) cleanup, add infor about whole-disk partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:15 +01:00
Karel Zak c1c58b492f libfdisk: don't count special whole-disk partitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:15 +01:00
Karel Zak 7aa0d52963 cfdisk: add create lebel UI
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak 5139eca74a libfdisk: add dump functions, make freespace code generic
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak 1b92d076ba libfdisk: (dos) consolidate partition end-offset code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak e77313a67d libfdisk: (dos) fix ext_index usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak bd5e829198 libfdisk: remove label specific get_freespace
- it seems we can use improved nested<->container relationship
   rather than implement DOS specific function

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak bcddbe9688 libfdisk: (dos) fix log.partition delete
- deallocate sector buffer and deincrement part_max when delete last
   logical partition
 - zap obsolete EBR on begin of the extended partition when no logical
   partition defined

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak aa423fd39e libfdisk: again improve freespace code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak 036439315f libfdisk: improve freesapce detection
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak a3e37fa7af libfdisk: don't ask for pri/log if wanted start within extended partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak e5c93999e6 libfdisk: add table sort function, use it in get_freespace
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 2cec794994 libfdisk: rewrite freespace code
* use separate function to get free space
 * allow to use label-specific get_freespace() function
   (this is necessary for MBR extended partitions mess)

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 81c29a73d9 linfdisk: align free space
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 1240f549d8 libfdisk: (gpt) initialize last_lba, cleanup pa->{start,size} usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak ef7b2f1c88 libfdisk: initialize last_lba
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 732aefdf26 libfdisk: add fdisk_partition_*_follow_default()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 20f878fee3 libfdisk: add ASKTYPE_MENU and context last_lba
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 849968b9ba fdisk: fix 'p'rint error on empty PT
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 28b6a23cae libfdisk: add fdisk_table_get_partition()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 04406c0d0c libfdisk: add fdisk_table_get_nents()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 9f7fdeaf0e libfdisk: tiny clean up in fdisk_table_to_string()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak d0059a2491 libfdisk: clean up cylinder column
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 9f670072f4 libfdisk: remove tt stuff from API
The include/tt.h has to be used only internally by the library (for
example to convert fdisk_table to string).

The fdisk_ask API should not be more used for complex tasks like print
partition table. The application has to use fdisk_get_table() and
fdisk_table_to_string() or something else.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 6c89f750d2 libfdisk: use fdisk_table to generate output
* add generic fdisk_iter iterator
 * use fdisk_table to convert partition table to human readable output
 * clean up partition.c API (don't use reference to fdisk_context in
   fdisk_partition struct)
 * extern table.c API to use fdisk_iter iterator
 * remove old fdisk_list_partitions()

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 187de51c8a libfdisk: move partition stuff to partition.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak b48cdebcb4 libfdisk: add table container
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak d6cfa8b327 libfdisk: add reference counting to fdisk_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 1de9fddbe5 libfdisk: add support to list free space
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 77d6a70ac4 libfdisk: use partition template
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 851515216f libfdisk: remove fdisk_get_partition_type()
Let's use more generic:

	fdisk_get_partition()
        fdisk_partition_get_parttype()

rather than fdisk_get_partition_type().

The patch also improves fdisk_get_partition() semantic to allocate
a new partition struct if the argument is NULL.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 27d4d07292 libfdisk: (sun) remove get_partition_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 5d660fa488 libfdisk: (sgi) remove get_partition_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 7f01ec7aad libfdisk: (dos) remove get_partition_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak a699b27de4 libfdisk: (bsd) remove get_partition_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 7f539277e8 libfdisk: (gpt) remove get_partition_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 0a2aedf0e2 libfdisk: (sun) use new list() and get_part() API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak d787618b97 libfdisk: (sgi) use new list() and get_part() API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 262002ee6f libfdisk: (dos) use new list() and get_part() API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak d6faa8e00d libfdisk: add new list() columns, cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak d48419f3a9 libfdisk: (bsd) use new get_part() API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 82ebc7dea7 libfdisk: improve conversion to string
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 8c0a7f9136 libfdisk: add struct fdisk_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 6941952e8d libfdisk: (gpt) use fdisk_column
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 8152753d58 libfdisk: implement generic functions for FDISK_COL_ stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 21a44c9b84 libfdisk: extend API definition to list info about partitions
This change adds a struct fdisk_column to provide generic description
for information about partitions. The struct is used for tt tables as
well as lists of possible columns for specified label driver.

We use the same concept in all applications linked with tt.c (lsblk,
findmnt, partx, ...) where is possible to dynamically change columns,
order of the columns etc. Now it will be possible to do the same with
fdisk.

And it's also possible to use FDISK_COL_* Ids to address data, for
example:

   fdisk_partition_get_data(cxt, FDISK_COL_SIZE, 1, &data);

returns a string with human readable size (<num>{MGT}) of the second
partition.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak dbf7043ea1 build-sys: don't connect _DEPENDENCIES and _LIBADD
The _DEPENDENCIES has to be used for dependencies on another in-tree
files, but _LIBADD is to specify additional libs (including external
libs).

Reported-by: oleid <notifications@github.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-05 10:20:10 +01:00
Karel Zak b37ab36eec libfdisk: (dos) warn on type 0
This is old warning, but somehow lost during rewrite to libfdisk. Sorry.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-27 22:04:10 +01:00
Karel Zak 28a5bccc47 libfdisk: (dos) fix free part counter
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-27 21:42:18 +01:00
Karel Zak 6d0ed4cb38 fdisk: (gpt) more human readable info about free space
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-25 13:18:02 +01:00
Karel Zak d0a870c5b3 fdisk: don't care about partition type
fdisk allows to overwrite existing partition if the partition has
partition type set to zero (very unusual, but possible).

This is incorrect because such partition is pretty valid (and Linux
kernel does not care about the type at all). For example:

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048       22527       10240   83  Linux
/dev/sdb2           22528      227327      102400    0  Empty
                    ^^^^^                            ^^^^^^^^

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (22528-1228799, default 22528):
                                    ^^^^^^^

.. if user follows the default then the result are overlapping
partitions:

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048       22527       10240   83  Linux
/dev/sdb2           22528      227327      102400    0  Empty
/dev/sdb3           22528     1228799      603136   83  Linux
                    ^^^^^

... and if you call "mkfs /dev/sdb3" then you lost data on sdb2. Sad
thing.

Reported-by: Marc MERLIN <marc@merlins.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-25 12:00:55 +01:00
Karel Zak 488cc17a99 fdisk: fix nasty coding style
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-25 10:58:18 +01:00
Karel Zak e41e151427 libfdisk: (sgi) generate partname according to partition position
The SGI drive currently counts only usable partitions, that's wrong as
Linux kernel counts all partition to generate partition number. For
example:

Kernel:
	sdb                                             8:16   0   600M  0 disk
	├─sdb9                                          8:25   0     2M  0 part
	└─sdb11                                         8:27   0 596.2M  0 part

Fdisk:
	Pt# Device    Info Start       End   Sectors Id System
	 9: /dev/sdb1          0      4095      4096  0 SGI volhdr
	11: /dev/sdb2          0   1220939   1220940  6 SGI volume

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-19 13:02:39 +01:00
Karel Zak 36da6b64c4 libfdisk: (sun) fix end sectors with +1 error
partx (or parted, etc.):

NR     START       END   SECTORS   SIZE NAME UUID
 1         0    410047    410048 200.2M
 2    410048  82329055  81919008  39.1G
 4  82329056 102807615  20478560   9.8G
 5 102807616 110999039   8191424   3.9G
 6 110999040 312580543 201581504  96.1G

and the same with fdisk:

     Device Flag    Start       End    Blocks   Id  System
/dev/loop0p1             0    410048    205024    1  Boot
/dev/loop0p2        410048  82329056  40959504   83  Linux native
/dev/loop0p3             0 312580544 156290272    5  Whole disk
/dev/loop0p4      82329056 102807616  10239280   83  Linux native
/dev/loop0p5     102807616 110999040   4095712   83  Linux native
/dev/loop0p6     110999040 312580544 100790752   8e  Linux LVM

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-01 12:15:25 +01:00
Karel Zak e49874e24c libfdisk: (gpt) add /home GUID
Reported-by: andreas.hanke@gmx-topmail.de
References: http://cgit.freedesktop.org/systemd/systemd/commit/?id=1a14a53cfded6e78c6e8dfb73fdff0039971d642
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-31 08:53:03 +01:00
Karel Zak 433d05ff9a libfdisk: (gpt) allow to work with hybrid GPT
Notes:

 * fdisk don't sync hybrid MBR with GPT
 * hybrid MBR is ignored and not overwritten by PBMR
 * users is informed about expert command 'M' to toggle between MBR
   and GPT mode. It's possible to manually modify hybrid MBR.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-23 16:59:45 +02:00
Karel Zak 45ddb828ed libfdisk: (gpt) improve and cleanup recovery code
* use AlternativeLBA rather than hardcoded offset to backup GPT
 * create gpt_copy_header()

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-23 12:06:47 +02:00
Karel Zak d2d9efa103 libfdisk: (gpt) recover from corrupted primary/backup PT
We already have all code to support this feature, unfortunately
it was not used in gpt_probe_label()...

References: https://bugzilla.redhat.com/show_bug.cgi?id=1022217
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-23 10:46:10 +02:00
Karel Zak 6e876a98ac libfdisk: warn about obsolete signatures on the device
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-23 10:46:10 +02:00
Karel Zak c83f772efd libfdisk: support extended attributes modification
* GPT attributes defined by standard (e.g. legacy boot etc.)
 * attributes (bits 48-63) reserved for GUID specific attributes (used for example
   by MS Windows)

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-23 10:46:10 +02:00
Karel Zak f736ae5117 libfdisk: (dos) be more verbose when change bootable flag
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-23 10:46:10 +02:00
Karel Zak 829f4206fc libfdisk: fix printf stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-23 10:46:10 +02:00
Karel Zak d17c584ac1 libfdisk: support nested MBR
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-23 10:45:14 +02:00
Karel Zak 68e0b7c855 libfdisk: (gpt) %ld -> %ju in verify function
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-21 13:14:04 +02:00
Karel Zak ae48894081 libfdisk: add Intel Rapid Start Technology GUID
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-18 12:05:35 +02:00
Karel Zak 243631e75e libfdisk: (bsd) leave context if new disklabel unwanted
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-16 12:03:48 +02:00
Karel Zak e39966c6a0 fdisk: fix printf stuff
Unfortunately, fdisk_warn/info/.. function was not marked by
printf __attribute__.

We don't want to break gettext stuff now, so all compiler warnings
have been fixed by casts. This is temporary solution, after release it
will be necessary to fix all the strings.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-15 12:46:35 +02:00
Karel Zak f32a9be45a libfdisk: (dos) all disklabel locate function
.. to make 'D'ump expert command usable also for MBR.

Yes, we have -rc2 now and this is a new feature, but it's tiny change
without any interaction to the rest of the code and without gettext stuff.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-15 12:21:28 +02:00
Benno Schulenberg 8321764154 textual: equalize four error messages with already existing ones
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-14 14:54:45 +02:00
Karel Zak 1572fb3e00 libfdisk: mark label modified for PMBR mismatch
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-11 11:50:10 +02:00
Karel Zak 59db52ad47 libfdisk: treat size mismatch as a warning, not an error
Based on kernel patch from Doug Anderson <dianders@chromium.org>.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-11 11:38:29 +02:00
Karel Zak 7a188aedbf libfdisk: add API to disable specified label
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-09 16:02:33 +02:00
Benno Schulenberg d6060cd3ae libfdisk: (gpt) use consistent final period in status messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-09 11:40:08 +02:00
Benno Schulenberg 98aeae9611 libfdisk: (dos) improve the grammar of an error message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-09 11:40:08 +02:00
Benno Schulenberg a0862e2695 libfdisk: (dos) correct the grammar of the disk-identifier prompt
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-09 11:39:54 +02:00
Sami Kerola 5d324c6b94 various: fix mixing declarations and code compiler warnings [smatch]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-10-08 15:47:59 +02:00
Benno Schulenberg e9c58f6d55 COPYING: fix grammar of referring phrase, and indicate location better
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:38:39 +02:00
Benno Schulenberg fd56121ac3 textual: change spelling of "disk label" to the more abundant "disklabel"
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:38:39 +02:00
Karel Zak 8e7f944d95 libfdisk: (gpt) fix warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-08 15:28:53 +02:00
Benno Schulenberg 4ae11fe825 libfdisk/gpt: partly pluralize one message
And don't mention the largest when there is only one segment.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:37 +02:00
Benno Schulenberg 72065bc667 libfdisk/sgi: tweak and harmonize some message strings
Using consistent capitals and lowercase, adding missing periods and
a missing space, repositioning commas for clarity, improving grammar,
and aligning substrings for esthetics.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:34 +02:00
Benno Schulenberg 8a38f32ad0 libfdisk/sgi: tweak and harmonize some comments
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:33 +02:00
Benno Schulenberg c0b289aa11 libfdisk/sgi: properly pluralize three messages
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:32 +02:00
Benno Schulenberg 798f4853ae textual: end both the singular and the plural message with a period
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:27 +02:00
Karel Zak 77274f8842 libfdisk: cleanup warning messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-04 12:07:12 +02:00
Benno Schulenberg 88f91eb4d0 libfdisk: improve spelling of two comments
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-04 11:56:15 +02:00
Karel Zak a01b5b7077 fdisk: fix possible memleak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-02 14:20:59 +02:00
Karel Zak c1d26ddbe7 Merge branch 'master' of https://github.com/yurchor/util-linux 2013-09-30 15:56:31 +02:00
Karel Zak a1e276ae15 textual: fix misspelled words in -rc1
Reported-by: Rafael Ferreira <rafael.f.f1@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-30 13:58:53 +02:00
Yuri Chornoivan 0d0d12adf8 Fix various typos 2013-09-28 13:33:59 +03:00
Karel Zak a29fdcc001 libfdisk: (bds) cleanup includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-26 10:57:35 +02:00
Karel Zak b325f31a5b libfdisk: (sun) make it more obvious why the first sector moved
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-25 17:13:47 +02:00