Commit Graph

94 Commits

Author SHA1 Message Date
Karel Zak e69f2b0c1a fdisk: add support for the Xtensa architecture
Based on patch from Chris Zankel <chris@zankel.net>.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-30 15:18:22 +01:00
Karel Zak e421313dc2 textual: use UTIL_LINUX_VERSION everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-25 12:05:26 +01:00
Sami Kerola fb26bfaf6b build-sys: add files to distribution
To fix 'make distcheck' compilation.  The fdisks/Makemodule.am has one
new entry 'dos_part_types.h', the rest is about sorting the list.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-10 11:26:55 +01:00
Karel Zak 130820a8c8 fdisk: (gpt) fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:55:55 +01:00
Karel Zak 35e52fa531 fdisk: remove crappy bugs section from man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-17 17:11:05 +01:00
Karel Zak e3443e8f19 fdisk: (gpt) check if the "First sector" is unused
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-04 18:03:35 +01:00
Karel Zak 512a430fe7 fdisk: (gpt) align newly created partitions
- default "First sector" has to be aligned
 - "Last sector" has to be aligned if specified by +<size><suffix> convention

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-04 17:54:15 +01:00
Karel Zak 602ebe7da9 fdisk: (gpt) fix {last,first}_usable_lba usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-04 17:02:50 +01:00
Karel Zak 874aa9c31f fdisk: cleanup partition start/end usage
- always use pointers to make the code more generic
 - always use "const" is possible
 - always use le64_to_cpu() to access numbers

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-04 16:39:15 +01:00
Karel Zak 413df90611 fdisk: (gpt) check partitions alignment
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-04 15:45:25 +01:00
Karel Zak b546d44226 fdisk: report PT type, inform about new GPT
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-04 14:58:55 +01:00
Karel Zak b41846909f fdisk: (gpt) use topology to define FirstUsableLBA
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-04 14:49:17 +01:00
Karel Zak 3c88fb56b6 fdisk: move DOS units stuff to fdiskdoslabel.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-03 16:22:17 +01:00
Karel Zak 9598acbcc8 fdisk: use BLKSSZGET as default for io-limits rather than hardcoded limit
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-03 15:50:21 +01:00
Karel Zak cf3808e468 fdisk: remove global variable sector_offset
- add cxt->first_lba as replacement to sector_offset
 - add label->reset_alignment() to overwrite the default alignment setting
 - add fdisk_reset_alignment() to setup grain, first LBA offset, etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-03 15:48:31 +01:00
Karel Zak cc7b6e92c6 fdisk: zerosize EBR buffer
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-30 21:33:06 +01:00
Davidlohr Bueso 8254c3a594 fdisk: api: propagate add partitions to users
Similarly to commit 1f5eb51b79 we
do not propagate problems when adding partitions to user visible
api.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-11-30 13:48:27 +01:00
Davidlohr Bueso 5759a4a22b fdisk: remove dead code
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-11-30 13:48:24 +01:00
Davidlohr Bueso ff5775bd4f fdisk: api: move disklabel type to cxt
Get rid of it as a global variable as it belongs in the context.
To compare a disklabel on the device, the fdisk_dev_is_disklabel()
function is introduced. Also, to avoid naming issues, the fdisk_labeltype
members where renamed to FDISK_DISKLABEL_<type>.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-11-30 13:48:19 +01:00
Karel Zak 21770662c3 fdisk: don't fails silently if EBR is outside of disk
Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-30 11:54:10 +01:00
Davidlohr Bueso e9bf0935d6 fdisk: gpt: check header size
UEFI states that the size of the GPT header must be between 92 and
the sector size. Add the check when verifying a valid header.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-11-14 10:48:16 +01:00
Karel Zak 74b89d7d7a fdisk: don't offer GPT stuff in BSD menu
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-13 18:05:36 +01:00
Davidlohr Bueso 3f73100190 gpt: create empty disklabels
This patch enables creating a new, empty, GPT disklabel from either
an empty disk or one that already has a disklabel. For this
purpose, a 'g' option is added to the main menu and is visible to all
labels. Here's an example for a scsi_debug device (/dev/sdb):

...
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x20a614c8.
3696: fdisk:  CONTEXT: zeroize in-memory first sector buffer

Command (m for help): g
3696: fdisk:    LABEL: changing to gpt label

3696: fdisk:  CONTEXT: zeroize in-memory first sector buffer
3696: fdisk:    LABEL: created new empty GPT disklabel (GUID: D4EA0706-F011-46DC-B7DE-6A72C7090AF8)

Command (m for help): w
The partition table has been altered!
...

Acked-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-11-02 12:26:17 +01:00
Davidlohr Bueso 1961311196 fdisk: gpt: write entire first sector
We were writing only 1 byte in LBA0, and GPT requires dealing with an entire
sector. This bug wasn't affecting when dealing with already existing devices
with GPT as we weren't writing an important part of the first sector, thus
leaving it unchanged. Also use write_all() wrapper from all-io.h

Acked-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-11-02 12:25:47 +01:00
Karel Zak 6cf20040dd sfdisk: fix formatting typo in man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-02 09:17:49 +01:00
Karel Zak 8f3b568cd7 fdisk: fix compiler warning [-Wpointer-arith] and floating point exception
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 15:10:26 +02:00
Davidlohr Bueso 0b3e1d9bae fdisk: gpt: use swap_efi_guid for new partitions
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-10-18 12:16:06 +02:00
Davidlohr Bueso 42c384fa98 fdisk: fix segfault when printing gpt raw data
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-10-18 12:16:01 +02:00
Davidlohr Bueso 537187be67 fdisk: api: improve some comments
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-10-18 12:15:40 +02:00
Davidlohr Bueso 1f5eb51b79 fdisk: api: propagate partition deletion to users
The generic fdisk_delete_partition() function returns 0 when a partition
is correctly deleted, otherwise it's corresponding error (negative values).
This, however, does not include problems that can occur in actual label
specific contexts, so we need to propagate the corresponding return code,
back to the user visible api.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-10-18 12:15:33 +02:00
Mike Frysinger 2d609d9945 sfdisk: fix aliasing warnings
Compiles down to the same code.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-10-10 11:23:25 +02:00
Mike Frysinger 8323d9fd59 fix bold style of man page references
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-10-09 12:12:48 +02:00
Marcin Juszkiewicz 6d9bbf886a fdisk: add AArch64 support
Attached patch fixed build problem when util-linux is built for AArch64
architecture.
2012-10-09 12:12:48 +02:00
Davidlohr Bueso 766d5156c4 fdisk: add GPT support
This patch allows fdisk to handle GUID partition tables, based on the latest UEFI specifications
version 2.3.1, from June 27th, 2012. The following operations are supported:

  - Probing (detects both protective and hybrid MBRs)
  - Writing to disk
  - Listing used partitions
  - Adding partitions
  - Deleting partitions
  - Data integrity verifications (for both headers and partitions).

A few considerations:
  - Currently we do not fix invalid primary headers -- we just abort!
  - Header checksums are updated upon every change (ie: add/delete partitions), this allows us
    to mathematically verify the changes on-the-fly, and not only when writing to disk, like
    most other related tools do.
  - We are extremly picky when writing to disk, any error aborts the opeartion.
  - When creating a new partition, the following GUIDs are available:
     http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs

For test cases, the gpt.img from libblkid tests, scsi_debug and my own hard drive (/dev/sda) were used.
For the image, all operations were tested successfully, and for /dev/sda all except write, which
was not tested - hey, I'm not suicidal!

[kzak@redhat.com: - add get/set partition type functions
                  - use unified on strings based table for partition types
                  - add partition type to table list function]

Tested-and-reviewed-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:14 +02:00
Karel Zak 2b1a43cf17 fdisk: cleanup debug messages and comments
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
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
Thierry Reding 4862db73e8 sfdisk: Fix format specifiers for size_t
The proper specifier for size_t is %zu. %lu will work fine on 64-bit
architectures but not on 32-bit.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
2012-09-21 12:14:04 +02:00
Karel Zak 67757329cc mark expected fallthrough for static analysers
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-07 12:05:56 +02:00
Davidlohr Bueso 24505fb241 fdisk: document FDISK_DEBUG
Add the corresponding entry in the manpage.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-09-04 12:48:23 +02:00
Bernhard Voelker eab4028f38 fdisk: fix typo in comment
* fdisks/utils.c: s/firts/first/: found by misspellings.
s/Zero's/Zeros/: denoted by Pádraig Brady <P@draigBrady.com>.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-09-04 12:45:31 +02:00
Davidlohr Bueso 109896c36b fdisk: aix: fix warning
Fixes:
 warning: no previous prototype for ‘aix_nolabel’

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-08-13 14:49:57 +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
Karel Zak 03bc5c0658 fdisk: sgi: use xcalloc()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 21:49:42 +02:00
Karel Zak 43b382e66a fdisk: dos: mark unused parameters
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 18:03:10 +02:00
Karel Zak d0a5b91d2e fdisk: mac: remove magic maclabel macro, mark unused parameters
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 17:57:00 +02:00