]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
13 years agolib/sysfs: check if cxt->dir_path is NULL in sysfs_readlink()
Cong Wang [Wed, 20 Jun 2012 08:32:00 +0000 (16:32 +0800)] 
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>
13 years agofdisk: add some debug messages
Karel Zak [Thu, 21 Jun 2012 06:17:50 +0000 (08:17 +0200)] 
fdisk: add some debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agofdisk: use memset() rather than bzero()
Karel Zak [Thu, 21 Jun 2012 06:09:45 +0000 (08:09 +0200)] 
fdisk: use memset() rather than bzero()

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agofdisk: API: add geometry
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.

This patch passes regression tests.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: mark dos compatibility/CHS options deprecated in manpage
Davidlohr Bueso [Sun, 17 Jun 2012 16:10:28 +0000 (18:10 +0200)] 
fdisk: mark dos compatibility/CHS options deprecated in manpage

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: sun: remove unused function
Davidlohr Bueso [Sun, 17 Jun 2012 16:10:26 +0000 (18:10 +0200)] 
fdisk: sun: remove unused function

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: sgi: remove unused function
Davidlohr Bueso [Sun, 17 Jun 2012 16:10:22 +0000 (18:10 +0200)] 
fdisk: sgi: remove unused function

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: sgi: remove unused code
Davidlohr Bueso [Sun, 17 Jun 2012 16:10:15 +0000 (18:10 +0200)] 
fdisk: sgi: remove unused code

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: tests: update oddinput test
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.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: API: add mbr
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.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: API: add topology debug
Davidlohr Bueso [Sun, 17 Jun 2012 16:10:04 +0000 (18:10 +0200)] 
fdisk: API: add topology debug

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: extend comments for fdisk_new_context()
Davidlohr Bueso [Sun, 17 Jun 2012 16:09:59 +0000 (18:09 +0200)] 
fdisk: extend comments for fdisk_new_context()

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agolsblk: fix usage, improve exclude/include lists parsing
Karel Zak [Tue, 19 Jun 2012 15:41:35 +0000 (17:41 +0200)] 
lsblk: fix usage, improve exclude/include lists parsing

Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolibmount: improve ifdef HAVE_LIBSELINUX stuff
Karel Zak [Tue, 19 Jun 2012 14:19:18 +0000 (16:19 +0200)] 
libmount: improve ifdef HAVE_LIBSELINUX stuff

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolsblk: add --include option
Karel Zak [Tue, 19 Jun 2012 14:06:22 +0000 (16:06 +0200)] 
lsblk: add --include option

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolscpu: fix compiler warning [-Wsign-compare]
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]

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agoMerge branch '2012wk24' of git://github.com/kerolasa/lelux-utiliteetit
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()
  ...

13 years agopo: add *.h stuff to POTFILES
Karel Zak [Tue, 19 Jun 2012 10:50:10 +0000 (12:50 +0200)] 
po: add *.h stuff to POTFILES

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agomount: (new) add note about unsupported 'ignore' fstype to fstab.5
Karel Zak [Tue, 19 Jun 2012 10:04:03 +0000 (12:04 +0200)] 
mount: (new) add note about unsupported 'ignore' fstype to fstab.5

Reported-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolsblk: permit option --exclude more than once
Bernhard Voelker [Fri, 15 Jun 2012 13:40:35 +0000 (15:40 +0200)] 
lsblk: permit option --exclude more than once

Previously, `lsblk -e 8 -e 11` did not exlude maj:8 as requested.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
13 years agouuidd: move from /var/run/uuidd to /run/uuidd
Karel Zak [Mon, 18 Jun 2012 13:46:20 +0000 (15:46 +0200)] 
uuidd: move from /var/run/uuidd to /run/uuidd

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolibuuid: move clock.txt path to header file
Karel Zak [Mon, 18 Jun 2012 13:36:00 +0000 (15:36 +0200)] 
libuuid: move clock.txt path to header file

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agomore: fix pointer wrap around compiler warnings
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]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agomore: fix search repetition regression
Sami Kerola [Sun, 17 Jun 2012 12:34:30 +0000 (14:34 +0200)] 
more: fix search repetition regression

Commit 596007ef6a37b708f44286932eed667b316e5f70 introduced a bug
crashing more always when a text search was repeated with 'n' command.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agolscpu: values in /proc/bus/pci/devices are always unsigned
Sami Kerola [Sat, 16 Jun 2012 21:34:30 +0000 (23:34 +0200)] 
lscpu: values in /proc/bus/pci/devices are always unsigned

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agoscriptreplay: fix compiler format warning
Sami Kerola [Sat, 16 Jun 2012 21:27:28 +0000 (23:27 +0200)] 
scriptreplay: fix compiler format warning

scriptreplay.c:210:3: warning: format '%zd' expects argument of type 'signed size_t *', but argument 4 has type 'size_t *' [-Wformat]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agolib/mbsalign: abort() when non-expected case is encountered
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]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agomkfs.cramfs: disallow unknown command line options
Sami Kerola [Sat, 16 Jun 2012 21:06:03 +0000 (23:06 +0200)] 
mkfs.cramfs: disallow unknown command line options

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agofsck.cramfs: disallow unknown command line options
Sami Kerola [Sat, 16 Jun 2012 21:05:42 +0000 (23:05 +0200)] 
fsck.cramfs: disallow unknown command line options

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agosetarch: disallow unknown command line options
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.

$ x86_64 -x ls

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agohexdump: print sensible message when all input file arguments fail
Sami Kerola [Sat, 16 Jun 2012 20:30:04 +0000 (22:30 +0200)] 
hexdump: print sensible message when all input file arguments fail

Earlier hexdump printed unnecessary, and perhaps even misleading, 'bad
file descriptor' message.

$ hexdump foobar
hexdump: foobar: No such file or directory
hexdump: foobar: Bad file descriptor

The message is changed to

$ hexdump foobar
hexdump: foobar: No such file or directory
hexdump: all input file arguments failed

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agomount: (new) use exclusive_option()
Sami Kerola [Sat, 16 Jun 2012 09:47:07 +0000 (11:47 +0200)] 
mount: (new) use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agodmesg: use exclusive_option()
Sami Kerola [Sat, 16 Jun 2012 09:31:47 +0000 (11:31 +0200)] 
dmesg: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agowipefs: use exclusive_option()
Sami Kerola [Fri, 15 Jun 2012 22:06:20 +0000 (00:06 +0200)] 
wipefs: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agowdctl: correct manual section reference
Sami Kerola [Fri, 15 Jun 2012 21:55:19 +0000 (23:55 +0200)] 
wdctl: correct manual section reference

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agowdctl: use exclusive_option()
Sami Kerola [Fri, 15 Jun 2012 21:54:41 +0000 (23:54 +0200)] 
wdctl: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agoprlimit: use exclusive_option()
Sami Kerola [Fri, 15 Jun 2012 21:40:49 +0000 (23:40 +0200)] 
prlimit: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agolscpu: use exclusive_option()
Sami Kerola [Fri, 15 Jun 2012 21:16:21 +0000 (23:16 +0200)] 
lscpu: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agolosetup: use exclusive_option()
Sami Kerola [Fri, 15 Jun 2012 20:56:45 +0000 (22:56 +0200)] 
losetup: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agochcpu: use exclusive_option()
Sami Kerola [Fri, 15 Jun 2012 15:17:49 +0000 (17:17 +0200)] 
chcpu: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agolsblk: use exclusive_option()
Sami Kerola [Thu, 14 Jun 2012 19:46:16 +0000 (21:46 +0200)] 
lsblk: use exclusive_option()

This commit fixes exclusions which where meant to happen, but where not
successful.  For example

lsblk -r -l # did exclude
lsblk -l -r # did not exclude

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agofindmnt: use exclusive_option()
Sami Kerola [Thu, 14 Jun 2012 19:31:09 +0000 (21:31 +0200)] 
findmnt: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agoblkid: use exclusive_option()
Sami Kerola [Thu, 14 Jun 2012 19:07:28 +0000 (21:07 +0200)] 
blkid: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agohwclock: use exclusive_option()
Sami Kerola [Thu, 14 Jun 2012 18:58:12 +0000 (20:58 +0200)] 
hwclock: use exclusive_option()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agopartx: use exclusive_option()
Sami Kerola [Thu, 14 Jun 2012 18:22:02 +0000 (20:22 +0200)] 
partx: use exclusive_option()

Earlier option combinations such as below behaved unexpected way.

partx -l -l /dev/sda
partx -r -s /dev/sda

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agoinclude [optutils]: add exclusive_option() inline function
Sami Kerola [Thu, 14 Jun 2012 18:17:51 +0000 (20:17 +0200)] 
include [optutils]: add exclusive_option() inline function

The exclusive_option() will unify how exclusive options are
determined.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agopartx: use -s option for default output
Davidlohr Bueso [Tue, 12 Jun 2012 12:50:06 +0000 (14:50 +0200)] 
partx: use -s option for default output

It's been around a year and a half now that partx was rewritten,
and the legacy output should no longer be default.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agolib/blkdev: return static strings by blkdev_scsi_type_to_name()
Karel Zak [Fri, 15 Jun 2012 11:14:30 +0000 (13:14 +0200)] 
lib/blkdev: return static strings by blkdev_scsi_type_to_name()

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolsblk: use fallback for TYPE
Karel Zak [Fri, 15 Jun 2012 11:13:40 +0000 (13:13 +0200)] 
lsblk: use fallback for TYPE

 ... bug introduced by 1edd8af70b4794c796d0faed0cf763ff3474b92e

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agoinclude/blkdev: cleanup up
Karel Zak [Fri, 15 Jun 2012 11:01:51 +0000 (13:01 +0200)] 
include/blkdev: cleanup up

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agoMerge branch '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit
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]

13 years agolibmount: make some string operations more robust
Karel Zak [Fri, 15 Jun 2012 10:26:05 +0000 (12:26 +0200)] 
libmount: make some string operations more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolibmount: fix trivial typos
Petr Uzel [Thu, 14 Jun 2012 14:13:03 +0000 (16:13 +0200)] 
libmount: fix trivial typos

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
13 years agolibmount: fix read before allocated buffer
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)

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
13 years agolibmount: plug a memory leak in exec_helper()
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)

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
13 years agolibblkid: update dm-verity scan
Milan Broz [Tue, 12 Jun 2012 11:18:02 +0000 (13:18 +0200)] 
libblkid: update dm-verity scan

New superblock now contains UUID. Old version is not going to be used.

Signed-off-by: Milan Broz <mbroz@redhat.com>
13 years agosetsid: fix off-by-one error in execvp call
Bernhard Voelker [Wed, 6 Jun 2012 14:34:55 +0000 (16:34 +0200)] 
setsid: fix off-by-one error in execvp call

Bug introduced during --ctty implementation by v2.21-112-g8a2f04d.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
13 years agosu: remove unimplemented options -u and -v
Bernhard Voelker [Wed, 6 Jun 2012 13:30:52 +0000 (15:30 +0200)] 
su: remove unimplemented options -u and -v

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
13 years agoflock: user-configurable exit code
Jan \"Yenya\" Kasprzak [Tue, 5 Jun 2012 14:26:58 +0000 (16:26 +0200)] 
flock: user-configurable exit code

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.

13 years agomount: (new) allow sloppy for non-root
Karel Zak [Thu, 14 Jun 2012 12:43:21 +0000 (14:43 +0200)] 
mount: (new) allow sloppy for non-root

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=825836
Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolibmount: don't use nosuid,noexec,nodev for cifs user=foo
Karel Zak [Thu, 14 Jun 2012 12:19:26 +0000 (14:19 +0200)] 
libmount: don't use nosuid,noexec,nodev for cifs user=foo

   mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux

is incorrectly translated to

   mount.cifs -o noexec,nosuid,nodev,user=root,password=linux ...

The command mount(8) should be sensitive to "user" (without "=<name>")
only. The correct cifs command line is:

   mount.cifs -o user=root,password=linux

Addresses: https://bugzilla.novell.com/show_bug.cgi?id=766157
Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolibmount: don't generate empty option strings
Karel Zak [Thu, 14 Jun 2012 09:38:53 +0000 (11:38 +0200)] 
libmount: don't generate empty option strings

 mount -t foo something /mnt/test -o user=root,password=linux

generates

 "rw,noexec,nosuid,nodev,password=linux,,user=root"

options string for /sbin/mount.foo, the ",," is incorrect.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agoeject: cleanup umount code
Karel Zak [Wed, 13 Jun 2012 13:58:16 +0000 (15:58 +0200)] 
eject: cleanup umount code

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agoeject: don't try to use non-device path
Karel Zak [Wed, 13 Jun 2012 11:55:49 +0000 (13:55 +0200)] 
eject: don't try to use non-device path

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agoeject: add --no-partitions-unmount
Karel Zak [Wed, 13 Jun 2012 11:46:24 +0000 (13:46 +0200)] 
eject: add --no-partitions-unmount

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agotools: add small and stupid script to check HAVE_DECL_
Karel Zak [Wed, 13 Jun 2012 09:59:29 +0000 (11:59 +0200)] 
tools: add small and stupid script to check HAVE_DECL_

 use 'make checkdecl' to run the script

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolibblkid: trust in udev symlinks, don't verify
Karel Zak [Tue, 12 Jun 2012 14:31:39 +0000 (16:31 +0200)] 
libblkid: trust in udev symlinks, don't verify

The libblkid always verify that /dev/disk/by-* symlinks match with
on-device LABELs/UUIDs. It means that all requests (e.g. mount -L |
-U) generates extra superblocks scans on the device.

Currently, many users and tools (GNOME, systemd, ...etc) use the
symlink directly and udev maintains the symlinks by inotify (+watch
rule). It seems better for system performance to disable the extra
paranoid mode and trust in udev.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolosetup: improve -a to report loopdevs < 512 bytes
Karel Zak [Tue, 12 Jun 2012 13:41:47 +0000 (15:41 +0200)] 
losetup: improve -a to report loopdevs < 512 bytes

 # ll ~/xxx2
  -rw-r--r-- 1 root root 500 Jun 12 14:30 /root/xxx2

 old version:
  # losetup -a

 new version:
  # losetup -a
  /dev/loop0: [2052]:535312 (/root/xxx2)

The new version scans /sys/block/loopN, kernel >= 2.6.37 is required
otherwise fallback to the original not-so-smart /proc/partitions scan.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=730266
Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolosetup: warn about backing file size
Karel Zak [Tue, 12 Jun 2012 12:34:16 +0000 (14:34 +0200)] 
losetup: warn about backing file size

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=730266
Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agolsblk: use blkdev_scsi_type_to_name()
Sami Kerola [Mon, 11 Jun 2012 19:22:38 +0000 (21:22 +0200)] 
lsblk: use blkdev_scsi_type_to_name()

Replace inline version of similar, but less complete, functionality
with the lib/blkdev.c function.  The function will inform if a type is
unknown, which appears as hex string value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agoblkdev: add blkdev_scsi_type_to_name()
Sami Kerola [Mon, 11 Jun 2012 19:17:38 +0000 (21:17 +0200)] 
blkdev: add blkdev_scsi_type_to_name()

Add a function, and necessary symbols, to convert scsi type id's
to name strings.

Reference: http://permalink.gmane.org/gmane.linux.utilities.util-linux-ng/5994
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agowipefs: use symbolic value for markup mode
Sami Kerola [Sun, 10 Jun 2012 20:20:34 +0000 (22:20 +0200)] 
wipefs: use symbolic value for markup mode

In case mode value is found to be out of bounds program will crash.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agoeject: inform if CD-ROM drive is not ready
Sami Kerola [Sun, 10 Jun 2012 20:03:57 +0000 (22:03 +0200)] 
eject: inform if CD-ROM drive is not ready

Include file (see linux/cdrom.h lines 395 and 398) suggests ioctl() can
return CDS_NO_INFO and CDS_DRIVE_NOT_READY, which where ignored.  This
commit will tell user what is going on.

The commit will also make eject to crash in ioctl() will return
unexpected value.

Reference: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=include/linux/cdrom.h;h=dfd7f187c351440d2ffa81050e46ed2602877f73;hb=HEAD
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agodocs: clean up partx.8 manual
Sami Kerola [Sun, 10 Jun 2012 16:20:48 +0000 (18:20 +0200)] 
docs: clean up partx.8 manual

* Remove bold & italic noise.
* Reformat text to be 70 characters wide.
* Use option and option argument highlights consistently.
* Indent option argument list for --nr.
* Squeeze examples where the same is done multiple different ways.
* Use URL and email macros where appropriate.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agoinclude: fix void pointer arithmetics warnings
Sami Kerola [Sun, 10 Jun 2012 14:49:51 +0000 (16:49 +0200)] 
include: fix void pointer arithmetics warnings

all-io.h:18:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]
all-io.h:38:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agosysfs: fix printf format warnings
Sami Kerola [Sun, 10 Jun 2012 14:48:31 +0000 (16:48 +0200)] 
sysfs: fix printf format warnings

sysfs.c:93:3: warning: format '%u' expects argument of type 'unsigned
int *', but argument 3 has type 'int *' [-Wformat]
sysfs.c:93:3: warning: format '%u' expects argument of type 'unsigned
int *', but argument 4 has type 'int *' [-Wformat]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agobuild: fix unused parameter warnings
Sami Kerola [Sun, 10 Jun 2012 14:44:54 +0000 (16:44 +0200)] 
build: fix unused parameter warnings

pager.c:203:14: warning: unused parameter 'argc' [-Wunused-parameter]
pager.c:203:26: warning: unused parameter 'argv' [-Wunused-parameter]

randutils.c:108:14: warning: unused parameter 'argc' [-Wunused-parameter]
randutils.c:108:26: warning: unused parameter 'argv' [-Wunused-parameter]

optstr.c:774:37: warning: unused parameter 'optstr' [-Wunused-parameter]
optstr.c:774:51: warning: unused parameter 'value' [-Wunused-parameter]
optstr.c:774:65: warning: unused parameter 'valsz' [-Wunused-parameter]
optstr.c:774:79: warning: unused parameter 'next' [-Wunused-parameter]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agobuild: fix redundant redeclaration warnings
Sami Kerola [Sun, 10 Jun 2012 14:37:11 +0000 (16:37 +0200)] 
build: fix redundant redeclaration warnings

env.c:24:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]
su.c:81:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]

fstab.c:581:14: warning: redundant redeclaration of 'strsignal' [-Wredundant-decls]

kill.h:1:13: note: previous declaration of 'get_pids' was here
kill.c:152:13: warning: redundant redeclaration of 'get_pids' [-Wredundant-decls]

kill.c:142:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]
getopt.c:89:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]

agetty.c:536:15: warning: redundant redeclaration of 'optarg' [-Wredundant-decls]
agetty.c:537:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
script.c:161:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
wall.c:96:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]

libmount.h:362:26: note: previous declaration of 'mnt_update_get_fs' was here
libmount.h:454:26: note: previous declaration of 'mnt_context_get_fs' was here
mountP.h:383:26: warning: redundant redeclaration of 'mnt_context_get_fs' [-Wredundant-decls]
mountP.h:398:26: warning: redundant redeclaration of 'mnt_update_get_fs' [-Wredundant-decls]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agoinclude: fix spurious list.h warnings
Sami Kerola [Sun, 10 Jun 2012 09:09:08 +0000 (11:09 +0200)] 
include: fix spurious list.h warnings

include/list.h:224:17: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]
include/list.h:255:19: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]

Compilation warned about that at least 110 times.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agouuidd: use output redirection which works [checkbashisms]
Sami Kerola [Sat, 9 Jun 2012 21:20:04 +0000 (23:20 +0200)] 
uuidd: use output redirection which works [checkbashisms]

possible bashism in misc-utils/uuidd.rc line 52 (should be >word 2>&1):
if pidofproc -p $PIDFILE $DAEMON >& /dev/null ; then

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agoblkid: fix realloc memory leak [cppcheck]
Sami Kerola [Sat, 9 Jun 2012 21:05:23 +0000 (23:05 +0200)] 
blkid: fix realloc memory leak [cppcheck]

[misc-utils/blkid.c:367]: (error) Common realloc mistake: 'str' nulled but not freed upon failure

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agosetarch: do not use -1 as array index [cppcheck]
Sami Kerola [Sat, 9 Jun 2012 20:45:27 +0000 (22:45 +0200)] 
setarch: do not use -1 as array index [cppcheck]

Negative array index does technically work, but looks awkward and
can confuse static analyser such as cppcheck.

[sys-utils/setarch.c:267]: (error) Array index -1 is out of bounds

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
13 years agobuild-sys: add compiler warnings
Karel Zak [Wed, 6 Jun 2012 10:10:41 +0000 (12:10 +0200)] 
build-sys: add compiler warnings

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agofdisk: fix io_size usage in new API
Karel Zak [Wed, 6 Jun 2012 09:03:23 +0000 (11:03 +0200)] 
fdisk: fix io_size usage in new API

properly implemented fdisk_dev_has_topology() requires optimal
I/O size to detect that the device provides topology.

Unfortunately, currently used cxt->io_size maybe overwritten in
__discover_topology() to min_io_size.

This patch introduces cxt->optimal_io_size and keeps it independent on
cxt->io_size. The cxt->io_size is I/O size used by fdisk for alignment
calculation.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agofdisk: fix compiler warning [-Wunused-variable]
Karel Zak [Wed, 6 Jun 2012 08:56:29 +0000 (10:56 +0200)] 
fdisk: fix compiler warning [-Wunused-variable]

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agofdisk: fix compiler warning [-Wpointer-sign]
Karel Zak [Wed, 6 Jun 2012 08:53:20 +0000 (10:53 +0200)] 
fdisk: fix compiler warning [-Wpointer-sign]

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agofdisk: fix compiler warnings [-Wsign-compare]
Karel Zak [Wed, 6 Jun 2012 08:48:26 +0000 (10:48 +0200)] 
fdisk: fix compiler warnings [-Wsign-compare]

Signed-off-by: Karel Zak <kzak@redhat.com>
13 years agofdisk: remove user specified sector size global variable
Davidlohr Bueso [Sun, 3 Jun 2012 17:47:44 +0000 (19:47 +0200)] 
fdisk: remove user specified sector size global variable

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: add fdisk_dev_sectsz_is_default helper
Davidlohr Bueso [Sun, 3 Jun 2012 18:15:34 +0000 (20:15 +0200)] 
fdisk: add fdisk_dev_sectsz_is_default helper

Instead of printing this warning from the API, add a helper and call it from
fdisk logic.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: use EXIT_SUCCESS for -l option
Davidlohr Bueso [Sun, 3 Jun 2012 18:15:30 +0000 (20:15 +0200)] 
fdisk: use EXIT_SUCCESS for -l option

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: add total sectors
Davidlohr Bueso [Sun, 3 Jun 2012 18:15:20 +0000 (20:15 +0200)] 
fdisk: add total sectors

Add the total_sectors variable to the context structure. This is the initial
geometry information.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: add device topology to the API
Davidlohr Bueso [Sun, 3 Jun 2012 18:15:17 +0000 (20:15 +0200)] 
fdisk: add device topology to the API

This patch adds device topology discovery to the internal API. This
functionality is static only to the API and therefore hidden from general fdisk
code. Functionality itself doesn't really change, min_io_size, io_size, logical
and physical sector sizes and alignment offset are added to the fdisk_context
structure and elements are accessed from there. The logical sector size
(sector_size) is now unsigned long instead of unsigned int, this as no effect
otherwise.

A few things to notice:
 - The patch is larger than I wanted but we need to modify function parameters
   across fdisk and its labels to use the topology data from cxt-> instances.
   Hopefully this will be pretty much it regarding this kind of modifications -
   perhaps geometry will need something of the like too.

 - The -b option must override internal discovery.

 - A new helper function has added to verify if the device provides topology
   information, this replaces the 'has_topology' global variable.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: sun: use sector_t
Davidlohr Bueso [Sun, 27 May 2012 19:44:24 +0000 (21:44 +0200)] 
fdisk: sun: use sector_t

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: sgi: use sector_t
Davidlohr Bueso [Sun, 27 May 2012 19:44:20 +0000 (21:44 +0200)] 
fdisk: sgi: use sector_t

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: dos: use sector_t
Davidlohr Bueso [Sun, 27 May 2012 19:44:17 +0000 (21:44 +0200)] 
fdisk: dos: use sector_t

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: introduce sector_t type
Davidlohr Bueso [Sun, 27 May 2012 19:44:13 +0000 (21:44 +0200)] 
fdisk: introduce sector_t type

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: remove useless comments
Davidlohr Bueso [Sun, 27 May 2012 19:44:07 +0000 (21:44 +0200)] 
fdisk: remove useless comments

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: use context as a parameter
Davidlohr Bueso [Sun, 27 May 2012 19:44:04 +0000 (21:44 +0200)] 
fdisk: use context as a parameter

This program heavily uses global variables, which isn't very elegant and can
lead to nasty bugs. Modify functions that use fdisk's context current features
(descriptor and path), to receive the context as a parameter instead of
globally. This includes DOS, SUN, SGI and BSD label code. Another benefit that
comes with this is that as the API grows all the information regarding fdisk
will be accessible from this structure so we can reduce even more global
variables and simply code.

This patch passed:
 - building
 - regression tests
 - local dos/sun/bsd partition changes

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agofdisk: stop buffering welcome message
Davidlohr Bueso [Sun, 27 May 2012 19:43:56 +0000 (21:43 +0200)] 
fdisk: stop buffering welcome message

Recently, commit 0a86755fe8af1da510d2eca43bdfcd70af098c19 directed the welcome
message output from stderr to stdout breaking regression tests.  Correct this
by flushing stdout and stop buffering the output - a trivial function is
created as well.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
13 years agobuild-sys: suid su in make install
Karel Zak [Tue, 5 Jun 2012 15:38:09 +0000 (17:38 +0200)] 
build-sys: suid su in make install

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