Commit Graph

12712 Commits

Author SHA1 Message Date
Vaclav Dolezal d45e8ef999 mount: document --namespace in man/help
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 16:13:36 +02:00
Vaclav Dolezal cddd2eaa27 libmount: switch namespace when appropriate
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 16:12:55 +02:00
Vaclav Dolezal 65ca7b5a9b libmount: support for namespaces for helpers
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 16:08:44 +02:00
Karel Zak de7ccabdfd libmount: make errno usable after mnt_context_set_target_ns()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 16:06:17 +02:00
Vaclav Dolezal c3dc9a8bad umount: add support for namespaces
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 16:01:49 +02:00
Vaclav Dolezal 21edc0f71a mount: add support for namespaces
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 15:56:41 +02:00
Vaclav Dolezal 8342e5840d libmount: added error MNT_ERR_NAMESPACE
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 15:51:17 +02:00
Vaclav Dolezal 5cbf01b75d libmount: note namespaces in mnt_reset_context() docs
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 15:50:29 +02:00
Vaclav Dolezal 4917d842ea libmount: add support for switching namespaces
[kzak@redhat.com: - cosmetic changes, add some comments]

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 15:49:48 +02:00
Karel Zak 921f63433e wipefs: postpone BLKRRPART until all is done
It's possible we erase from the whole device before we erase from the
partition on the same disk:

 # wipefs -a /dev/sdc /dev/sdc1

the current code calls re-read PT ioctl immediately after erase (so,
before sdc1 is processed). The result is that sdc1 node is no more
accessible:

  # wipefs -a /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc: calling ioctl to re-read partition table: Success
  wipefs: error: /dev/sdc1: probing initialization failed: No such file or directory

It seems the most simple solution is to postpone the re-read ioctl and
do it as the last thing.

  # wipefs -a  /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc1: 2 bytes were erased at offset 0x00000438 (ext4): 53 ef
  /dev/sdc: calling ioctl to re-read partition table: Success

The patch also adds a small delay before the re-read ioctl call. It's
not elegant, but without the usleep(25000) the first attempt returns
EBUSY.

Addresses: https://github.com/karelzak/util-linux/issues/598
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 12:36:32 +02:00
Karel Zak 3b3f43748f zramctl: (man) explain that --find is necessary
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1589148
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 11:14:56 +02:00
Karel Zak ddf287b4ec blkzone: fix whole device detection
Matias Bjørling wrote:
  The current detection code for chunk size assumes that the
  underlying device is a device that uses the minor device id
  as the partition id, and that the whole device has minor id 0.
  This is not true for example null_blk and nvme device drivers.

Let's use sysfs_devno_to_wholedisk() to get whole-disk devno.

Addresses: https://github.com/karelzak/util-linux/pull/646
Reported-by: Matias Bjørling matias.bjorling@wdc.com
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-08 11:42:48 +02:00
Karel Zak c3f5a0f1d4 losetup: keep -f and <devname> mutually exclusive
losetup tries to blindly use specified device as well as search for
the first free device, the result is:

 # losetup /dev/loop1 -f /tmp/tfile_loop1
 losetup: /dev/loop1: failed to set up loop device: Invalid argument

fixed version:

 # losetup /dev/loop10 -f img
 losetup: unexpected arguments

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1566432
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-07 12:05:08 +02:00
Karel Zak 2c4d86abda agetty: keep c_iflags unmodified on --autologin
agetty sets c_iflags according to interaction with serial line in
get_logname(). For --autologin it does not read from the line, so we
have no clue how to set the flags.

The current behavior is to zeroize the flags.  Unfortunately, it seems
like bad idea, because the line may be already properly initialized by
kernel (or systemd, etc.).

The new behavior is not touch the flags on --autologin.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1252764
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-06 15:57:24 +02:00
Karel Zak 641af90dce tests: add empty column test
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-04 15:27:54 +02:00
Karel Zak a797704d5d libsmartcols: don't print empty column
The commit 0f9f927b6f forces
libsmartcols to use one byte as a minimal column width. This seems
like a bug if the column is empty and without header.

$ printf '🅰️b\n' | column -t -s ':' -o ':'
 🅰️b

Fixed version:
$ printf '🅰️b\n' | column -t -s ':' -o ':'
🅰️b

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-04 15:20:28 +02:00
Karel Zak 6691d53797 mount: keep MS_MOVE as flag
The previous commit 4ebea84bb1 replaced
all operations by strings, but it does not work for MS_MOVE as this
operation is not supported in fstab by libmount.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-01 14:07:53 +02:00
Karel Zak 8d6de22499 libmount: don't use MS_MGC_VAL magic in mount(2) syscall
Specifying MS_MGC_VAL was required in kernel versions prior to 2.4,
but since Linux 2.4 is no longer required and is ignored if specified

The minimal kernel requirement for util-linux is Linux v2.6.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-01 12:29:14 +02:00
Karel Zak 816773b475 libmount: improve MS_REC usage
libmount allows to split one library (mount(8)) call to multiple mount(2)
syscalls, for example

   --rbind --make-rslave

in this case we have to be careful with MS_REC because the flag is
applied to multiple operations.

 # strace -e mount mount --rbind --make-rslave /mnt/A /mnt/B

Old version:

 mount("/mnt/A", "/mnt/B", 0x13ecac0, MS_MGC_VAL|MS_BIND, NULL) = 0
 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0

Fixed version:

 mount("/mnt/A", "/mnt/B", 0x1f22ac0, MS_MGC_VAL|MS_BIND|MS_REC, NULL) = 0
 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1584443
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-01 12:16:19 +02:00
Karel Zak 4ebea84bb1 mount: use internally string to set move/bind operations
It's better to inform libmount about operations by string than by
flags, because for example "rbind,slave" cannot be specified by
MS_REC|MS_BIND|MS_SLAVE.

https://bugzilla.redhat.com/show_bug.cgi?id=1584443
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-01 12:11:03 +02:00
Karel Zak c0bdff9997 libmount: include sys/mount.h on Linux only
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=891812
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-29 10:06:00 +02:00
Karel Zak 989407d364 po: fix lsblk translation
Reported-by: Rosberg Nascimento Freitas Rodrigues <rosberg.berg@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-29 09:49:59 +02:00
Karel Zak e82b77e969 libmount: accept another flags on MS_REMOUNT|MS_BIND
The current libmount MS_REMOUNT|MS_BIND support is restricted to
MS_RDONLY (read-only bind mount). This is too restrictive as Linux
kernel supports bind-remount for arbitrary VFS flags.

After this update you can use

 # mount /dev/sdc1 /mnt/A
 # mount --bind -onosuid,noexec /mnt/A /mnt/B

 # findmnt /dev/sdc1 -oTARGET,SOURCE,FS-OPTIONS,VFS-OPTIONS
 TARGET SOURCE    FS-OPTIONS                 VFS-OPTIONS
 /mnt/A /dev/sdc1 rw,stripe=512,data=ordered rw,relatime
 /mnt/B /dev/sdc1 rw,stripe=512,data=ordered rw,nosuid,noexec,relatime

The "mount --bind" is composed from two syscalls of course (1st is
bind, 2nd is bind,remount,nosuid,noexec).

Addresses: https://github.com/karelzak/util-linux/issues/637
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-28 16:15:30 +02:00
Sami Kerola 8d69fd437a mountpoint: simplify test condition [cppcheck]
[sys-utils/mountpoint.c:79]: (style) Redundant condition:
ctl->st.st_dev==pst.st_dev. 'A || (!A && B)' is equivalent to 'A || B'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:39:18 +02:00
Sami Kerola 33b2e30284 include/pt-mbr.h: fix integer overflow
gcc -fsanitize=undefined gives following warning.

include/pt-mbr.h:27:51: runtime error: left shift of 248 by 24 places cannot
be represented in type 'int'

It looks like char is converted internally to int before bit-shift, and that
type overflows when char value is greater than 127.  Following code snippet
will show the effect what is stored when undefined behaviour happens.

    #include <stdio.h>
    #include <inttypes.h>
    int main(int argc, unsigned char **argv)
    {
        char p[] = { 170, 170, 170, 170 };
        unsigned int uint = p[3];
        uint64_t res = 0;
        /* overflow */
        res = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
        printf("%" PRIu64 "\n", res);
        /* this is fine */
        res = 0;
        res = p[0] | (p[1] << 8) | (p[2] << 16) | (uint << 24);
        printf("%" PRIu64 "\n", res);
        return 0;
    }

I tested gcc 8.1.0, clang 6.0.0, and tcc 0.9.27 and they all printed the
same values.

    $ ./a.out
    18446744073709551530
    4294967210

Because output is result of undefined behavior what is stored may change in
future, and other compilers / version might do something different.  In the
case of what pt-mbr.h the destination data type size was commonly 32 bits in
size, that truncated excess rubbish from bitshift.  Needless to say that was
not very robust code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:36:38 +02:00
Sami Kerola 1405658822 nls: remove translation strings
While looking earlier commit I noticed everything but formatting was removed
from a message in namei.c file.  That inspired me to look if there are more
strings that does not need translation project attention.  This change
removes at least some of them, if not all.

Reference: e19cc7b65b
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:36:38 +02:00
Sami Kerola faa44b6d9a bash-completion: add swapon specifiers to completion
No space after device name is not entirely right, but that's better than
missing argument completions.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:36:38 +02:00
Sami Kerola 25ed963d02 rev: move a global variable to local scope
Mark also file names read-only.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:36:38 +02:00
Sami Kerola 4520caa11e tests: move stderr redirection out from test expression
Fix shellcheck error.

if ! [ "$paraller_jobs" -ge 0 2>/dev/null ]; then
^-- SC1009: The mentioned parser error was in this if expression.
     ^-- SC1073: Couldn't parse this test expression.
                              ^-- SC1072: Expected test to end here (don't
                                  wrap commands in []/[[]]). Fix any
                                  mentioned problems and try again.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:36:38 +02:00
Karel Zak 64af1a2987 lib/strutils: fix strnlen() fallback
Addresses: https://github.com/karelzak/util-linux/issues/643
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-28 12:30:34 +02:00
Karel Zak 5ac0b26994 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Fix reporting UDF 2.60 revision
2018-05-28 09:58:19 +02:00
Karel Zak 3abbd0814c libblkid: (ntfs) fix cluster size check
Addresses: https://github.com/karelzak/util-linux/issues/641
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-25 21:02:23 +02:00
Pali Rohár 4c837d4ffe libblkid: udf: Fix reporting UDF 2.60 revision
According to the UDF 2.60 specification, the Minimum UDF Read Revision
value shall be at most #0250 for all media with a UDF 2.60 file system.

So in this case use Minimum UDF Write Revision as ID_FS_VERSION to
distinguish between UDF 2.50 and UDF 2.60 discs.

This commit also adds a testing Blu-Ray Recordable image with UDF revision
2.60 created by Nero which really sets Minimum UDF Read Revision to 2.50.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2018-05-25 17:52:31 +02:00
Karel Zak 7816ee22d5 libblkid: (ntfs) enlarge cluster limit to 2MB
Windows 10 Creators edition has extended the ntfs cluster limit to
2MB. As a consequence blkid does not identify recent partitions with
clusters beyond 65K as ntfs ones.

Addresses: https://github.com/karelzak/util-linux/issues/641
Signed-off-by: Karel Zak <kzak@redhat.com>
Co-Author: Jean-Pierre André <jean-pierre.andre@wanadoo.fr>
2018-05-25 13:53:03 +02:00
Ruediger Meier 333423163b cfdisk: fix compiler warnings, follow-up 7085f1e4 (#636)
Seen on OSX 10.13, xcode 9.3.

 disk-utils/cfdisk.c:1860:45: error: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
         DBG(UI, ul_debug("get_size (default=%ju)", *res));
                                             ~~~    ^~~~
                                             %llu
 disk-utils/cfdisk.c:267:60: note: expanded from macro 'DBG'
 #define DBG(m, x)       __UL_DBG(cfdisk, CFDISK_DEBUG_, m, x)
                                                           ^
 ./include/debug.h:67:4: note: expanded from macro '__UL_DBG'
                         x; \
                         ^
 disk-utils/cfdisk.c:1889:25: error: incompatible pointer types passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'uintmax_t *' (aka 'unsigned long *') [-Werror,-Wincompatible-pointer-types]
                         rc = parse_size(buf, &user, &pwr);      /* parse */
                                              ^~~~~
 ./include/strutils.h:15:51: note: passing argument to parameter 'res' here
 extern int parse_size(const char *str, uintmax_t *res, int *power);
                                                   ^
 2 errors generated.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-05-24 16:31:43 +02:00
Karel Zak 7085f1e49b cfdisk: use uint64_t to avoid compiler warnings
Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-24 09:19:28 +02:00
Karel Zak fa7709dbad lslogins: add -o+<COLNAME> support
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-23 16:44:42 +02:00
Karel Zak bb3d3fd905 lslogins: add PWD-METHOD column
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-23 16:32:32 +02:00
Karel Zak 214fbec40a lslogins: fix password verification
Let's follow the standard $id$salt$encrypted password format in
verification code.

The current code is useless and for example PWD-LOCK column is always
FALSE.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1581611
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-23 12:45:23 +02:00
Bjarni Ingi Gislason 3fe5e8ec09 man: Change the only argument to two for the two-fonts macros
Punctuation marks have been left in the only argument of two-fonts
macros, instead of being separated from it to make the second one.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-05-23 10:43:27 +02:00
Bjarni Ingi Gislason 244b7991c3 man: choom.1: Use the correct macro for the font change of one argument
Use the correct macro "I" for one argument, instead of the
two-fonts macro "IR".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-05-23 10:43:27 +02:00
Bjarni Ingi Gislason 0bb7e904d7 man: Use the correct macro for a font change of one argument
Use the correct macro (I, B) for the font change of one argument, not
those that are used for alternating two fonts, like "BR", "IR", "RB",
or "RI".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-05-23 10:43:27 +02:00
Sami Kerola a8f98304e6 more: reorder global declarations
Group include, defines and such together, and move items inbetween functions
on top of the source file so that everything can be seen easily.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-23 10:41:46 +02:00
Sami Kerola f16ca88d9c more: remove function prototypes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-23 10:41:46 +02:00
Karel Zak 03d190ad9e lsns: remove unnecessary include
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-17 12:42:16 +02:00
Ruediger Meier aafa27c1ff script: fix printf format specifiers
Noticed on 32bit builds. Types changed in 0da73643.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-05-16 12:41:08 +02:00
Karel Zak 3d15a5e852 lsblk: fix notes about RAM disks
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-15 10:51:15 +02:00
Karel Zak b9dd5721fc lsblk: don't exclude RAM disks on --all
Reported-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-15 10:29:22 +02:00
Karel Zak 8a69ad47b8 iscript: s/COLS/COLUMNS/ in start message
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-14 13:59:52 +02:00
Karel Zak aa4e132f57 tests: update script done messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-14 13:54:41 +02:00