Commit Graph

1305 Commits

Author SHA1 Message Date
Karel Zak 929c257548 ipcs: fix shmctl() usage
The function shmctl() has to be called with 'struct shmid_ds', and if
you need 'struct shminfo' then the right way is to cast:

bad way:
  struct shm_info info;

  shmctl(0, SHM_INFO, &info);

right way:
  struct shmid_ds buf;
  struct shm_info *info;

  shmctl(0, SHM_INFO, &buf);
  info = (struct shm_info *) &buf);

The patch also fixes bug in ipc_shm_get_limits() where is missing
lim->shmmax in code based on shmctl().

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-19 13:42:41 +01:00
Sami Kerola 3ce29d6d46 ipcs: fix two data type errors [AddressSanitizer]
==3218==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffa577e2b0 at pc 0x4501f9 bp 0x7fffa577e130 sp 0x7fffa577e108
WRITE of size 112 at 0x7fffa577e2b0 thread T0
    #0 0x4501f8 in shmctl /home/users/aadgrand/LLVM/releases/ubuntu/final/llvm.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:2502
    #1 0x48bd13 in ipc_shm_get_info /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcutils.c:157
    #2 0x488884 in do_shm /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcs.c:279
    #3 0x4844a8 in main /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcs.c:175
    #4 0x2afb3f8c176c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c)
    #5 0x48408c in _start (/home/travis/build/kerolasa/lelux-utiliteetit/ipcs+0x48408c)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 11:32:38 +01:00
Sami Kerola 772420322d lscpu: blacklist vmware_bdoor() AddressSanitizer check
AddressSanitizer is identifying the __asm__ segment as suspicious.

==1215==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000
(pc 0x0000004ccffd bp 0x7fff9b7184f0 sp 0x7fff9b7184e0 T0)
    #0 0x4ccffc in vmware_bdoor /home/src/util-linux/sys-utils/lscpu.c:660

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 11:32:38 +01:00
Benno Schulenberg f49ccec212 docs: don't use bold or italics for "[option]" in synopsis of man pages
As per the convention shown in Documentation/howto-man-page.txt.
Also make a few other tiny adjustments along the way.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-12-19 09:57:23 +01:00
Karel Zak 01966ce852 libmount: allow unspecified source on remount
kernel does not require mount source (e.g. device name) on remount, it
means that fstab/mtab/mountinfo should be optional in this case.
For example:

 mount -o rw,remount /

has to work on system without mounted /proc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-18 10:47:39 +01:00
Cristian Rodríguez fad25f02a3 build-sys: hwclock requires -lm
hwclock uses fabs and therefore needs libm, otherwise a linking
error ocurrs when building with -fno-builtin.
2014-12-09 09:19:36 +01:00
Karel Zak bc265f7cfa eject: use sysfs API to detect hotplug
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-02 11:00:19 +01:00
Karel Zak 784467ad2d blkdiscard: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-26 12:38:53 +01:00
Karel Zak 41525ce062 ldattach: add fallback for N_GSM0710
Addresses: https://github.com/karelzak/util-linux/issues/133
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-21 13:57:14 +01:00
Karel Zak cd2876d252 build-sys: move all around clock_gettime() to monotonic.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-19 11:54:47 +01:00
Karel Zak a4830f617e build-sys: use CLOCKGETTIME_LIBS
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-19 11:23:05 +01:00
Karel Zak 700031ade7 misc: use monotonic time rater than gettimeofday
Based on patch Alexander Samilovskih <alexsamilovskih@gmail.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-18 14:35:21 +01:00
Ville Skyttä 9779f59831 docs: Spelling fixes
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-18 13:59:19 +01:00
Karel Zak 8596f63914 ldattach: GSM0710 support, add intro modem command
Patch add:
 --intro-command string  : send command to modem
 --pause value           : define delay between intro command and ldattach

Based on patch from Martin Schmid <scm@aps-systems.ch>

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-18 13:49:42 +01:00
Tobias Stoeckmann 6cbf75e56e lscpu: theoretical buffer overflow
there is a theoretical buffer overflow possible in the hypervisor
parsing code of lscpu.  It would require a proc entry to return way more
than expected so it's no high priority.  But better be safe than sorry.

At first I thought about switching to fgets but there is another
code file that adds a format specifier.  The diff is less intrusive
that way, too.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-18 11:38:21 +01:00
Benno Schulenberg df48a72161 hwclock: improve wording and formatting of man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-11-13 15:09:16 +01:00
Karel Zak 64d0cee6c0 include/statfs_magic: use macro rather than type for f_type
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-10 11:29:42 +01:00
Benno Schulenberg f4cae17663 swapon: reword some usage strings
Also remove some inconsistent periods and properly punctuate
the closing sentence.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-11-07 13:21:06 +01:00
Benno Schulenberg 24930e7088 docs: fix some wording, grammar and formatting in man page of swapon
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-11-07 13:21:06 +01:00
Karel Zak 52f2fd9bcc swapoff: swapoff swap files by LABEL and UUID
# swapon --show=NAME,UUID
 NAME                   UUID
 /dev/sda3              8d52fca3-bf48-41d6-b826-2315e518a305
 /home/fs-images/2g.img 6fa72b96-b802-441f-a31c-091d65c0212c

 # swapoff UUID=6fa72b96-b802-441f-a31c-091d65c0212c
 swapoff: cannot find the device for UUID=6fa72b96-b802-441f-a31c-091d65c0212c

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-07 12:08:11 +01:00
Karel Zak 8f806bb1ea switch_root: improve statfs->f_type portability
__SWORD_TYPE is not available everywhere, for example it's not defined
by musl libc. It also seems that __SWORD_TYPE is not used for f_type
on some architectures (s390x).

Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-06 12:50:27 +01:00
Karel Zak 0bf037402a lib/loopdev: replace custom DBG() with include/debug.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-04 14:08:45 +01:00
Karel Zak 68e422ecae docs: update info about env debug variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-03 13:13:54 +01:00
Karel Zak 03b5e5975a swapon: improve man page notes about holes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-03 10:11:58 +01:00
Karel Zak 54f2e4563d swapon: remove extra word from usage
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-31 10:58:27 +01:00
Benno Schulenberg 6ee8e19489 textual: slice up the usage text of swapon for ease of translation
A new option was added recently; seize this opportunity to cut the
usage text into small and easily managed chunks.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-10-31 10:39:11 +01:00
Benno Schulenberg b1301d7865 docs: fix some wording and formatting in man page of swapon
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-10-31 10:39:08 +01:00
Sami Kerola b35c37274c fstrim: initialize path variable
Reading the code this initialization is not necessary, so the change is
mostly about silencing a compiler warning and ensuring the program keeps
on working if there is a future bug that could make uninitialized 'path'
reachable to use.

sys-utils/fstrim.c:247: warning: 'path' may be used uninitialized in this
function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-31 10:38:58 +01:00
Karel Zak 8fc4a88630 build-sys: properly check for -lrt
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-27 11:05:14 +01:00
Karel Zak c0dedab013 build-sys: old glibc requires -lrt clock_gettime()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-27 10:47:32 +01:00
Karel Zak 4f55368cc5 blkdiscard: fix includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-27 10:00:19 +01:00
Karel Zak 8f59654a40 blkdiscard: update man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-27 09:42:51 +01:00
Federico Simoncelli c472a7e35a blkdiscard: add support for steps and progress
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
2014-10-27 09:16:49 +01:00
Federico Simoncelli d7ce9acb33 blkdiscard: fail on sector misalignment 2014-10-27 09:16:47 +01:00
J William Piggott bbb4c273e9 hwclock: Reduce drift factor update period
To facilitate the calculation of 'cold' vs 'warm' Hardware Clock drift
factor the limit on the update period needs to be less than 8 hours.

4 hours should be enough drift to allow calculations that are not
grossly out of range.

For example, with a workstation that is shutdown every night the cold
drift factor can be significantly different than a drift factor based on
a 24 hour period.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-20 15:22:24 -04:00
J William Piggott 66af1c0f44 hwclock: fix superfluous 'if' statement and typo
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-20 14:48:07 -04:00
J William Piggott 5cb71d2bca hwclock: adjust wording of v2.26 notes
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-20 14:07:27 -04:00
Sami Kerola 6f7f155c0c eject: move unreachable code to preprocessor #else block [smatch scan]
eject.c:466 toggle_tray() info: ignoring unreachable code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-20 14:07:18 +02:00
Karel Zak 732ac3a52a hwclock: add notes about default behavior changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-20 14:01:25 +02:00
Karel Zak fc56c36368 hwclock: cleanup man and usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-20 13:31:36 +02:00
Karel Zak e2c1eb9913 Merge branch 'master' of https://github.com/jwpi/util-linux into hwclock 2014-10-20 11:41:38 +02:00
Karel Zak e07fdac476 swapon: add -o <list> for compatibility with mount
The new option allows to specify swap options by fstab compatible
string. The concept is the same as for mount(8).

   swapon -o pri=1,discard=pages,nofail /dev/sda2

The advantage is that tools (like systmed) that parses fstab can call
swapon without translation from fstab options to swapon(8) command
line options.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-20 10:59:08 +02:00
Karel Zak ba986e815c mount: don't ignore mtab for --bind -o remount
Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-17 08:53:54 +02:00
J William Piggott cd950279f1 hwclock: Add --update-drift option MAN
Update hwclock man page for the
hwclock: Add --update-drift option patch.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-15 16:15:06 -04:00
J William Piggott f276d71a3e hwclock: Add --update-drift option
There are cases where we need to refresh the
timestamps in the adjtime file without updating the
drift factor.

For example, with ntpd and an Eleven Minute Mode
kernel, we need to call systohc at shutdown to
facilitate drift correction.  With the current
behavior hwclock will clobber the drift factor to
near zero, because the Hardware Clock and System
Clock are synced by Eleven Minute Mode.  What
actually needs to be done is refresh the adjtime
file timestamps and not calculate a new drift
factor.

Because it is a manual process to craft a good
Hardware Clock drift factor, that is, there is no
automated method that will produce a good drift
factor, this patch changes the default drift
calculation behavior to off, and it is turned on
by using the --update-drift option. Once we have a good
drift factor for a given machine we do not want
anything clobbering it, including an administrator
forgetting to turn off recalculation. A system
administrator should make a concious effort in
telling hwclock with the --update-drift option that
(s)he wants to recalculate the drift factor.

Without using the --update-drift option with calibrate
operations only the timestamps are refreshed in
the adjtime file. With the --update-drift option the old
default behavior of refreshing the timestamps and
updating the drift factor is performed.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-15 15:48:17 -04:00
J William Piggott 8db424dcbc hwclock: persistent_clock_is_local MAN
Update hwclock man page for the
hwclock: persistent_clock_is_local patch.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-15 14:48:07 -04:00
J William Piggott d17a12a368 hwclock: persistent_clock_is_local
When hctosys is used at boot time, making it the
first caller of settimeofday, the responsibility
of setting persistent_clock_is_local is thrust
upon it.  Currently hctosys always leaves this
variable uninitialized.  This causes a Hardware
Clock configured to use the local timescale to be
clobbered with the UTC timescale by the kernel's
NTP eleven minute mode.

This patch fixes this hctosys bug, by having it
properly set persistent_clock_is_local according
to the time scale configured for the Hardware
Clock.

It does this via the kernel warp_clock function
but this in inconsequential, because we set the
system time immediately afterward.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-15 14:45:29 -04:00
J William Piggott cb7efbc12d hwclock: hctosys drift compensation II MAN
Update hwclock man page for the
hwclock: hctosys drift compensation II patch.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-15 14:37:08 -04:00
J William Piggott ede32597f5 hwclock: hctosys drift compensation II COMMENTS
Update source comments and --help output for the
hwclock: hctosys drift compensation II patch.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-15 14:32:31 -04:00
J William Piggott 2794995ad9 hwclock: hctosys drift compensation II
Allowing hctosys to drift compensate facilitates:

More precise setting of the System Clock early in
the boot process when --adjust cannot be used
because the file system is not writeable.

Applies sub second drift corrections immediately,
where as --adjust cannot.

Reduces boot time by not calling hwclock multiple
times, e.g., --hctosys early before fsck when the
file system is read-only, then --adjust later when
the file system is read-write and --hctosys again
for drift correction.

Use of --adjust elsewhere may no longer be
necessary.

Part II

After the original submission of this patch I
realized that now all operations except --systz
require drift corrected Hardware Clock time.
Therefore, it should be done only once early in
the process. Upon implementation of that premise
many improvements were facilitated:

* Adds drift correction to --hctosys.
* Adds setting system time with sub-second precision.
* Adds --get, a drift corrected 'show' operation.
* Improves drift factor calculation precision while
   greatly simplifying its algorithm.
* Fixes --show bug, printing integer sub-seconds, and
   now uses a more intuitive positive value.
* Fixes --predict bug, drift correction must be
   negated to predict future RTC time.
* Reduces the number of function arguments and
   lines of code.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2014-10-15 14:21:13 -04:00