Commit Graph

34 Commits

Author SHA1 Message Date
Karel Zak ed470672bb fdisk: use fdisk_parttype in add_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 02460b8aae fdisk: add fdisk_set_partition_type()
- remove all label specific partition type stuff from fdisk.c to
   label files
 - add new fdisk_set_partition_type() to API

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 010186f2a2 fdisk: add fdisk_get_partition_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 559d921eda fdisk: add new functions for work with fdisk_parttype
- add flags to fdisk_parttype to store more information about the types
 - function for conversion from code to fdisk_parttype
 - function for conversion from string to fdisk_parttype
 - function for conversion from user input to fdisk_parttype
 - support for unknown complex types (e.g. unknown UUIDs)

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 7b575fcc3b fdisk: improve list partition types
- add fdisk_parttype->typestr for types like GPT UUID or Mac
 - list typestr if specified

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 749af4b609 fdisk: move partition types to label specific part
- move MBR partition types to dos_part_types.h
 - make dos_part_types.h independent on datetypes to keep it useful in
   all fdisks
 - add struct fdisk_parrtype
 - move label specific partition types to context->label

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 7e6e9c7018 fdisk: cast before count size
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-31 19:07:37 +02:00
Petr Uzel a7a6f7d2e2 fdisk: don't print CHS geometry unless DOS compatible mode is set
References: http://marc.info/?l=util-linux-ng&m=134329693623430&w=2
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-07-26 17:19:03 +02:00
Petr Uzel f8527f4bd3 fdisk: always print total number of sectors
Print it no regardless on units_per_sector.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-07-26 17:18:55 +02:00
Petr Uzel 6a95c736dc fdisk: fix typo
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-07-26 17:18:53 +02:00
Petr Uzel b29ce87ba4 fdisk: make grain global variable part of fdisk_context()
There is no reason for this to be global variable - it belongs
to the context.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 16:59:35 +02:00
Sami Kerola 888a2e1cd0 fdisk: add noreturn function attribute
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:26 +02:00
Karel Zak de3d6c9379 Revert "fdisk: de-duplicate disk label strings"
... because it's not expected that fdisk_label will be exported by
API and accessible for applications (like fdisk.c). It's private
libfdisk stuff.

This reverts commit e781864260.
2012-07-24 14:15:08 +02:00
Bernhard Voelker e781864260 fdisk: de-duplicate disk label strings
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-07-24 14:10:57 +02:00
Petr Uzel 63906221b6 fdisk: fix compiler warning [-Werror=unused-variable]
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-07-24 14:09:52 +02:00
Karel Zak 594304d56d fdisk: don't ignore 1MiB granularity on 512-byte sector devices
Note that +10MB is 100000 (10^N) and relative values (+<size>
convention) should be be aligned to the default grain (= 1 MiB).

Old version:

  Last sector, +sectors or +size{K,M,G} (2048-2047999, default 2047999): +10MB
  Partition 1 of type Linux and of size 9.5 MiB is set
  ...
  /dev/loop0p1            2048       21578        9765+  83  Linux
  /dev/loop0p2           21579       43062       10742   83  Linux

New version:
  Last sector, +sectors or +size{K,M,G} (2048-2047999, default 2047999): +10MB
  Partition 1 of type Linux and of size 10 MiB is set
  ...
  /dev/loop0p1            2048       22527       10240   83  Linux
  /dev/loop0p2           22528       43007       10240   83  Linux

Addresses: http://thread.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/5913/focus=5929
Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-24 12:28:35 +02:00
Davidlohr Bueso 639f1d56b9 fdisk: API: add fdisk_label_change
[kzak@redhat.com: - rename function
                  - remove fdisk_create_default_disklabel()]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-07-24 10:31:32 +02:00
Davidlohr Bueso 2ca61a61e1 fdisk: API: add verify to label operations
[kzak@redhat.com: - rename some functions]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-24 09:54:52 +02:00
Davidlohr Bueso 0f639e54df fdisk: API: add new partition to label operations
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-07-24 09:34:22 +02:00
Davidlohr Bueso fae7b1bcb5 fdisk: API: add write to label operations
[kzak@redhat.com: - rename functions
                  - use errno]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-07-24 09:13:59 +02:00
Davidlohr Bueso 61c4cb8530 fdisk: API: add delete partition to label operations
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23 18:15:57 +02:00
Davidlohr Bueso 79c8a145dd fdisk: API: add to label operations to context
The context structure is the fdisk API's main data type as it keeps all data
together. Add the label structure to it, so that the pt-specific operations can
be called from the context.

[kzak@redhat.com: - merge with latest changes
                  - don't allocate the label, use const pointer]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-07-23 17:31:06 +02:00
Karel Zak 67987b4734 fdisk: rename cxt->mbr buffer to cxt->firstsector
MBR is regular name for DOS partition table, let use less confusing
name for the buffer.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23 14:24:25 +02:00
Karel Zak 6718834075 fdisk: move label specific stuff to fdiskdoslabel.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23 14:07:35 +02:00
Karel Zak 9a5e29e94b fdisk: move DOS geometry code from generic part to label specific
get_partition_table_geometry() should be called from DOS code

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23 13:57:58 +02:00
Karel Zak 84e18f7659 fdisk: get_boot() has to die (step II.)
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23 11:08:26 +02:00
Karel Zak a71601af27 fdisk: get_boot() has to die (step I.)
- move generic stuff around "create disklabel" operation to API

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23 10:56:06 +02:00
Karel Zak 759d093fae fdisk: move user geometry setting from fdisk.c to API
- to avoid duplicate code
 - to remove fdisk_geom_set_cyls() from API

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23 10:11:08 +02:00
Karel Zak c642a6aaae Merge branch '2012wk28'
* 2012wk28:
  translation: unify file open error messages
  translation: unify stat error messages
  utmpdump: use help and version output macros
  su: align with howto-usage-function
  fdisk: make if clause easier to read
  look: remove extra semicolon
  utmpdump: remove unused variable
  swapon: remove unused variables
  lib/loopdev: minor bug fix: add missing semicolon
  lib/pager: minor compiler warning fixes
  libblkid: remove duplicate entries in symbols
2012-07-16 18:19:08 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola 7d2ba34044 fdisk: make if clause easier to read
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:21 +02:00
Davidlohr Bueso b8855c868f fdisk: API: add label probing functionality
This patch sets the initial layout for label specific operations. A
new fdisk_label structure is created that will hold all these ops,
like new, delete, write and probe, among others. For now only probing
is implemented. Once this design is established, a copy of the probed
label will be copied to the main context structure, where calling the
specific functions will save 'disklabel' checks. Debugging support is
added as well.

This patch passes regression tests and manually passes bsd, sun, dos
and sgi labels probes.

Reviewed-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-07-16 17:59:52 +02:00
Karel Zak 657d9adb71 fix buffer overrun in some calls to sscanf
Reported-by: Sergei Antonov <saproj@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-09 22:26:27 +02:00
Karel Zak 50ea679509 build-sys: rename fdisk -> fdisks/, convert to module
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:50:53 +02:00