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>
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>
fdisk: get_boot() has to die (step II.)

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk: (dos) cleanup function names

 - use 'write' in name for functions that really touch devices
 - use 'set' in name for functions that modify in-memory stuff

... otherwise it's unreadable mess

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk: fix error message for too small devices

 # touch ~/a
 # fdisk -l ~/a
 # fdisk: cannot open /root/a: Success

should be (at least):
 fdisk: cannot open /root/a: Invalid argument

Signed-off-by: Karel Zak <kzak@redhat.com>
tests: update oddinput test

Signed-off-by: Karel Zak <kzak@redhat.com>
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>
fdisk: move label specific stuff to fdiskdoslabel.c

Signed-off-by: Karel Zak <kzak@redhat.com>
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>
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>
fdisk: set label pointer in fdisk_create_default_disklabel()

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk: API: add delete partition to label operations

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
fdisk: API: add new partition to label operations

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
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>
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>
fdisk: make label API more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk: remove unused variables

Signed-off-by: Karel Zak <kzak@redhat.com>
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>
dmesg: add fileback for SEEK_DATA

Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>