fdisk: extend comments for fdisk_new_context()

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk: API: add topology debug

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk: API: add mbr

This patch adds to the fdisk API the relevant logic to buffers that have MBR. This also serves for
future GPT support for the protective MBR. All labels have been updated to have access to the cxt
structure for the corresponding buffer.

An important observation is that SGI no longer uses the standard qsort(3) function to sort partitions,
as it needs access to cxt. To address this, a heap sort implementation from the kernel was added to
the label code and adapted to fdisk.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk: tests: update oddinput test

Adding mbr to the API breaks this test, specifically when reading the first 512 bytes
of the MBR, update the expected output for oddinput.toosmall. Also let the test create
and remove the test file instead of having it in the expected directory.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk: sgi: remove unused code

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk: sgi: remove unused function

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk: sun: remove unused function

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk: mark dos compatibility/CHS options deprecated in manpage

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk: API: add geometry

Add device geometry to the fdisk API. While it maintains traditional behaviour, the cylinders
are changed to sector_t instead of unsigned int in order to avoid dealing with truncated cylinders.
A new helper is added to compute the amount of cylinders based on the heads and sectors - if a user passed
-H or -S to the program, it must call this function to update the corresponding values.

This patch passes regression tests.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk: use memset() rather than bzero()

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk: add some debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/sysfs: check if cxt->dir_path is NULL in sysfs_readlink()

cxt->dir_path could be NULL, for example, when sysfs_init() fails,
check this before calling readlink()/readlink_at().

Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
lib/mangle: fix a memory leak in the test case

Marek reported there is a memory leak in lib/mangle.c

  CC       mangle.o
mangle.c:160:9: warning: Memory is never released; potential leak of memory pointed to by 'ss'

This patch fixes it.

Reported-by: Marek Otahal <markotahal@gmail.com>
Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
lib/sysfs: use warn_unused_result for sysfs_init()

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/loopdev: use warn_unused_result forimportant functions

Signed-off-by: Karel Zak <kzak@redhat.com>
tests: add lscpu test for box with 64 CPUs

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                64
On-line CPU(s) list:   0-63
Thread(s) per core:    2
Core(s) per socket:    8
Socket(s):             4
Vendor ID:             GenuineIntel
...

Signed-off-by: Karel Zak <kzak@redhat.com>
lsblk: check ioctl result [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
agetty: more robust debug() macro, check ioctl result [coverity scan]

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

Signed-off-by: Karel Zak <kzak@redhat.com>
swaplabel: check blkid_probe_lookup_value() result [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>