]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
10 years agolibfdisk: fix fdisk_label_parse_parttype() for unknown types
Karel Zak [Wed, 15 Jul 2015 13:42:22 +0000 (15:42 +0200)] 
libfdisk: fix fdisk_label_parse_parttype() for unknown types

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) add missing GUIDs
Karel Zak [Wed, 15 Jul 2015 13:02:13 +0000 (15:02 +0200)] 
libfdisk: (gpt) add missing GUIDs

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add GPT GUIDs for PReP
Scott Moser [Tue, 14 Jul 2015 20:10:17 +0000 (16:10 -0400)] 
libfdisk: add GPT GUIDs for PReP

Power Firmware (OFW) scans chosen devices for PReP partition IDs.

Signed-off-by: Scott Moser <smoser@ubuntu.com>
10 years agolibfdisk: (gpt) fix "MidnightBSD UFS" UUID
Karel Zak [Wed, 15 Jul 2015 12:29:53 +0000 (14:29 +0200)] 
libfdisk: (gpt) fix "MidnightBSD UFS" UUID

Reported-by: Андрей Гаврилин <gaal.dev@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: evaluate errno only if read() sets it
Ruediger Meier [Thu, 2 Jul 2015 10:10:17 +0000 (12:10 +0200)] 
script: evaluate errno only if read() sets it

[kzak@redhat.com: - be careful with errno and DBG
                  - add EINTR check
                  (both suggested by Rudi]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoscript: make sure errno is zero
Karel Zak [Thu, 2 Jul 2015 08:30:10 +0000 (10:30 +0200)] 
script: make sure errno is zero

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoswapon: fix restart waitpid with errno == EINTR
Karel Zak [Wed, 1 Jul 2015 13:35:17 +0000 (15:35 +0200)] 
swapon: fix restart waitpid with errno == EINTR

Reported-by: Maks Naumov (https://github.com/karelzak/util-linux/pull/205)
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/strutils: make strmode() more generic
Karel Zak [Tue, 30 Jun 2015 10:41:13 +0000 (12:41 +0200)] 
lib/strutils: make strmode() more generic

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoMerge branch 'sulogin'
Karel Zak [Tue, 30 Jun 2015 09:21:12 +0000 (11:21 +0200)] 
Merge branch 'sulogin'

10 years agofstrim: close dir before exit [coverity scan]
Karel Zak [Mon, 29 Jun 2015 14:14:35 +0000 (16:14 +0200)] 
fstrim: close dir before exit [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agortcwake: cosmetic changes
Karel Zak [Mon, 29 Jun 2015 13:19:47 +0000 (15:19 +0200)] 
rtcwake: cosmetic changes

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agortcwake: fix ARRAY_SIZE() usage
Karel Zak [Mon, 29 Jun 2015 11:46:05 +0000 (13:46 +0200)] 
rtcwake: fix ARRAY_SIZE() usage

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agortcwake: don't use usage() on error
Karel Zak [Mon, 29 Jun 2015 11:43:41 +0000 (13:43 +0200)] 
rtcwake: don't use usage() on error

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agortcwake: fix valgrind warning
Sami Kerola [Sat, 6 Jun 2015 21:41:51 +0000 (22:41 +0100)] 
rtcwake: fix valgrind warning

==3445== Syscall param ioctl(generic) points to uninitialised byte(s)
==3445==    at 0x4F16477: ioctl (in /usr/lib/libc-2.21.so)
==3445==    by 0x402785: setup_alarm (rtcwake.c:231)
==3445==    by 0x403302: main (rtcwake.c:520)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: read accepted mode strings from /sys/power/state
Sami Kerola [Sun, 11 Jan 2015 09:37:59 +0000 (09:37 +0000)] 
rtcwake: read accepted mode strings from /sys/power/state

The rtcwake has various mode names that are internal to the command,
listed in rtcwake_mode_string array, while some modes are dynamicaly
listed in /sys/power/state.  Together these form the allowed modes.

[kzak@redhat.com: - cleanup strv usage]

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agortcwake: make some command line options mutually exclusive
Sami Kerola [Sun, 11 Jan 2015 01:03:37 +0000 (01:03 +0000)] 
rtcwake: make some command line options mutually exclusive

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: improve coding style
Sami Kerola [Sun, 11 Jan 2015 00:55:23 +0000 (00:55 +0000)] 
rtcwake: improve coding style

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: add --list-modes
Sami Kerola [Sat, 10 Jan 2015 20:07:08 +0000 (20:07 +0000)] 
rtcwake: add --list-modes

Commit ece44f19f423408f576f348fed2845c876d72c6e missed freeze mode, which
to a simple patch adding the missing argument but Karel pointed out it
would be better to make the rtcwake to tell what arguments are supported
so that possible changes end up to be automatically correct in bash
completion.

Proposed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: do not overwrite device name
Sami Kerola [Sat, 10 Jan 2015 19:46:02 +0000 (19:46 +0000)] 
rtcwake: do not overwrite device name

This improves error messaging, and removes a memory leak.

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: clean up struct tm initializations
Sami Kerola [Sat, 10 Jan 2015 19:13:11 +0000 (19:13 +0000)] 
rtcwake: clean up struct tm initializations

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: fix preprocessor redefinition
Sami Kerola [Sat, 10 Jan 2015 18:45:22 +0000 (18:45 +0000)] 
rtcwake: fix preprocessor redefinition

The RTC_AF is expected to be part of linux/rtc.h file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: add human readable --date timestamp format
Sami Kerola [Sat, 10 Jan 2015 18:31:29 +0000 (18:31 +0000)] 
rtcwake: add human readable --date timestamp format

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: improve read_clock_mode()
Sami Kerola [Sat, 10 Jan 2015 18:03:25 +0000 (18:03 +0000)] 
rtcwake: improve read_clock_mode()

Make skipping two lines more robust, and add message about unexpected
adjfile contents when running with --verbose.

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: remove RTC_ALM_READ and RTC_ALM_SET compatibility
Sami Kerola [Sat, 10 Jan 2015 17:07:09 +0000 (17:07 +0000)] 
rtcwake: remove RTC_ALM_READ and RTC_ALM_SET compatibility

The RTC_WKALM_RD and RTC_WKALM_SET have been available since 2.6.17, and
preferred way since 2007.  Keeping the fallbacks to the old interface is
no longer needed.

Reference: https://github.com/torvalds/linux/commit/e824290e5dcfaf2120da587b16d10dfdff8d5d3e
Reference: https://github.com/torvalds/linux/commit/f8245c26886c912627ebc49f714e4491261224c4
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: replace long if else statement with switch case
Sami Kerola [Sat, 10 Jan 2015 16:34:25 +0000 (16:34 +0000)] 
rtcwake: replace long if else statement with switch case

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: enumerate constant mode strings
Sami Kerola [Sat, 10 Jan 2015 16:14:35 +0000 (16:14 +0000)] 
rtcwake: enumerate constant mode strings

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agortcwake: add rtcwake_control and remove global variables
Sami Kerola [Sat, 10 Jan 2015 15:39:00 +0000 (15:39 +0000)] 
rtcwake: add rtcwake_control and remove global variables

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoreset: deprecate the script, and remove reset.033c
Sami Kerola [Fri, 12 Jun 2015 20:25:08 +0000 (21:25 +0100)] 
reset: deprecate the script, and remove reset.033c

Most distributions probably ship reset from ncurses, which means
util-linux reset(1) is unlikely to be in use anywhere.  Assuming the
previous being true it is almost unimaginable anyone one would be using
the alternative script, so remove it and mark the script deprecated.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agogetopt: use $(...) command substitution in example script [shellcheck]
Sami Kerola [Fri, 12 Jun 2015 19:57:31 +0000 (20:57 +0100)] 
getopt: use $(...) command substitution in example script [shellcheck]

Reference: https://github.com/koalaman/shellcheck/wiki/SC2006
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodocs: unify mkswap(8) with swapon(8) about holes warning
Sami Kerola [Sun, 7 Jun 2015 20:51:51 +0000 (21:51 +0100)] 
docs: unify mkswap(8) with swapon(8) about holes warning

Reviewed-by: Dave Rutherford <dave@evilpettingzoo.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agozramctl: add link to kernel documentation
Sami Kerola [Sat, 6 Jun 2015 20:21:41 +0000 (21:21 +0100)] 
zramctl: add link to kernel documentation

The manual page does lacks explanation how to create zram with modprobe.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolast-deprecated: remove from source tree
Sami Kerola [Tue, 2 Jun 2015 09:18:25 +0000 (10:18 +0100)] 
last-deprecated: remove from source tree

The last/lastb(1) from sysvinit has been around for about two years,
and the better implementation is already part of releases 2.24 to 2.26.
It should be safe to remove the unused last code from the source tree.

Reference: ce60272039ea11952b15fefb653892dd0da02217
Signed-off-by: Sami Kerola <sami.kerola@lastminute.com>
10 years agoscript: fix variable initialization warning
Sami Kerola [Thu, 25 Jun 2015 15:28:19 +0000 (16:28 +0100)] 
script: fix variable initialization warning

term-utils/script.c:402:19: warning: obsolete use of designated
initializer without '=' [-Wpedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agobuild-sys: make autogen.sh more robust
Karel Zak [Mon, 29 Jun 2015 09:41:22 +0000 (11:41 +0200)] 
build-sys: make autogen.sh more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: use REALTIME_LIBS for script
Karel Zak [Mon, 29 Jun 2015 08:55:37 +0000 (10:55 +0200)] 
build-sys: use REALTIME_LIBS for script

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosulogin: improve support for locked root account
Karel Zak [Mon, 25 May 2015 13:30:52 +0000 (15:30 +0200)] 
sulogin: improve support for locked root account

Some installations and distributions don't use a root account password
for security reasons and use sudo instead. In that case, asking for the
password makes no sense, and it is not even considered as valid as it's just
"*" or "!".

In these cases --force is required to just start a root shell and no
ask for password.

I don't think it's a good idea to automatically start root shell when
locked account is detected. It's possible that the machine is on
public place and for example Ubuntu uses root account disabled by
default (and also Fedora when installed by yum/dnf without anaconda).

The --force option forces admins to think about it...

The distro maintainers can also use --force in their initscripts or
systemd emergency.service if they believe that promiscuous setting is
the right thing for the distro.

Addresses: https://bugs.debian.org/326678
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agocfdisk: fix condition logic [cppcheck]
Boris Egorov [Fri, 19 Jun 2015 19:41:01 +0000 (01:41 +0600)] 
cfdisk: fix condition logic [cppcheck]

[disk-utils/cfdisk.c:1181] -> [disk-utils/cfdisk.c:1181]: (warning)
Possible null pointer dereference: data - otherwise it is redundant to
check it against null.

Signed-off-by: Boris Egorov <egorov@linux.com>
10 years agolibblkid/whereis: simplify some conditions [cppcheck]
Boris Egorov [Fri, 19 Jun 2015 19:41:00 +0000 (01:41 +0600)] 
libblkid/whereis: simplify some conditions [cppcheck]

[misc-utils/whereis.c:466]: (style) Redundant condition: uflag.
'A && (!A || B)' is equivalent to 'A || B'
[libblkid/src/tag.c:373]: (style) Redundant condition: dev.
'A && (!A || B)' is equivalent to 'A || B'

Signed-off-by: Boris Egorov <egorov@linux.com>
10 years agosys-utils/disk-utils/lib: fix printf format types [cppcheck]
Boris Egorov [Fri, 19 Jun 2015 19:40:59 +0000 (01:40 +0600)] 
sys-utils/disk-utils/lib: fix printf format types [cppcheck]

Fix 'invalidPrintfArgType' cppcheck warnings

Signed-off-by: Boris Egorov <egorov@linux.com>
10 years agorename: allow full-path renames
Andreas Henriksson [Mon, 22 Jun 2015 17:26:22 +0000 (19:26 +0200)] 
rename: allow full-path renames

The command "touch b0;rename.ul -v ./b0 ./b1 ./b0" used to work
before "allow renaming in subdirectories" change.
(regression in commit bd9ced628bb86)

Addresses: https://bugs.debian.org/789240
Reported-by: gregrwm <bug-grub@whitleymott.net>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
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>