Davidlohr Bueso [Sun, 17 Jun 2012 16:10:33 +0000 (18:10 +0200)]
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.
Davidlohr Bueso [Sun, 17 Jun 2012 16:10:11 +0000 (18:10 +0200)]
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.
Davidlohr Bueso [Sun, 17 Jun 2012 16:10:07 +0000 (18:10 +0200)]
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.
Karel Zak [Tue, 19 Jun 2012 11:14:20 +0000 (13:14 +0200)]
lscpu: fix compiler warning [-Wsign-compare]
lscpu.c: In function ‘has_pci_device’:
lscpu.c:425:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
lscpu.c:425:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Karel Zak [Tue, 19 Jun 2012 11:01:29 +0000 (13:01 +0200)]
Merge branch '2012wk24' of git://github.com/kerolasa/lelux-utiliteetit
* '2012wk24' of git://github.com/kerolasa/lelux-utiliteetit: (24 commits)
more: fix pointer wrap around compiler warnings
more: fix search repetition regression
lscpu: values in /proc/bus/pci/devices are always unsigned
scriptreplay: fix compiler format warning
lib/mbsalign: abort() when non-expected case is encountered
mkfs.cramfs: disallow unknown command line options
fsck.cramfs: disallow unknown command line options
setarch: disallow unknown command line options
hexdump: print sensible message when all input file arguments fail
mount: (new) use exclusive_option()
dmesg: use exclusive_option()
wipefs: use exclusive_option()
wdctl: correct manual section reference
wdctl: use exclusive_option()
prlimit: use exclusive_option()
lscpu: use exclusive_option()
losetup: use exclusive_option()
chcpu: use exclusive_option()
lsblk: use exclusive_option()
findmnt: use exclusive_option()
...
Sami Kerola [Sun, 17 Jun 2012 13:01:34 +0000 (15:01 +0200)]
more: fix pointer wrap around compiler warnings
more.c:318:5: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
more.c:362:3: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
Sami Kerola [Sat, 16 Jun 2012 21:09:54 +0000 (23:09 +0200)]
lib/mbsalign: abort() when non-expected case is encountered
Fixes the following compiler warning (9 occurrences), and makes program
to crash if mbsaligh() is called with unexpected align value (which
would be programming error).
../lib/mbsalign.c:260:7: warning: switch missing default case [-Wswitch-default]
Sami Kerola [Sat, 16 Jun 2012 20:59:47 +0000 (22:59 +0200)]
setarch: disallow unknown command line options
Exit with instruction to run --help if unknown option is encountered.
Before the following example printed error, but resulted to an attempt
to run argument.
Karel Zak [Fri, 15 Jun 2012 10:44:17 +0000 (12:44 +0200)]
Merge branch '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit
* '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit:
lsblk: use blkdev_scsi_type_to_name()
blkdev: add blkdev_scsi_type_to_name()
wipefs: use symbolic value for markup mode
eject: inform if CD-ROM drive is not ready
docs: clean up partx.8 manual
include: fix void pointer arithmetics warnings
sysfs: fix printf format warnings
build: fix unused parameter warnings
build: fix redundant redeclaration warnings
include: fix spurious list.h warnings
uuidd: use output redirection which works [checkbashisms]
blkid: fix realloc memory leak [cppcheck]
setarch: do not use -1 as array index [cppcheck]
Petr Uzel [Thu, 14 Jun 2012 14:13:02 +0000 (16:13 +0200)]
libmount: fix read before allocated buffer
valgrind --leak-check=full ./sys-utils/mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
....
==21359== Invalid read of size 1
==21359== at 0x415AC6: mnt_optstr_remove_option_at (optstr.c:310)
==21359== by 0x416358: mnt_optstr_apply_flags (optstr.c:716)
==21359== by 0x40DFBF: mnt_context_prepare_mount (context_mount.c:86)
==21359== by 0x40EB5A: mnt_context_mount (context_mount.c:782)
==21359== by 0x4058B0: main (mount.c:918)
==21359== Address 0x51cd5bf is 1 bytes before a block of size 10 alloc'd
==21359== at 0x4C297CD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359== by 0x4C29957: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359== by 0x415780: __mnt_optstr_append_option (optstr.c:188)
==21359== by 0x412822: mnt_fs_append_options (fs.c:764)
==21359== by 0x409288: mnt_context_append_options (context.c:733)
==21359== by 0x4053F0: main (mount.c:776)
Petr Uzel [Thu, 14 Jun 2012 14:13:01 +0000 (16:13 +0200)]
libmount: plug a memory leak in exec_helper()
valgrind --leak-check=full ./sys-utils/mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
....
==21359== 28 bytes in 1 blocks are definitely lost in loss record 1 of 1
==21359== at 0x4C298B2: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359== by 0x415780: __mnt_optstr_append_option (optstr.c:188)
==21359== by 0x415CB5: mnt_optstr_set_option (optstr.c:387)
==21359== by 0x40D778: do_mount (context_mount.c:192)
==21359== by 0x40E6A9: mnt_context_do_mount (context_mount.c:685)
==21359== by 0x40EB7B: mnt_context_mount (context_mount.c:786)
==21359== by 0x4058B0: main (mount.c:918)
When locking the file fails with -n or -w option, caller has no way
to distinguish between the exit code 1 of the -c command,
and the exit code 1 of flock(1) caused by the conflicting lock.
Add a new -E <exitcode> (--conflict-exit-code) option to set
the exit code for the case of locking failure to any value.