Commit Graph

11583 Commits

Author SHA1 Message Date
Ruediger Meier 11e904f02c libblkid: fix gcc-7 warning -Wint-in-bool-context
BLOCK_SIZE(sb) should be unsigned so that the left shift is defined.

This was the warning:

../libblkid/src/superblocks/exfat.c: In function 'probe_exfat':
../libblkid/src/superblocks/exfat.c:40:42: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context]
 #define CLUSTER_SIZE(sb) (BLOCK_SIZE(sb) << (sb)->bpc_bits)
                          ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
../libblkid/src/superblocks/exfat.c:122:14: note: in expansion of macro 'CLUSTER_SIZE'
  if (!sb || !CLUSTER_SIZE(sb))
              ^~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14 11:48:22 +02:00
Ruediger Meier acecab61e5 misc: fix gcc-7 snprintf warnings -Wformat-truncation
../lib/loopdev.c: In function 'loopcxt_next_from_sysfs':
../lib/loopdev.c:545:32: warning: '/loop/backing_file' directive output may be truncated writing 18 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
   snprintf(name, sizeof(name), "%s/loop/backing_file", d->d_name);
                                ^~~~~~~~~~~~~~~~~~~~~~
../lib/loopdev.c:545:3: note: 'snprintf' output between 19 and 274 bytes into a destination of size 256
   snprintf(name, sizeof(name), "%s/loop/backing_file", d->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../lib/sysfs.c: In function 'sysfs_is_partition_dirent':
../lib/sysfs.c:343:31: warning: '/start' directive output may be truncated writing 6 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
  snprintf(path, sizeof(path), "%s/start", d->d_name);
                               ^~~~~~~~~~
../lib/sysfs.c:343:2: note: 'snprintf' output between 7 and 262 bytes into a destination of size 256
  snprintf(path, sizeof(path), "%s/start", d->d_name);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/sysfs.c: In function 'sysfs_partno_to_devno':
../lib/sysfs.c:372:32: warning: '/partition' directive output may be truncated writing 10 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
   snprintf(path, sizeof(path), "%s/partition", d->d_name);
                                ^~~~~~~~~~~~~~
../lib/sysfs.c:372:3: note: 'snprintf' output between 11 and 266 bytes into a destination of size 256
   snprintf(path, sizeof(path), "%s/partition", d->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/sysfs.c:377:33: warning: '/dev' directive output may be truncated writing 4 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
    snprintf(path, sizeof(path), "%s/dev", d->d_name);
                                 ^~~~~~~~
../lib/sysfs.c:377:4: note: 'snprintf' output between 5 and 260 bytes into a destination of size 256
    snprintf(path, sizeof(path), "%s/dev", d->d_name);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14 11:48:22 +02:00
Ruediger Meier f64ddc95f3 misc: fix gcc-7 sprintf warnings -Wformat-overflow
../login-utils/last.c: In function ‘main’:
../login-utils/last.c:624:23: warning: ‘%s’ directive writing up to 31 bytes into a region of size 27 [-Wformat-overflow=]
   sprintf(path, "/dev/%s", ut->ut_line);
                       ^~   ~~
../login-utils/last.c:624:3: note: ‘sprintf’ output between 6 and 37 bytes into a destination of size 32
   sprintf(path, "/dev/%s", ut->ut_line);

../libblkid/src/devname.c: In function 'probe_one':
../libblkid/src/devname.c:166:29: warning: '%s' directive writing up to 255 bytes into a region of size 245 [-Wformat-overflow=]
   sprintf(path, "/sys/block/%s/slaves", de->d_name);
                             ^~
../libblkid/src/devname.c:166:3: note: 'sprintf' output between 19 and 274 bytes into a destination of size 256
   sprintf(path, "/sys/block/%s/slaves", de->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14 11:48:22 +02:00
Ruediger Meier 39ff5b34d3 hwclock: fix warning [-Winvalid-noreturn]
clang warned:

 CC       sys-utils/hwclock.o
../sys-utils/hwclock.c:1274:1: warning: function declared 'noreturn' should not return [-Winvalid-noreturn]

We have to move the noreturn attribute from the function definition
to the declaration.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14 11:48:22 +02:00
Ruediger Meier b68d953e62 libmount: btrfs, remove unused setter functions
We have never used them since introduced in 2cd28fc8.
clang compiler warned about it.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14 11:48:22 +02:00
Ruediger Meier b017648ad3 tests: fix fincore, don't use variable COLUMNS
COLUMNS is automatically set by bash and may result in stupid
errors like

  fincore: unknown column: 160

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14 11:48:22 +02:00
Ruediger Meier 59879322e6 libsmartcols: fix warning "unused parameter"
Noticed on OSX.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-13 23:39:22 +02:00
Ruediger Meier 92e486f80e libfdisk: fix guid usage of packed struct gpt_entry
clang issued warnings like this:

../libfdisk/src/gpt.c:371:18: warning: taking address of packed member 'type' of class or structure 'gpt_entry' may result in an unaligned pointer value [-Waddress-of-packed-member]
        guid_to_string(&e->type, str);
                        ^~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-13 23:38:48 +02:00
Ruediger Meier 7f387c5c21 libfdisk: cleanup sun label checksum usuage
We are using now the formerly unused function sun_pt_checksum(). This
cleanup was motivated by clang compiler warning, see below. Also nice
that we are now always using uint16_t instead of short.

Warning was:

../libfdisk/src/sun.c:177:35: warning: taking address of packed member 'csum' of class or structure 'sun_disklabel' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                while(ush < (unsigned short *)(&sunlabel->csum))

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-13 18:06:36 +02:00
Karel Zak c972852b29 lscpu: cleanup DMI detection return codes
Michal wrote:
 There is weird mix of logic in lscpu-dmi.c which sometimes returns 0 and
 sometimes -1 on error. Since most checks are if (rc) goto done; this
 bails out early on error skipping some detection methods. Further, in
 lscpu.c all following detections are guarder by if(hyper) so returning
 -1 causes all following methods to be skipped.

Reported-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-13 12:15:11 +02:00
Karel Zak f12e437436 libsmartcols: (docs) add new functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-13 11:17:06 +02:00
Karel Zak d9eddf72a3 column: add --table-header-repeat
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-13 11:14:46 +02:00
Karel Zak 36e07cebf1 libsmartcols: add header-repeat feature
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-13 11:11:17 +02:00
Karel Zak 5df8f14c30 libsmartcols: add missing symbols
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-12 16:35:58 +02:00
Karel Zak 26cd36a636 Merge branch 'pylibmount-NULL-terminate-kwlist-in-Context_init' of https://github.com/zmedico/util-linux
* 'pylibmount-NULL-terminate-kwlist-in-Context_init' of https://github.com/zmedico/util-linux:
  pylibmount: NULL terminate kwlist in Context_init
2017-06-12 15:39:59 +02:00
Karel Zak e33b387483 libsmartcols: add scols_table_{set,get}_termheight()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-12 11:51:36 +02:00
Karel Zak f46a8d7e66 lib/ttyutils: return terminal lines too
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-12 11:38:38 +02:00
Karel Zak b35ca0ab37 docs: update TODO, remove auto,noauto
It seems good enough to use the current semantic and check for
"noauto" string rather than evaluate "auto/noauto" as a bit flag.

We use flags for mount options, but in this case (mount --all) it's
overkill to convert all options on all fstab entries to flags just to
be sure that somewhere is no "auto,noauto" obscure setting.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-12 10:44:37 +02:00
Karel Zak 1d9e35cc1e lsblk: add option --tree
Now lsblk uses --list when --sort <column> is specified. This patch
allows to specify --tree to overwrite this default behavior add to
force tree-like output. In this case tree branches are sorted by the
<column>.

$ lsblk --sort SIZE
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda2   8:2    0   200M  0 part /boot
sda1   8:1    0   200M  0 part /boot/efi
sda6   8:6    0   7.8G  0 part [SWAP]
sda5   8:5    0  35.1G  0 part /home/misc
sda4   8:4    0    50G  0 part /
sdb1   8:17   0  74.5G  0 part /home/archive
sdb    8:16   0  74.5G  0 disk
sda3   8:3    0 130.3G  0 part /home
sda    8:0    0 223.6G  0 disk

$ lsblk --sort SIZE --tree
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   0  74.5G  0 disk
└─sdb1   8:17   0  74.5G  0 part /home/archive
sda      8:0    0 223.6G  0 disk
├─sda2   8:2    0   200M  0 part /boot
├─sda1   8:1    0   200M  0 part /boot/efi
├─sda6   8:6    0   7.8G  0 part [SWAP]
├─sda5   8:5    0  35.1G  0 part /home/misc
├─sda4   8:4    0    50G  0 part /
└─sda3   8:3    0 130.3G  0 part /home

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-09 11:33:18 +02:00
Karel Zak bff78d701d libblkid: (vfat) add more debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-09 11:11:38 +02:00
Zac Medico 29b721bc9d pylibmount: NULL terminate kwlist in Context_init
Fixes a segfault observed with python3.6.
2017-06-07 17:25:12 -07:00
Karel Zak 11573ac0c8 libmount: (umount) use mount table filter on -c only
The path canonicalization is the worst use-case, it's better to read
all mount table than try canonicalize.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-07 12:40:17 +02:00
Karel Zak f8416301c1 libmount: use mount table filter on --no-canonicalize
The umount command option --no-canonicalize means that the path is
already canonical. So, we can use mount table filter in this case too.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-07 11:35:26 +02:00
Karel Zak f60d62afa1 rename: add -o to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-06 12:09:34 +02:00
Karel Zak 5fba8b758c Merge branch 'rename-nooverride' of https://github.com/dov/util-linux
* 'rename-nooverride' of https://github.com/dov/util-linux:
  Changed "override" to "overwrite" rename option.
  Added --no-override option to rename.
2017-06-06 12:07:26 +02:00
Karel Zak 4d670b2e44 Merge branch 'hwclock-localtime' of https://github.com/Villemoes/util-linux 2017-06-06 12:06:28 +02:00
Karel Zak 9f1af33141 umount: add note about NFS and -c to umount.8
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-06 12:05:21 +02:00
NeilBrown ce6e269447 umount: never 'stat' the path when "-c" is given.
It is currently not possible to reliably and automatically
unmount an NFS filesystem. If the server is not available, the
umount command will hang.

The hang can be avoided by using "-l" or "-f", but neither
of these are appropriate for automatic use such as by an
automounter (e.g automountd or systemd).

"-l" will unmount even if the filesystem is in use, which
an automounter generally doesn't want.  If the filesystem
is in use, then the umount should fail.

"-f" can cause the filesystem to abort pending transactions
which might break filesystem semantics.  This can be useful
in the hands of a sysadmin, but not when used by an
automatic tool.

umount has another option, "-c" aka "--no-canonicalize"
which avoids some "stat" calls.
Currently this doesn't avoid all calls to
canonicalize_path()
as
  mnt_context_prepare_umount() ->
    lookup_umount_fs() ->
      mnt_context_find_umount_fs() ->
        mnt_context_get_mtab_for_target() ->
	  mnt_resolve_path() ->
	    canonicalize_path_and_cache() ->
	      canonicalize_path()

leads to that function being called.

The "-c" option could be taken to mean "I know what I'm
doing, this really is the path to a mount point, I just want
you to unmount it".  Given that, it seems suitable to
extend this to avoid all 'stat' calls on the mountpoint.

It is already appropriate for any automount program to pass
"-c" to "umount", so they can be changed to do so at any
time.
With the patch below, "-c" will result in the mountpoint
never being "stat"ed, so umount won't hang on an
inaccessible server.

This isn't quite sufficient, for NFS at least, as the usage
of libmount in umount.nfs still calls 'stat' on the mount
point.
"-c" isn't passed to the umount helper, but it is reasonable
for such helpers to assume "-c" because "umount" will have
canonicalized the path when that is appropriate.

So, this patch treats "-c" much like "-l" and "-f" when
deciding whether it is safe to 'stat' the path.

Signed-off-by: NeilBrown <neilb@suse.com>
2017-06-06 11:41:05 +02:00
Karel Zak daef243fac Merge branch 'fdformat-done1' of https://github.com/jwilk-forks/util-linux
* 'fdformat-done1' of https://github.com/jwilk-forks/util-linux:
  fdformat: clear progress message before printing "done"
2017-06-05 15:27:39 +02:00
Sebastian Schrader 94826d0dec setpriv: Add --init-groups option
Add an --init-groups option which initializes the supplementary groups
from the system's group database (e.g /etc/group) using initgroups(3).
2017-06-05 13:44:11 +02:00
Karel Zak 5f032ae4bb chsh: cleanup global_shells usage
* global variables are always initialized by NULL
* it seems we need it as global variable due to libreadline, then use it as
  global everywhere in the same .c file.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-05 13:29:20 +02:00
Karel Zak 54373fb9b9 chsh: split get_shell_list()
Let's use two functions is_known_shell() and print_shells() to make
the code more readable and to avoid complex semantic of the original
get_shell_list().

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-05 13:15:59 +02:00
Sami Kerola d1818b9e12 chsh: make readline completion to propose valid shells
This is better than default readline completion, that gives paths from
current directory onwards.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-05 12:58:52 +02:00
Dov Grobgeld 9a838c3c55 Changed "override" to "overwrite" rename option. 2017-06-03 23:40:47 +03:00
Jakub Wilk fc747ee72a fdformat: clear progress message before printing "done"
Before:

    Formatting ... done1

After:

    Formatting ... done

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2017-06-02 23:54:10 +02:00
Karel Zak dd9bae58ae build-sys: release++ (v2.30)
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-02 12:22:29 +02:00
Karel Zak 10a68c54e9 docs: update v2.30-ReleaseNotes
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-02 12:20:19 +02:00
Karel Zak df55fbfe9c docs: update AUTHORS file
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-02 12:16:08 +02:00
Karel Zak 99791a1984 lib/pager: use xalloc
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-02 12:07:36 +02:00
Karel Zak 2a57a232b6 tests: update build-sys test
The libtinfo is enough (and libncurses optional for cal).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-02 12:03:46 +02:00
Karel Zak 12e29c7199 po: merge changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-02 11:30:19 +02:00
Karel Zak 7dec8dfeca Merge branch 'master' of https://github.com/yurchor/util-linux
* 'master' of https://github.com/yurchor/util-linux:
  Fix minor typos
2017-06-02 11:13:39 +02:00
Yuri Chornoivan 6ef65081c5 po: update uk.po (from translationproject.org) 2017-06-02 11:08:30 +02:00
Mesutcan Kurt cdfe02e35b po: update tr.po (from translationproject.org) 2017-06-02 11:08:30 +02:00
Sebastian Rasmussen 42fd838c91 po: update sv.po (from translationproject.org) 2017-06-02 11:08:30 +02:00
Jakub Bogusz 0062b697f7 po: update pl.po (from translationproject.org) 2017-06-02 11:08:30 +02:00
Takeshi Hamasaki 2affdd5f7d po: update ja.po (from translationproject.org) 2017-06-02 11:08:30 +02:00
Philipp Thomas 08272f4f7e po: update de.po (from translationproject.org) 2017-06-02 11:08:30 +02:00
J William Piggott b3d41ca07c docs: add information about mailing list rejection
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-01 19:42:21 -04:00
Karel Zak 535a4090b4 lib/pager: don't use pager if command not available
for example:
 # PAGER=foo dmesg -H
 sh: foo: command not found

the same problem is we have with fdisk 'l' command:

 # PAGER=foo fdisk /dev/sda
 Welcome to fdisk (util-linux 2.30-rc2-33-41b71).
 ...
 Command (m for help): l
 sh: foo: command not found

It seems better to don't use pager at all if not available.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-01 14:20:20 +02:00