]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
10 years agotests: add fullpath tests to rename/subdir
Andreas Henriksson [Mon, 22 Jun 2015 17:22:34 +0000 (19:22 +0200)] 
tests: add fullpath tests to rename/subdir

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
10 years agocal: correct the man page: the reformation eliminated eleven days, not ten
Benno Schulenberg [Wed, 24 Jun 2015 18:58:06 +0000 (20:58 +0200)] 
cal: correct the man page: the reformation eliminated eleven days, not ten

Also tweak some other wordings and formatting.

Reported-by: Felix Neumann <felix.neumann@inka.de>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agoMerge branch 'script'
Karel Zak [Thu, 25 Jun 2015 09:56:02 +0000 (11:56 +0200)] 
Merge branch 'script'

* script: (25 commits)
  script: add note to BUGS man page section
  script: fix EOF problems
  script: improve poll debugging
  script: cleanup signals usage
  script: debug poll() results
  script: add support for SCRIPT_DEBUG=
  script: remove magic constants from poll code
  script: rename control struct members
  script: close timingfp also when -e
  tests: add scriptreplay test
  script: move timing file opening close to use of it
  script: add noreturn function attributes
  script: use gettime_monotonic() to get timing file timestamps
  script: use correct input type, move comment, and so on
  script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
  script: move do_io() content to small functions
  script: add 'Script started' line always to capture file
  script: remove io vs signal race
  script: merge doinput() and output() functions to do_io()
  script: use poll() rather than select()
  ...

10 years agoscript: add note to BUGS man page section
Karel Zak [Thu, 25 Jun 2015 09:55:42 +0000 (11:55 +0200)] 
script: add note to BUGS man page section

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: add note about kern->user conversion
Karel Zak [Wed, 24 Jun 2015 10:17:32 +0000 (12:17 +0200)] 
logger: add note about kern->user conversion

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add GPT GUIDs for ARMs
Karel Zak [Mon, 22 Jun 2015 09:56:43 +0000 (11:56 +0200)] 
libfdisk: add GPT GUIDs for ARMs

Addresses: https://github.com/karelzak/util-linux/issues/203
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: improve monitor to be usable for non-root users
Karel Zak [Fri, 19 Jun 2015 10:17:45 +0000 (12:17 +0200)] 
libmount: improve monitor to be usable for non-root users

The current implementation calls mkdir and open(O_CREATE) to
initialize /run/mount/utab.lock before it starts to monitor the file.
Unfortunately it makes the monitor useless for non-root processes
(e.g. systemd --user).

The new implementation adds inotify watch for the last existing
component in the path (/run/mount/utab.lock) and re-initialize
after a change. It makes the monitor robust enough for mkdir/rmdir
when monitor is already active.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibuuid: return correct value for uuid_generate_time_safe
Romain Bouvier [Wed, 17 Jun 2015 15:59:18 +0000 (15:59 +0000)] 
libuuid: return correct value for uuid_generate_time_safe

Make return value consistent for consecutive calls.  If you call
uuid_generate_time_safe, it should always return -1 if it can't guarantee
uniqueness.  Without this patch, on consecutive calls where it can't guarantee
uniqueness, the first call returns -1, but later calls return 0.

Reported-by: Romain Bouvier <skunnyk@alteroot.org>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
10 years agolibfdisk: ignore misaligned optimal I/O size
Karel Zak [Thu, 18 Jun 2015 09:55:29 +0000 (11:55 +0200)] 
libfdisk: ignore misaligned optimal I/O size

For example:

 # modprobe scsi_debug dev_size_mb=1000 opt_blks=65535 physblk_exp=3

creates a disk with:

 Sector size (logical/physical): 512 bytes / 4096 bytes
 I/O size (minimum/optimal): 4096 bytes / 33553920 bytes

where 33553920 % 4096 != 0, it means that use Optimal I/O size to
align partition results that partition is not aligned to physical
sector boundary.

Reported-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: fix EOF problems
Karel Zak [Wed, 17 Jun 2015 13:48:50 +0000 (15:48 +0200)] 
script: fix EOF problems

* remove STDIN from poll() if:

  * STDIN already closed -- poll returns POLLHUP, for example:

echo "date" | script

  * detect EOF as returned by read(), for example:

script -c "echo Hello" < /dev/null

* don't write to master when there is still something to read from
  slave (it means shell is not initialized yet or busy)

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: improve poll debugging
Karel Zak [Wed, 17 Jun 2015 11:33:35 +0000 (13:33 +0200)] 
script: improve poll debugging

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: cleanup signals usage
Karel Zak [Wed, 17 Jun 2015 11:25:46 +0000 (13:25 +0200)] 
script: cleanup signals usage

 * don't call anything from assert()
 * fork() block cleanup to make it more readable
 * restore original signal mask in child (do_shell())
 * close signal FD in child (do_shell())

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosfdisk: improve some formatting and wording in the man page
Benno Schulenberg [Wed, 17 Jun 2015 06:28:33 +0000 (08:28 +0200)] 
sfdisk: improve some formatting and wording in the man page

The main fix is: giving -J, --json its own paragraph.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agosfdisk: show that the command --verify optionally takes device names
Benno Schulenberg [Wed, 17 Jun 2015 06:28:32 +0000 (08:28 +0200)] 
sfdisk: show that the command --verify optionally takes device names

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agotests: always kill helper
Ruediger Meier [Fri, 8 May 2015 22:34:12 +0000 (00:34 +0200)] 
tests: always kill helper

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agoprocutils: reset errno before readdir
Ruediger Meier [Fri, 8 May 2015 22:47:33 +0000 (00:47 +0200)] 
procutils: reset errno before readdir

readdir(3p): "When the end of the directory is encountered, a null
pointer shall be returned and errno is not changed"

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agoscript: debug poll() results
Karel Zak [Tue, 16 Jun 2015 12:43:59 +0000 (14:43 +0200)] 
script: debug poll() results

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: add support for SCRIPT_DEBUG=
Karel Zak [Tue, 16 Jun 2015 12:03:09 +0000 (14:03 +0200)] 
script: add support for SCRIPT_DEBUG=

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: remove magic constants from poll code
Karel Zak [Tue, 16 Jun 2015 11:11:05 +0000 (13:11 +0200)] 
script: remove magic constants from poll code

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: rename control struct members
Karel Zak [Tue, 16 Jun 2015 10:34:04 +0000 (12:34 +0200)] 
script: rename control struct members

Sorry, but it's really ugly manner to use "xflg" where "x" is a command
line option as program variable and use it in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: close timingfp also when -e
Karel Zak [Tue, 16 Jun 2015 10:26:00 +0000 (12:26 +0200)] 
script: close timingfp also when -e

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoMerge branch 'script3' of git://github.com/kerolasa/lelux-utiliteetit into script
Karel Zak [Tue, 16 Jun 2015 09:53:18 +0000 (11:53 +0200)] 
Merge branch 'script3' of git://github.com/kerolasa/lelux-utiliteetit into script

* 'script3' of git://github.com/kerolasa/lelux-utiliteetit:
  tests: add scriptreplay test
  script: move timing file opening close to use of it
  script: add noreturn function attributes
  script: use gettime_monotonic() to get timing file timestamps
  script: use correct input type, move comment, and so on
  script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
  script: move do_io() content to small functions
  script: add 'Script started' line always to capture file
  script: remove io vs signal race
  script: merge doinput() and output() functions to do_io()
  script: use poll() rather than select()
  script: use signalfd() to catch signals
  script: add struct script_control and remove global variables
  script: remove function prototypes
  tests: check script options work as expected
  tests: add script output buffering race check

10 years agochrt: slice up the usage text and normalize its layout
Benno Schulenberg [Thu, 11 Jun 2015 09:04:02 +0000 (11:04 +0200)] 
chrt: slice up the usage text and normalize its layout

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agochrt: make the usage synopsis clearer
Benno Schulenberg [Thu, 11 Jun 2015 09:04:01 +0000 (11:04 +0200)] 
chrt: make the usage synopsis clearer

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agolosetup: be careful with errno
Karel Zak [Mon, 15 Jun 2015 12:54:15 +0000 (14:54 +0200)] 
losetup: be careful with errno

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: add JSON sfdisk dumps
Karel Zak [Mon, 15 Jun 2015 12:02:36 +0000 (14:02 +0200)] 
tests: add JSON sfdisk dumps

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosfdisk: add --json
Karel Zak [Mon, 15 Jun 2015 11:23:36 +0000 (13:23 +0200)] 
sfdisk: add --json

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add JSON dump output
Karel Zak [Mon, 15 Jun 2015 11:18:09 +0000 (13:18 +0200)] 
libfdisk: add JSON dump output

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: rename script functions to improve readability
Karel Zak [Mon, 15 Jun 2015 08:38:38 +0000 (10:38 +0200)] 
libfdisk: rename script functions to improve readability

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: update fdisk BSD
Karel Zak [Thu, 11 Jun 2015 13:13:17 +0000 (15:13 +0200)] 
tests: update fdisk BSD

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add new API to read label specific data
Karel Zak [Thu, 11 Jun 2015 12:19:47 +0000 (14:19 +0200)] 
libfdisk: add new API to read label specific data

* removes list() label operation from internal API

  The list() has been based on fdisk_info() it was useless for
  anything else than print on stdout...

* add a new get_item() label operation and fdisk_get_disklabel_item() public API

  The new API provides abstract and pretty simple way how to get label
  specific disk label information, for example

     fdisk_get_disklabel_item(cxt, GPT_LABELITEM_ENTRIESLBA, &iterm);

  return LBA of the array with GPT entries.

  Note that this patch does not implement public functions to get
  data from the @item object.

* removes get_id() label operation -- it's subset of the new get_item()

* the new internal API is also used to implement backwardly compatible
  fdisk_list_disklabel() and fdisk_get_disklabel_id()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (dos) fix cylinders calculation
Karel Zak [Wed, 10 Jun 2015 14:55:29 +0000 (16:55 +0200)] 
libfdisk: (dos) fix cylinders calculation

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofstrim: de-duplicate by mount source too
Karel Zak [Wed, 10 Jun 2015 12:19:45 +0000 (14:19 +0200)] 
fstrim: de-duplicate by mount source too

Now fstrim de-duplicates by target (mountpoint). This patch adds
de-duplication according to mount source (device) to avoid bind mounts
or devices mounted more than once. Note that the patch also check FS
root, the different FS roots of the same multi-root FS (e.g. btrfs)
maybe mounted on different places.

  # mount --bind /home/wine /mnt/test

old version:

  # fstrim -av
  /mnt/test: 0 B (0 bytes) trimmed            <---
  /home/wine: 0 B (0 bytes) trimmed           <---
  /boot: 0 B (0 bytes) trimmed
  /home: 0 B (0 bytes) trimmed
  /: 0 B (0 bytes) trimmed

new version:

  # fstrim -av
  /mnt/test: 0 B (0 bytes) trimmed            <---
  /boot: 0 B (0 bytes) trimmed
  /home: 171.8 MiB (180113408 bytes) trimmed
  /: 0 B (0 bytes) trimmed

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1162213
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk: differentiate between +<sector> and +<size>{M,G,...}
Karel Zak [Wed, 10 Jun 2015 10:45:53 +0000 (12:45 +0200)] 
fdisk: differentiate between +<sector> and +<size>{M,G,...}

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibblkid: (nilfs2) check size for backup superblock only
Karel Zak [Tue, 9 Jun 2015 13:53:20 +0000 (15:53 +0200)] 
libblkid: (nilfs2) check size for backup superblock only

The size of the device seems irrelevant for the primary superblock.
The primary superblock is stored on fixed offset, possible collision
between last partition and whole-disk is possible only for backup
superblock only.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agochrt: fix --help inconsistency
Karel Zak [Tue, 9 Jun 2015 09:16:45 +0000 (11:16 +0200)] 
chrt: fix --help inconsistency

Reported-by: Martin Steigerwald <ms@teamix.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibblkid: (nilfs2) check devise size
Karel Zak [Tue, 9 Jun 2015 08:37:11 +0000 (10:37 +0200)] 
libblkid: (nilfs2) check devise size

Unfortunately, nilfs2 have the same problem like many RAIDs. It uses
the end of the device to store (backup) superblock. The end of the
last partition is the same location as the end of the whole-disk. It
means that the superblock seems valid for the last partitions as well
as for whole-device.

Fortunately, nilfs2 superblock contains size of the device, so we can
distinguish between whole-disk and partition device.

Reported-by: Heinz Diehl <htd+ml@fritha.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: add scriptreplay test
Sami Kerola [Sun, 31 May 2015 21:23:14 +0000 (22:23 +0100)] 
tests: add scriptreplay test

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: move timing file opening close to use of it
Sami Kerola [Tue, 3 Mar 2015 22:06:01 +0000 (22:06 +0000)] 
script: move timing file opening close to use of it

This allows removing almost immediate closure of file handle in the
doshell() function that does not use the file.

Proposed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: add noreturn function attributes
Sami Kerola [Tue, 30 Dec 2014 23:22:33 +0000 (23:22 +0000)] 
script: add noreturn function attributes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: use gettime_monotonic() to get timing file timestamps
Sami Kerola [Tue, 30 Dec 2014 23:03:32 +0000 (23:03 +0000)] 
script: use gettime_monotonic() to get timing file timestamps

This moves the previous time to script control structure, and does
timeval calculation with timersub() that is more appropriate than
making a timeval to a double.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: use correct input type, move comment, and so on
Sami Kerola [Sat, 27 Dec 2014 10:14:28 +0000 (10:14 +0000)] 
script: use correct input type, move comment, and so on

Minor corrections.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: replace strftime() workaround with CFLAGS = -Wno-format-y2k
Sami Kerola [Sat, 27 Dec 2014 09:32:45 +0000 (09:32 +0000)] 
script: replace strftime() workaround with CFLAGS = -Wno-format-y2k

Nowadays, gcc(1) provides the -Wno-format-y2k option to prevent the
warning, so that the above workaround is no longer required.

Reference: http://man7.org/linux/man-pages/man3/strftime.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: move do_io() content to small functions
Sami Kerola [Fri, 26 Dec 2014 22:32:25 +0000 (22:32 +0000)] 
script: move do_io() content to small functions

The do_io() got to be a bit long with relatively deep indentation.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: add 'Script started' line always to capture file
Sami Kerola [Fri, 26 Dec 2014 17:57:46 +0000 (17:57 +0000)] 
script: add 'Script started' line always to capture file

The scriptreplay(1) will expect capture file always to have header.
Before this change the --quiet option together with timing caused
following replay error.

$ script --quiet --timing=timing
[...]
$ scriptreplay timing typescript
[...]
scriptreplay: unexpected end of file on typescript

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: remove io vs signal race
Sami Kerola [Fri, 26 Dec 2014 17:43:49 +0000 (17:43 +0000)] 
script: remove io vs signal race

Make do_io() to run poll() until all streams are empty.  This should
remove the signal from child versus io handling race for good.

Addresses: https://github.com/karelzak/util-linux/pull/62
Addresses: https://bugs.launchpad.net/bugs/264967
Addresses: https://bugs.debian.org/305808
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: merge doinput() and output() functions to do_io()
Sami Kerola [Fri, 26 Dec 2014 15:57:02 +0000 (15:57 +0000)] 
script: merge doinput() and output() functions to do_io()

One item to poll() more is a lot less work for system than separete input
and output processes.

Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolibfdisk: improve +0 partition size
Karel Zak [Mon, 8 Jun 2015 15:26:31 +0000 (17:26 +0200)] 
libfdisk: improve +0 partition size

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (dos) fix tiny partitions calculation
Karel Zak [Mon, 8 Jun 2015 14:45:15 +0000 (16:45 +0200)] 
libfdisk: (dos) fix tiny partitions calculation

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) make it possible to create really small partitions
Karel Zak [Mon, 8 Jun 2015 14:02:17 +0000 (16:02 +0200)] 
libfdisk: (gpt) make it possible to create really small partitions

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: support alignment to non power of 2
Karel Zak [Mon, 8 Jun 2015 13:41:33 +0000 (15:41 +0200)] 
libfdisk: support alignment to non power of 2

Let's create a disk with 33553920 bytes optimal I/O size:

# modprobe scsi_debug dev_size_mb=1000 opt_blks=65535

and try to create partition:

 echo -e 'n\n\n\n\n+512M\np\nq\n'  | fdisk /dev/sdc

old version:

 Device     Boot Start     End Sectors  Size Id Type
 /dev/sdc1       65535 1114110 1048576  512M 83 Linux

The next partition will be expected on sector 1114110 + 1, but it's
not aligned to optimal I/O:

        ((1114110 + 1) * 512) % 33553920 = 8192

fixed version:

 Device     Boot Start     End Sectors  Size Id Type
 /dev/sdc1       65535 1114094 1048560  512M 83 Linux

        ((1114094 + 1) * 512) % 33553920 = 0

Note that the same problem with alignment calculation has been fixed
in Linux kernel by commit b8839b8c55f3fdd60dc36abcda7e0266aff7985c
(Oct 2014).

The patch also improves fdisk_align_lba_in_range() to not align sizes
smaller than grain (default 1MiB) to make it possible to create really
small partitions.

Reported-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosulogin: Use read instead of allocated size from getline()
Guillem Jover [Sat, 6 Jun 2015 04:26:43 +0000 (06:26 +0200)] 
sulogin: Use read instead of allocated size from getline()

The getline function distinguishes between the allocated and read
lenghts, and we should not mix them up, as we might end up processing
junk.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
10 years agoinclude/c: Define F_DUPFD_CLOEXEC on kFreeBSD systems if missing
Guillem Jover [Sat, 6 Jun 2015 04:19:07 +0000 (06:19 +0200)] 
include/c: Define F_DUPFD_CLOEXEC on kFreeBSD systems if missing

The kernel of FreeBSD version 10 and higher supports this fcntl command,
but the system libc, in this case glibc, might not yet know about it.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
10 years agolib/sysfs: Use dup_fd_cloexec instead of direct call to fcntl
Guillem Jover [Sat, 6 Jun 2015 04:19:06 +0000 (06:19 +0200)] 
lib/sysfs: Use dup_fd_cloexec instead of direct call to fcntl

Signed-off-by: Guillem Jover <guillem@hadrons.org>
10 years agolib/fileutils: Add new dup_fd_cloexec function
Guillem Jover [Sat, 6 Jun 2015 04:19:05 +0000 (06:19 +0200)] 
lib/fileutils: Add new dup_fd_cloexec function

This function duplicates and marks a file descriptor as close-on-exec.
Takes care of build and run-time support for the fcntl F_DUPFD_CLOEXEC
command, and other errors.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
10 years agoman: fix nolazytime typo in mount(8)
Andreas Henriksson [Wed, 3 Jun 2015 16:32:09 +0000 (18:32 +0200)] 
man: fix nolazytime typo in mount(8)

Avoids double negation...

Addresses: http://bugs.debian.org/786554
Reported-by: Felix Zielcke <fzielcke@z-51.de>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
10 years agobash-completion: remove unused variables [shellcheck]
Boris Egorov [Tue, 2 Jun 2015 17:59:03 +0000 (23:59 +0600)] 
bash-completion: remove unused variables [shellcheck]

Fix shellcheck SC2034 warnings.

Signed-off-by: Boris Egorov <egorov@linux.com>
10 years agobash-completion: sync lscpu completion with code
Boris Egorov [Tue, 2 Jun 2015 17:59:02 +0000 (23:59 +0600)] 
bash-completion: sync lscpu completion with code

Remove unexistent option, add two not listed in completion.

Signed-off-by: Boris Egorov <egorov@linux.com>
10 years agobash-completion: handle comma-separated options
Boris Egorov [Tue, 2 Jun 2015 17:59:01 +0000 (23:59 +0600)] 
bash-completion: handle comma-separated options

This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:

    $ partx --output END,SECTORS,SCHEME,START,

You got these completions:

    END,SECTORS,SCHEME,START,FLAGS,  END,SECTORS,SCHEME,START,NR,
    END,SECTORS,SCHEME,START,TYPE,
    END,SECTORS,SCHEME,START,NAME,   END,SECTORS,SCHEME,START,SIZE,
    END,SECTORS,SCHEME,START,UUID,

Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.

Few issues remained:

    * completion interrupts after encountering ':' in listed option,
    like in 'MAJ:MIN' in lsblk, losetup.
    * lscpu completion is broken: it inserts space after '--extended',
    but lscpu assumes there is no space after this option. It also
    doesn't complete '--parse' option.
    * some completion options are outdated (for example, lscpu MMHZ). We
    need to sync them with code. Fix for lscpu follows.

Signed-off-by: Boris Egorov <egorov@linux.com>
10 years agoscript: use poll() rather than select()
Sami Kerola [Fri, 26 Dec 2014 12:37:36 +0000 (12:37 +0000)] 
script: use poll() rather than select()

Finalize the signalfd() change by adding file descriptors to poll() loop.

Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: use signalfd() to catch signals
Sami Kerola [Fri, 26 Dec 2014 11:51:00 +0000 (11:51 +0000)] 
script: use signalfd() to catch signals

This is incomplete change.  Working command requires the subsequent
select() to poll() change as well.

Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: add struct script_control and remove global variables
Sami Kerola [Sat, 20 Dec 2014 01:05:49 +0000 (01:05 +0000)] 
script: add struct script_control and remove global variables

Fix also couple indentation issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoscript: remove function prototypes
Sami Kerola [Sat, 20 Dec 2014 00:02:42 +0000 (00:02 +0000)] 
script: remove function prototypes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: check script options work as expected
Sami Kerola [Sun, 24 May 2015 17:14:58 +0000 (18:14 +0100)] 
tests: check script options work as expected

Options --flush and --timing remain unchecked, as I do not have an idea
how to check them reliably.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: add script output buffering race check
Sami Kerola [Sun, 24 May 2015 16:48:05 +0000 (17:48 +0100)] 
tests: add script output buffering race check

Regression check to a fix by Stanislav Brabec.

Reference: 0b285b84b2f14339fd86857244654ba25fac7d73
CC: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolibsmartcols: keep JSON field names lower-case
Karel Zak [Fri, 5 Jun 2015 09:58:42 +0000 (11:58 +0200)] 
libsmartcols: keep JSON field names lower-case

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolslocks: add --json
Karel Zak [Fri, 5 Jun 2015 08:45:15 +0000 (10:45 +0200)] 
lslocks: add --json

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolosetup: add --json
Karel Zak [Fri, 5 Jun 2015 08:30:52 +0000 (10:30 +0200)] 
losetup: add --json

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofindmnt: add --json
Karel Zak [Fri, 5 Jun 2015 07:47:59 +0000 (09:47 +0200)] 
findmnt: add --json

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolsblk: add --json
Karel Zak [Thu, 4 Jun 2015 13:49:52 +0000 (15:49 +0200)] 
lsblk: add --json

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibsmartcols: add JSON output format
Karel Zak [Thu, 4 Jun 2015 13:47:21 +0000 (15:47 +0200)] 
libsmartcols: add JSON output format

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: (docs) fix wording
Ronny Chevalier [Wed, 3 Jun 2015 11:21:52 +0000 (13:21 +0200)] 
libmount: (docs) fix wording

Signed-off-by: Ronny Chevalier <chevalier.ronny@gmail.com>
10 years agolibmount: (docs) fix typo
Ronny Chevalier [Wed, 3 Jun 2015 11:06:59 +0000 (13:06 +0200)] 
libmount: (docs) fix typo

Signed-off-by: Ronny Chevalier <chevalier.ronny@gmail.com>
10 years agolosetup: print more usable error message on failed -f
Karel Zak [Wed, 3 Jun 2015 10:05:09 +0000 (12:05 +0200)] 
losetup: print more usable error message on failed -f

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1215370
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: do not call umount helper on --fake
Karel Zak [Wed, 3 Jun 2015 08:59:35 +0000 (10:59 +0200)] 
libmount: do not call umount helper on --fake

The umount.<type> helpers does not support --fake option and it does
not make sense to call the helpers at all. All we need is to remove
mtab/utab entries.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1172297
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolscpu: add warning for __SANITIZE_ADDRESS__
Karel Zak [Tue, 2 Jun 2015 12:52:56 +0000 (14:52 +0200)] 
lscpu: add warning for __SANITIZE_ADDRESS__

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosys-utils: lscpu segfaults when built with -fsanitize=address
Cristian Rodríguez [Sat, 30 May 2015 18:51:41 +0000 (15:51 -0300)] 
sys-utils: lscpu segfaults when built with -fsanitize=address

This is expected and a false positive, exclude the vmware detection
trick when __SANITIZE_ADDRESS__ is defined.

10 years agolsblk.8: Fix description of output format
Stanislav Brabec [Thu, 28 May 2015 15:41:39 +0000 (17:41 +0200)] 
lsblk.8: Fix description of output format

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
10 years agolibmount: fix mnt_monitor_event_cleanup()
Karel Zak [Mon, 1 Jun 2015 11:17:41 +0000 (13:17 +0200)] 
libmount: fix mnt_monitor_event_cleanup()

We have to call epoll to drain mountinfo events too. The problem is
visible if the monitor epoll FD is within another (top-level) epoll.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolsblk: use internally sysfs devnames
Karel Zak [Fri, 29 May 2015 08:55:01 +0000 (10:55 +0200)] 
lsblk: use internally sysfs devnames

It seems better to keep the strange sysfs devnames internally and
translate to real devnames only on output or when we read from /dev.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agodocs: fix gtk-docs related warnings
Karel Zak [Thu, 28 May 2015 10:28:23 +0000 (12:28 +0200)] 
docs: fix gtk-docs related warnings

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/sysfs: rename devname functions, cleanup
Karel Zak [Thu, 28 May 2015 10:09:41 +0000 (12:09 +0200)] 
lib/sysfs: rename devname functions, cleanup

Well, I don't have mental power to use function names like

 sysfs_devname_to_dev_name()

so this patch renames to

 sysfs_devname_sys_to_dev()
 sysfs_devname_dev_to_sys()

It also cleanups usage of the functions. We have to be sure that
sysfs.c code returns regular devnames. The existence of the sysfs
devnames (with '!') should be completely hidden in sysfs specific
code.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/sysfs: Fix /dev to /sys node name translation
Stanislav Brabec [Wed, 27 May 2015 13:12:08 +0000 (15:12 +0200)] 
lib/sysfs: Fix /dev to /sys node name translation

d0dc6c1 introduced translation of /sys names to /dev names, as required
by the kernel linux/drivers/base/core.c: device_get_devnode(). But there
are other places of code that use /dev names in /sys. They need reverse
translation from '/' to '!'.

For example, fdisk -l returns empty list since a22c6eb for device nodes
in subdirectories (used e. g. by cciss driver).

Introduce yet another helper sysfs_dev_name_to_devname() and use it where
appropriate.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
10 years agolibfdisk: Use predictable /dev/mapper partition names for /dev/dm-N
Stanislav Brabec [Tue, 26 May 2015 15:59:29 +0000 (17:59 +0200)] 
libfdisk: Use predictable /dev/mapper partition names for /dev/dm-N

It is impossible to predict /dev/dm-N partition names. Use predictable
and better readable /dev/mapper names instead.

[kzak@redhat.com: - remove if-before-free]

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoUse correct partition names for /dev/mapper
Stanislav Brabec [Mon, 25 May 2015 19:17:52 +0000 (21:17 +0200)] 
Use correct partition names for /dev/mapper

The default configuration of multipath-tools appends "-partN" to
partition nodes. Follow this conventions and do the same.

It fixes for example fdisk -l /dev/mapper/name_of_the_device.

Note that the current implementation only partially fixes the problem. It
does not reflect any udev configuration changes, as udev does not provide
any function to return names of future (or current) partitions of a
particular device. It also does not fix fdisk -l /dev/dm-0.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
10 years agoFix /sys to /dev node name translation
Stanislav Brabec [Mon, 25 May 2015 16:21:36 +0000 (18:21 +0200)] 
Fix /sys to /dev node name translation

linux/drivers/base/core.c: device_get_devnode() defines a translation of
'!' in sysfs nodes to '/' in /dev nodes. The same translation has to be
done to properly support device nodes with slash (e. g. device nodes of
cciss driver and several other drivers).

Introduce new helper sysfs_devname_to_devno() and use it where
appropriate.

Fixes for example lsblk -f on devices using cciss driver.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
10 years agohwclock: don't allow non-root access
Karel Zak [Tue, 26 May 2015 08:32:38 +0000 (10:32 +0200)] 
hwclock: don't allow non-root access

Fortunately very few people are crazy enough to install hwclock as
setuid. Some comments in code and unfortunately also man page
advertising that setuid is no problem. That's pretty stupid promise.

The code quality is poor and it's obviously not designed to be secure
(things like popen() without drop privileges, etc.).

This patch removes all notes about "setuid support" and for sure
disable hwclock execution for non-root users.

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=786804
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosulogin: don't use strcpy(), enlarge pwd line buffer
Karel Zak [Mon, 25 May 2015 13:24:13 +0000 (15:24 +0200)] 
sulogin: don't use strcpy(), enlarge pwd line buffer

* according to "man getpwnam" 16384 bytes is enough to store one
  passwd entry (let's use 2*BUFSIZE to avoid magic numbers in code)

* don't use strcpy() to set empty password

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: add --without-* for all libs
Karel Zak [Fri, 22 May 2015 10:43:33 +0000 (12:43 +0200)] 
build-sys: add --without-* for all libs

It's necessary for people who want to compile util-linux in very
unusual environment and disable as much as possible dependencies.
For example distro bootstrap.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1223894
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoblkid: another hint to the man page
Karel Zak [Thu, 21 May 2015 11:13:49 +0000 (13:13 +0200)] 
blkid: another hint to the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoblkid: be more precise in the man page
Karel Zak [Thu, 21 May 2015 10:37:18 +0000 (12:37 +0200)] 
blkid: be more precise in the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoblkid: don't ignore info about partitions on non-formated devices
Karel Zak [Thu, 21 May 2015 10:14:32 +0000 (12:14 +0200)] 
blkid: don't ignore info about partitions on non-formated devices

 # blkid -p /dev/sdc1; echo $?
 2

but libblkid provides information about partition, fixed version:

 # blkid -p /dev/sdc1; echo $?
 /dev/sdc1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="4c1e518c-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="1021952" PART_ENTRY_DISK="8:32"
 0

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agodocs: update TODO
Karel Zak [Tue, 19 May 2015 12:40:42 +0000 (14:40 +0200)] 
docs: update TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: support unshare.static
Georg Schiesser [Tue, 5 May 2015 11:19:51 +0000 (13:19 +0200)] 
build-sys: support unshare.static

This patch adds support for building a static version of unshare.
We need to add unshare to the list of possible static programs, and
provide build flags for the compiler and linker, which are equivalent to
the flags of the non-static program, except additional static linking.
See also: commit 2fa60c5 build-sys: support nsenter.static

Signed-off-by: Georg Schiesser <georg.schiesser@opentech.at>
10 years agocal: fix January 1753 week number printout
Sami Kerola [Sun, 17 May 2015 17:27:42 +0000 (18:27 +0100)] 
cal: fix January 1753 week number printout

Earlier output was clearly broken.

$ cal -w 1 1753
      January 1753
   Su Mo Tu We Th Fr Sa
51     1  2  3  4  5  6
52  7  8  9 10 11 12 13
52 14 15 16 17 18 19 20
52 21 22 23 24 25 26 27
52 28 29 30 31

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agozramctl: add MEM-LIMIT, MEM-USED and MIGRATED columns
Karel Zak [Mon, 18 May 2015 09:30:56 +0000 (11:30 +0200)] 
zramctl: add MEM-LIMIT, MEM-USED and MIGRATED columns

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agozramctl: support /sys/block/zram<id>/mm_stat
Karel Zak [Mon, 18 May 2015 09:13:44 +0000 (11:13 +0200)] 
zramctl: support /sys/block/zram<id>/mm_stat

Linux >= 4.1 provides all memory related statistics by one file.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/strv: add new functions (from systemd)
Karel Zak [Fri, 15 May 2015 12:57:04 +0000 (14:57 +0200)] 
lib/strv: add new functions (from systemd)

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: Fix mangled EOF and hang on big endian
Stanislav Brabec [Thu, 14 May 2015 15:55:56 +0000 (17:55 +0200)] 
script: Fix mangled EOF and hang on big endian

On s390 and other big endian machines, doinput() sends NUL instead of
EOF to the tty master. NUL does not even reach the slave, and it is
waiting for more data forever.

If STDIN is not a tty, the bug caused "^@" being into the log, and since
commit 032228c it also causes hang.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
10 years agoMerge branch 'test-fixes' of https://github.com/rudimeier/util-linux
Karel Zak [Wed, 13 May 2015 13:08:04 +0000 (15:08 +0200)] 
Merge branch 'test-fixes' of https://github.com/rudimeier/util-linux

* 'test-fixes' of https://github.com/rudimeier/util-linux:
  tests: fix kill/all_processes
  tests: add $top_builddir to $PATH