Commit Graph

10209 Commits

Author SHA1 Message Date
Andreas Henriksson a2ad58ac51 libfdisk: Fix order of C/H/S numbers output
While the header says C/H/S the actual numbers where printed as
C/S/H.

Addresses: http://bugs.debian.org/815847
Reported-by: "groups, freeman" <freeman_groups@reason.dyndns.org>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2016-03-07 15:08:50 +01:00
Karel Zak bcceb0c7dd Merge branch 'port-osx' of https://github.com/rudimeier/util-linux
* 'port-osx' of https://github.com/rudimeier/util-linux:
  lib: include strutils.h for mempcpy()
  build-sys: remove duplicate cal sources
  lib: provide fallback if mkostemp(3) missing
  build-sys: chrt requires a sched_set* function
  build-sys: add --disable-ipcrm --disable-ipcs
  build-sys: disable login-utils if shadow.h or utmp.h is missing
  login-utils: minor utmp cleanup
  build-sys: build_init should check for flock
  newgrp: rename memset_s()
  misc: fix some includes
  libsmartcols: fix uninitialized variable
  fdisk: fix warning, incompatible pointer types passing 'uint64_t *'
  logger: use SCM_CREDENTIALS on LINUX only
2016-03-07 14:37:31 +01:00
Dmitry V. Levin ae7065760d setarch: fix personality syscall return code check
Depending on architecture and kernel version, personality
syscall is either capable or incapable of returning an error.
If the return value is not an error, then it's the previous
personality value, which can be an arbitrary value
undistinguishable from an error value.
To make things clear, a second call is needed.

For more details about personality syscall peculiarities see
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=glibc-2.22-637-ge0043e17dfc5

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2016-03-07 14:23:21 +01:00
Ruediger Meier ab753d8fee lib: include strutils.h for mempcpy()
We have that mempcpy fallback since 2013 (02887b73) but forgot to
include it.

This fixes a segfault of cal(1) on FreeBSD and OSX.

Compiler warning was:
lib/mbsalign.c:468:14: warning: implicit declaration of function 'mempcpy' is invalid in C99 [-Wimplicit-function-declaration]
      dest = mempcpy (dest, str_to_print, min (n_used_bytes, space_left));
             ^
lib/mbsalign.c:468:12: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
      dest = mempcpy (dest, str_to_print, min (n_used_bytes, space_left));

CC: Daniel Trebbien <dtrebbien@gmail.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:24 +01:00
Ruediger Meier cc2d3c52bc build-sys: remove duplicate cal sources
These extra sources should have been removed since cal is
linked against libcommon (see 7b353df2).

CC: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:21 +01:00
Ruediger Meier 4d751c008e lib: provide fallback if mkostemp(3) missing
It's missing on OSX.

CC: Yuriy M. Kaminskiy <yumkam@gmail.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:18 +01:00
Ruediger Meier ee20c303ac build-sys: chrt requires a sched_set* function
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:15 +01:00
Ruediger Meier 42a4a15250 build-sys: add --disable-ipcrm --disable-ipcs
ipcs's source history looks like some people are using it on BSD
but it won't build on most non-Linux systems. That's why it's nice
let "./configure --disable-ipcrm --disable-ipcs" work.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:11 +01:00
Ruediger Meier d00c10edb8 build-sys: disable login-utils if shadow.h or utmp.h is missing
Actually we could have also used UL_REQUIRES_LINUX because our
utmp usage and the shadow.h header is unlikely to be portable.
However only requiring these headers may help others who are
curious what needs to be done to port something.

Note, we could easily make the utmp stuff more portable by using
utmpx which is POSIX standard and on LINUX (glibc) basically just
renaming work. See getutxent(3).

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:08 +01:00
Ruediger Meier a365953a24 login-utils: minor utmp cleanup
- consistently use ut->ut_user instead of ut->ut_name
- don't include obsolete lastlog.h BSD header

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:06 +01:00
Ruediger Meier c12fc5e1cd build-sys: build_init should check for flock
To let a plain ./configure work on systems without create_timer().
see 254743e4

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:03 +01:00
Ruediger Meier bbbf2aa853 newgrp: rename memset_s()
It's already defined in OSX standard c library.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:59 +01:00
Ruediger Meier eaac9f88f9 misc: fix some includes
features.h:  any glibc header includes this already
libgen.h:    was unused there
sys/uio.h:   for writev(3p)
sys/queue.h  seems like it was never used

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:56 +01:00
Ruediger Meier beabee7c67 libsmartcols: fix uninitialized variable
This got broken in 2a750b4c.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:54 +01:00
Ruediger Meier 262c94c2c7 fdisk: fix warning, incompatible pointer types passing 'uint64_t *'
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:48 +01:00
Ruediger Meier 4199e9891e logger: use SCM_CREDENTIALS on LINUX only
This is a build fix of FreeBSD and OSX. Basically we revert
the following commit for non-linux systems:
27a9eb53 "use --id as local socket credentials"

Note I could also compile it like this:

  #ifdef HAVE_SYS_UCRED_H
  # define _WANT_UCRED
  # include <sys/param.h>
  # include <sys/ucred.h>
  # define SCM_CREDENTIALS SCM_CREDS
  #endif

  [...]
  #ifdef _linux_
  cred->pid = ctl->pid;
  #endif
  [...]

... but don't know how to test whether it does what it
should.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-26 03:29:41 +01:00
Karel Zak 7154cc8926 blkdiscard: add --zeroout (BLKZEROOUT ioctl)
Requested-by: Yaniv Kaul <ykaul@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 15:21:38 +01:00
Karel Zak b64dc52a53 Merge branch 'ldadd-cflags-warnings' of https://github.com/rudimeier/util-linux
* 'ldadd-cflags-warnings' of https://github.com/rudimeier/util-linux:
  build-sys: disable unused parameter warnings for some test progs
  misc: fix compiler warnungs (unsigned/signed)
  misc: fix warnings "unused parameter" [-Wunused-parameter]
  libfdisk: fix warnings, "redundant redeclaration" [-Wredundant-decls]
  tests: fix compiler warnings [-Wmissing-prototypes]
  libfdisk: fix compiler warnings [-Wmissing-prototypes]
  libfdisk: fix missing symbol
  libblkid: fix compiler warnings [-Wmissing-prototypes]
  libmount: add mnt_fs_set_priority()
  build-sys: always add AM_CFLAGS
  build-sys: always use global LDADD
2016-02-24 13:51:10 +01:00
Karel Zak 1c3ed5bf17 libsmartcols: fix stupid typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 13:42:28 +01:00
Karel Zak 249fc8fe89 unshare: add example for persistent mount namespace
References: https://github.com/karelzak/util-linux/issues/289
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 13:28:19 +01:00
Ruediger Meier a03eac5294 chrt: restore removed ifdef SCHED_RESET_ON_FORK
They got lost in acde3a05.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-24 12:46:20 +01:00
Ruediger Meier 59e4a3827b chrt: fix case SCHED_RR
Looks like the logic was mistakenly changed in acde3a05.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-24 12:46:20 +01:00
Karel Zak cbe3e49535 libsmartcols: fix relative column width for maxout
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 12:34:37 +01:00
Karel Zak c1d185c77b findmnt: use scols_table_print_range() for --poll
This change fixes problem with duplicate header line.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 12:04:24 +01:00
Karel Zak 7db029e54a logger: always update header when writing stdin line
Addresses: http://bugs.debian.org/798239
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 10:40:08 +01:00
Ruediger Meier 2013b33f40 build-sys: disable unused parameter warnings for some test progs
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:20:22 +01:00
Ruediger Meier b9710f1f08 misc: fix compiler warnungs (unsigned/signed)
These ones should be fixed:
libblkid/src/probe.c:393:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/probe.c:907:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/probe.c:1221:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:540:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1043:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1056:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1057:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1061:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1199:27: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1410:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1431:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/superblocks/linux_raid.c:151:8: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/linux_raid.c:155:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/superblocks.c:375:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/superblocks/xfs.c:141:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libsmartcols/src/table.c:333:24: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table.c:344:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table_print.c:753:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/ask.c:364:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/utils.c:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:435:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:730:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/script.c:557:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/dos.c:1791:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/gpt.c:813:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:140:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:551:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:640:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:27 +01:00
Ruediger Meier 71177ab8f9 misc: fix warnings "unused parameter" [-Wunused-parameter]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:24 +01:00
Ruediger Meier 63a7065b2c libfdisk: fix warnings, "redundant redeclaration" [-Wredundant-decls]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:21 +01:00
Ruediger Meier 5fde1d9f06 tests: fix compiler warnings [-Wmissing-prototypes]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:09 +01:00
Ruediger Meier 74272f00e1 libfdisk: fix compiler warnings [-Wmissing-prototypes]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:27:34 +01:00
Ruediger Meier f3aca7ab21 libfdisk: fix missing symbol
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:25:41 +01:00
Ruediger Meier b55b9fccf6 libblkid: fix compiler warnings [-Wmissing-prototypes]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:25:07 +01:00
Ruediger Meier 48df5980b4 libmount: add mnt_fs_set_priority()
Looks like it got lost in ce4dd666.

Compiler warning discoverd this issue:
libmount/src/fs.c:1171:5: warning: no previous prototype for 'mnt_fs_set_priority' [-Wmissing-prototypes]
 int mnt_fs_set_priority(struct libmnt_fs *fs, int prio)
     ^

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:19:49 +01:00
Ruediger Meier b0b54cc582 build-sys: always add AM_CFLAGS
We were missing our nice compliler warnings for many programs
and libs. See next commits how many trivial and non-trival
warnings have to be fixed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:17:29 +01:00
Ruediger Meier b201f1d86c build-sys: always use global LDADD
This was a major showstopper when building on a system where
LTLIBINTL libs are needed (e.g. OSX). Maybe there are a few test
programs which wouldn't need LDADD ... never mind.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:16:58 +01:00
Karel Zak 334e5eba9e libsmartcols: fix scols_table_print_range() to print header
References: https://github.com/karelzak/util-linux/issues/287
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-22 10:43:25 +01:00
Karel Zak 96592b4902 Merge branch 'scols_table_print_range_to_string' of https://github.com/ignatenkobrain/util-linux 2016-02-22 10:37:41 +01:00
Karel Zak 80d00db17e Merge branch 'errno-strutils' of https://github.com/rudimeier/util-linux 2016-02-22 09:50:57 +01:00
Hushan Jia e0bbe3d6ff ipcs: show gid instead of uid
ipcs -i incorrectly used uid where it should be gid

Signed-off-by: Hushan Jia <hushan.jia@gmail.com>
2016-02-22 09:50:22 +01:00
Romain Naour 092bc0edaa vipw: Remove pre-ANSI compiler support
__P() is used for compatibility with old K&R C compilers. With
ANSI C this macro has no effect.

This fixes a compilation error with musl libc because of undeclared
__P.

Ref:
https://lists.samba.org/archive/samba-technical/2015-June/108042.html

Signed-off-by: Romain Naour <romain.naour@gmail.com>
2016-02-22 09:50:22 +01:00
Romain Naour 7944a03cef build-sys: fix typo
When timer_create is available have_timer must be
set to "yes". But instead have_time is used.

Replace have_time by have_timer.

Fixes:
http://autobuild.buildroot.net/results/993/9935cd0522d4f978ba2e788a690f66790686b76b

Signed-off-by: Romain Naour <romain.naour@gmail.com>
2016-02-22 09:50:22 +01:00
Igor Gnatenko cfa185721e libsmartcols: implement scols_table_print_range_to_string
Reference: https://github.com/karelzak/util-linux/issues/283
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-02-21 21:13:50 +01:00
Ruediger Meier 423ef37592 tests: add logger tests "id _numbers_ with spaces"
Leading spaces are allowed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-21 18:10:09 +01:00
Ruediger Meier f643d3349e lib/strutils: parse_size(), sync errno and return value
Maybe strtosize_or_err() is the only function which uses
this errno (wrongly). But it doesnt hurt to maintain rc
as well as errno.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-21 18:10:00 +01:00
Ruediger Meier ca8eff2ade lib/strutils: add more ERANGE messages
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-21 18:09:28 +01:00
Ruediger Meier 73b9e094a8 lib/strutils: fix errno usage in strtoint functions
Don't use undefined errno:
$ ./logger --no-act -t "wtf" --id="" message
logger: failed to parse id: '': No such file or directory

Don't print useless EINVAL message but ERANGE only:
$ ./logger --no-act -t "wtf" --id="XX" message
logger: failed to parse id: 'XX': Invalid argument

Note the ERANGE-only improvement does not change anything on
Linux/c99 as strtoul(3) only set ERANGE there.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-21 18:08:26 +01:00
Karel Zak 12ca9cb1f5 libsmartcols: add sample-scols-continuous
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-19 16:47:38 +01:00
Karel Zak 2981e0fd0e libsmartcols: support continuous printing
This patch allows to disable line-breaks. This feature is usable when
you want to re-print the same line more than once -- move terminal
cursor to the begin of the line and print again and again (aka
progress bar).

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-19 16:43:28 +01:00
Karel Zak 2a750b4c4e libsmartcols: add scols_table_print_range()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-19 14:43:06 +01:00