Commit Graph

800 Commits

Author SHA1 Message Date
Karel Zak f5ae1d706e mount: write success messages to stdout
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-15 15:53:46 +01:00
Karel Zak be6904b92f mount: support multiple MS_PROPAGATION flags in one mount(8) exec
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-15 14:23:54 +01:00
Ondrej Oprala 701c69617e mount: add support for x-mount.mkdir[=<mode>] option
If the target directory (mountpoint) does not exist then mount(8) will create
it before mount.<type> is executed or mount(2) syscall is called.

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-09 18:52:32 +01:00
Karel Zak f3242e065a mount: document x-* options
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-09 15:41:46 +01:00
Richard Tollerton 1707b9b104 mount: Fix -t in listing mode when run as non-root
Presently, libmount-mount completely prohibits the use of -t by non-root
users.  This breaks using -t in listing mode as a user, which represents
a regression against mount-deprecated, macosx and presumably *BSD.

This commit fixes the issue by deferring the mnt_context_is_restricted
check for -t until we know we're not in listing mode.

Signed-off-by: Rich Tollerton <rich.tollerton@ni.com>
2013-01-09 14:47:25 +01:00
Dave Reisner 886330478b mount: document options for debugfs
Since 3.4, debugfs allows uid, gid, and mode options.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2013-01-09 14:42:01 +01:00
Sami Kerola e0b0676988 losetup: fix declarations [smatch scan]
sys-utils/losetup.c:309:2: error: 'for' loop initial declarations are only allowed in C99 mode
sys-utils/losetup.c:374:2: error: 'for' loop initial declarations are only allowed in C99 mode

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-09 13:37:23 +01:00
Sami Kerola d96b743f3f swapon: default to --show if nothing is requested
Proposed-by: Karel Zak <kzak@redhat.com>
References: http://www.spinics.net/lists/util-linux-ng/msg07301.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-09 13:37:21 +01:00
Sami Kerola fce1a34807 ipcs: fix spacing in summary output
Change 56692a6 introduced spacing error to --summary printing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-09 13:37:03 +01:00
Mike Frysinger 295dd90226 flock: improve usage strings
The current examples miss the best usage of all: specifying the command
and its arguments directly on the command line.  Add that to both the
program usage and the man page.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-09 13:36:58 +01:00
Karel Zak cd04b26bf8 swapon: print warning about insecure owner/permissions
Let's make it more obvious if swap area is accessible for non-root
users. The old version prints the warning only if --verbose is
specified.

Reported-by: mp.lists@free.fr
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 13:15:52 +01:00
Neil Horman 4bbe809939 unshare: support the switching of namespaces
In addition to the unshare syscall, there exists the setns syscall, which
allows processes to migrate to the namepsaces of other processes.  Add this
functionality into the unshare command, as they operate in a fairly simmilar
fashion.

Note: There was discussion of adding a path based namespace argument to unshare
in the origional discussion thread, but I opted to leave that out as it didn't
seem to fit in nicely with the current argument pattern.  I figure we can always
add that in later if we need to

[kzak@redhat.com: - fix optional arguments
                  - do not call unshare if no flag specified
                  - use O_CLOEXEC
                  - codding style cleanup]

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-07 14:56:32 +01:00
Karel Zak 278e7203fa ipcs: fix compiler warnings, use 64bit time
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:52:16 +01:00
Karel Zak 7f89534e6e hwclock: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:51:38 +01:00
Karel Zak 7e88f61717 ipcs: make --human really sexy
Align the "size" columns to the right.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19 15:27:12 +01:00
Sami Kerola 1342ffcbeb tunelp: deprecation: remove command from default build
It is difficult to think think tunelp command being in use a lot.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-19 11:38:48 +01:00
Sami Kerola 19b7b517b9 ipcs: add --bytes size output option
This makes the command being a little closer standard compliant.  See
IEEE Std 1003.1 referral link below for more information.

References: http://pubs.opengroup.org/onlinepubs/009696799/utilities/ipcs.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-19 11:05:00 +01:00
Sami Kerola 56692a6701 ipcs: add --human readable size conversion option
Introduces new function ipc_print_size() which will call
size_to_human_string(), and handles the occasional '([k]bytes)' printing
if default size format is requested.

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-19 11:04:53 +01:00
Sami Kerola 7e3c5f1cc1 ipcs: assist debugging
One will be able to see enum symbols when debugging, which is not the
case when values are specified as define list.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-19 11:04:50 +01:00
Sami Kerola a68ca3a1d2 docs: swapon.8 option name fix
The commit 7ae8b469ad added option --bytes,
not the initial proposal which was changed after maillist discussion.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-19 11:04:47 +01:00
Karel Zak 880f09c828 swapon: fix memmory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 12:40:48 +01:00
Karel Zak a0e35e3044 swapon: don't care about xasprintf() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 12:18:20 +01:00
Karel Zak 76a9fcc913 prlimit: don't care about xasprintf() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 12:16:16 +01:00
Karel Zak 9d8537ff21 lscpu: don't care about xasprintf() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 12:13:38 +01:00
Karel Zak cc8cc8f32c umount: sanitize paths from non-root users
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-26 16:25:46 +01:00
Karel Zak 5ebbc3865d mount: sanitize paths from non-root users
$ mount /root/.ssh/../../dev/sda2
 mount: only root can mount UUID=17bc65ec-4125-4e7c-8a7d-e2795064c736 on /boot

this is too promiscuous. It seems better to ignore on command line
specified paths which are not resolve-able for non-root users.

Fixed version:

  $ mount /root/.ssh/../../dev/sda2
  mount: /root/.ssh/../../dev/sda2: Permission denied

  $ mount /dev/sda2
  mount: only root can mount UUID=17bc65ec-4125-4e7c-8a7d-e2795064c736 on /boot

Note that this bug has no relation to mount(2) permissions evaluation
in suid mode. The way how non-root user specifies paths on command
line is completely irrelevant for comparison with fstab entries.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-26 16:24:54 +01:00
Karel Zak 6c32b388b5 lscpu: remove unnecessary variable
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 15:01:27 +01:00
Sami Kerola 3cd8773318 ipcs: remove print_perms()
The function is no longer in use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-23 14:58:22 +01:00
Sami Kerola 2bd2f79dde ipcs: make individual message queue id printing to use /proc
[kzak@redhat.com: - fix msgctl() call,
		  move q_qbytes to ipc_msg_get_info]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:22 +01:00
Sami Kerola 35118dfc31 ipcs: clean up do_msg(), and add ipc_msg_get_info()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-23 14:58:22 +01:00
Sami Kerola b5504a3d4b ipcs: make individual semaphore id printing to use /proc
And reindent the print_shm() function.

[kzak@redhat.com: move semctl(GET*...) calls to ipcutils.c]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:22 +01:00
Sami Kerola 1e2418a234 ipcs: clean up do_sem(), and add ipc_sem_get_info()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-23 14:58:22 +01:00
Sami Kerola 3ec6f77833 ipcs: make individual shared memory id printing to use /proc
And reindent the print_shm() function.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Karel Zak 7d94d1cebc ipcs: fix ipc_shm_get_info(), use calloc
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Karel Zak 61e14b4a61 ipcs: clean up do_shm()
- don't expect maxid as argument in ipc_shm_get_info()
 - if there is @id argument then use it everywhere in ipc_shm_get_info()
 - don't call shmctl() if not necessary in do_shm()

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Sami Kerola 058e81540f ipcs: read shared memory values from /proc
[kzak@redhat.com: - move to ipcutils.{c,h},
                  - fix datatypes to be arch independent]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Sami Kerola e5995acda2 ipcs: determine ipc limits from /proc
Some of the limit values are not dynamic.  Like in kernel these values
are #defined.

[kzak@redhat.com: - use better names for functions,
                  - add ipcutils.{c,h}
                  - read also shmmax from /proc]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Karel Zak ca01695b77 lib/path: rename functions to be more explicit
... and to have names compatible with lib/sysfs.c

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Dave Reisner 7b4a2697b1 umount: (recursive) add a cache to the table
Without this table libmount will not resolve paths, meaning that
umounting by relative path will fail.

[kzak@redhat.com: - use mnt_context_get_cache() to make it sensitive
                    to --no-canonicalize cmdline option]

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-16 10:41:36 +01:00
Karel Zak ae978c4d6c umount: (recursive) don't call umount(2) for already unmounted targets
In the umount --recursive we follow entries from mountinfo, but the
entries maybe already obsolete. Especially if the hierarchy of the
mountpoints contains shared subtrees and umount(2) for one entry may
generate umount for some other entry too.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-15 16:44:07 +01:00
Karel Zak a8cc72dea0 umount: clean --recursive
- mark some options combinations mutually exclusive
 - reset libmount context before next umount (this is important!)

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-15 11:55:48 +01:00
Karel Zak 06069d5f63 umount: allways return MOUNT_EX_*
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-13 16:50:02 +01:00
Dave Reisner 13ee1c9116 umount: add -R, --recursive option
This allows unmounting of an entire tree of filesystems, which might be
of particular interest for a shutdown initramfs.

[kzak@redhat.com: - always return MOUNT_EX_* codes
                  - cosmetic changes on coding style]

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-13 16:46:07 +01:00
Karel Zak d4bfa64d44 lscpu: make read_topology() more robust to avoid SIGFPE
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-13 10:36:25 +01:00
Toshi Kani a5cfffff28 lscpu: Fix issue found on CPU hot-remove
read_basicinfo() relies on sysfs cpu directories
"/sys/devices/system/cpu/cpu%d" with assumption that cpu
logical number %d is always sequentially assigned for all
CPUs. However, this assumption is not correct with CPU
hot-remove operation since it removes a target sysfs cpu
directory after it is ejected. As a result, lscpu may not
recognize all CPUs.

The issue can be easily reproduced on KVM or VirtualBox,
which supports CPU eject operation, as follows.

1) The system has 4 CPUs
  $ lscpu -a -e
  CPU NODE SOCKET CORE L1d:L1i:L2 ONLINE
  0   0    0      0    0:0:0      yes
  1   0    1      1    1:1:1      yes
  2   0    2      2    2:2:2      yes
  3   0    3      3    3:3:3      yes

2) Eject cpu2
  # echo 1 > /sys/bus/acpi/devices/LNXCPU:02/eject

3) lscpu no longer recognizes cpu3 after cpu2 is ejected
  $ lscpu -a -e
  CPU NODE SOCKET CORE L1d:L1i:L2 ONLINE
  0   0    0      0    0:0:0      yes
  1   0    1      1    1:1:1      yes

The following changes are made to address this issue.
 - Use maxcpus to allocate and parse bitmaps.
 - Set desc->ncpu from cpu/present, which includes both on-line
   and off-line CPUs.
 - Add is_cpu_present() to check if a CPU is present. Ejected
   CPUs are not present.

[kzak@redhat.com: - read also /sys/devices/system/cpu/possible mask to
                    determine maximal number of CPUs,
                  - err() if possible mask is not found in /sys]

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 14:47:13 +01:00
Karel Zak 65178cb3f2 losetup: allow to use -O without --list
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 14:36:29 +01:00
Karel Zak 4ad996d7f9 losetup: rename SIZE->SIZELIMIT
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 13:24:45 +01:00
Karel Zak ead259e325 docs: mark old losetup output format as DEPRECATED
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 13:23:19 +01:00
Ondrej Oprala 896352d390 losetup: add --list and --output option
The --list --all is the default output:

  # losetup
  NAME       SIZE OFFSET AUTOCLEAR RO BACK-FILE
  /dev/loop0    0      0         0  0 /home/fs-images/swap.img
  /dev/loop1    0    100         0  0 /home/fs-images/disk.img

[kzak@redhat.com: - default to --all if no device specified,
                  - cleanup column names (add BACK- prefix)
                  - add MAJ:MIN to of the loopdev device]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 13:08:00 +01:00
Karel Zak 59414c6b4a mount: supports paths canonicalization for alternative fstabs
# mount --fstab /path/my.fstab

has to support standard operations with paths.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-24 23:59:04 +02:00