Commit Graph

835 Commits

Author SHA1 Message Date
Karel Zak 3457d90e30 libfdisk: support bootbits protection from (p)MBR
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-13 13:40:25 +02:00
Jörg Jenderek 25156ba16b libfdisk: recognize FAT32 partitions hidden by Acronis software
References: http://www.acronis.de/products/trueimage
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Jörg Jenderek <joerg.jen.der.ek@gmx.net>
2015-04-08 10:24:26 +02:00
Rainer Gerhards 3eb3c8d77e silence compiler warning
This is primarily cosmetic, albeit it also provides an only very
slight improvement in compile time error checking.
2015-03-10 14:13:38 +01:00
Karel Zak c958032a6d build-sys: fix typo 2015-03-06 14:32:12 +01:00
Karel Zak 26e8964b9d lib/timer: use separate file for timers
It seems that static builds require -lpthread for timer_* functions.
It's better to keep it out of our libs (e.g. libmount) to avoid
unnecessary dependence.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-06 13:17:20 +01:00
Karel Zak b9dedd3d34 lib/monotonic: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-05 13:32:53 +01:00
Karel Zak b28842ae67 agetty: support /usr/lib/os-release too
http://www.freedesktop.org/software/systemd/man/os-release.html

The file /etc/os-release takes precedence over /usr/lib/os-release.
Applications should check for the former, and exclusively use its data
if it exists, and only fall back to /usr/lib/os-release if it is
missing.

Reported-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-05 12:25:28 +01:00
Karel Zak 46cd5b1767 flock: fix timeout handler pointer usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-05 10:47:59 +01:00
Sami Kerola 378543e13f flock: improve timeout handling
Signal ALRM raised by the timer, and the timer only, will be considered
as a timeout criteria.

Secondly time interval is made to use monotonic clock.  Documentation of
ITIMER_REAL is unclear whether that time is affected various sources of
clock skew, or does it even tick when system is suspended.

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-05 10:31:01 +01:00
Karel Zak f71d1104df build-sys: add --enable-usrdir-path
The directories /{sbin,bin} are symliks to /usr/{sbin,bin} on many
systems. This patch add new ./configure option to remove the non-usr
paths from the default $PATH environment variable.

The default $PATH is hardcoded in login(1) and can be overwritten
by /etc/login.defs.

default:

./test_pathnames | grep DEFPATH
       _PATH_DEFPATH /usr/local/bin:/bin:/usr/bin
  _PATH_DEFPATH_ROOT /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

--enable-usrdir-path:

./test_pathnames | grep DEFPATH
       _PATH_DEFPATH /usr/local/bin:/usr/bin
  _PATH_DEFPATH_ROOT /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

This patch does not modify install paths, you still have to care about
--{bin,lib}dir configure options.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-03 11:43:01 +01:00
Karel Zak 62dc0ee83b lib/colors: add USAGE_COLORS_DEFAULT
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-25 12:35:05 +01:00
Sami Kerola 52a49e9add logger: move /dev/log to pathnames.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-02-24 13:18:49 +01:00
Sami Kerola cd2a6f1cfd rpmatch: use symbolic value when evaluation return codes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-02-24 12:42:06 +01:00
Karel Zak 30b294c491 lib/strutils: extend parse_switch() to accept more options
* allow to specify more 0|1 pairs
* allow to specify error message

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-24 12:04:22 +01:00
Sami Kerola e5cf147655 lib/strutils: move parse_switch() from setterm(1) to library
To allow sharing the code with other utilities.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-24 11:33:31 +01:00
Eric W. Biederman 0bf159413b unshare: Fix --map-root-user to work on new kernels
In rare cases droping groups with setgroups(0, NULL) is an operation
that can grant a user additional privileges.  User namespaces were
allwoing that operation to unprivileged users and that had to be
fixed.

Update unshare --map-root-user to disable the setgroups operation
before setting the gid_map.

This is needed as after the security fix gid_map is restricted to
privileged users unless setgroups has been disabled.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2015-01-09 10:32:33 +01:00
Karel Zak 47123602e6 Merge remote-tracking branch 'sami/2014wk49'
* sami/2014wk49:
  chfn: make command to obey login.defs CHFN_RESTRICT instructions
  chfn: remove set_changed_data() and add add_missing()
  chfn: rename prompt() to ask_new_field()
  chfn: move new and old finger structs to chfn control struct
  chfn: clean up parse_argv()
  chfn: add minimalistic struct chfn_control
  chfn: simplify parse_passwd() by using strsep()
  chfn: fix usage() regression
  chfn: use xasprintf() rather than bunch of strlen() and malloc() calls
  chfn: rewrite prompt() to use strutils
  chfn: remove function prototypes
  lslogins: use hardcoded paths from pathnames.h
  lslogins: add space to systemd journal header and message
  lslogins: reject unknown time format arguments
  lslogins: fix short options
  lslogins: tell why command failed
  lslogins: make journald last logs time stamps to honor --time-format
  lslogins: allow changing password changed and expiration time formats
2014-12-19 14:28:42 +01:00
Sami Kerola d763c23081 include/c: define UL_ASAN_BLACKLIST address_sanitizer function attribute
The UL_ASAN_BLACKLIST allows AddressSanitizer to be switched off for
functions that cannot be checked.

Reference: http://dxr.mozilla.org/mozilla-central/source/mfbt/Attributes.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 11:32:38 +01:00
Sami Kerola 4ecc6dbb53 lslogins: use hardcoded paths from pathnames.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 2f8610ee95 strutils: fix unsigned integer overflows [AddressSanitizer]
include/strutils.h:174:10: runtime error: unsigned integer overflow: 0 -
1 cannot be represented in type 'size_t' (aka 'unsigned long')

include/strutils.h:178:6: runtime error: unsigned integer overflow:
18446744073709551615 + 1 cannot be represented in type 'size_t' (aka
'unsigned long')

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:10:48 +00:00
Sami Kerola 737532efe5 fdisk: (sgi) fix unsigned integer overflow [AddressSanitizer]
include/pt-sgi.h:103:7: runtime error: unsigned integer overflow: 0 -
1186450447 cannot be represented in type 'unsigned int'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:10:48 +00:00
Will Johansson fe2c9909cd login-utils: Enable building util-linux against OpenPAM
OpenPAM is compatible with util-linux, with a few changes, namely
using OpenPAM's conversation function, openpam_ttyconv.

We check for Linux-PAM by querying for security/pam_misc.h, and OpenPAM
by querying for security/openpam.h.

Signed-off-by: Will Johansson <will.johansson@gmail.com>
2014-12-15 10:16:03 +01:00
Karel Zak 372112e908 libmount: add new libmnt_monitor API
It's usually enough to us [e]poll() to monitor kernel mount table, but
there is no way how to monitor changes in userspace mount options
(e.g. _netdev). The management of these mount options is completely
hidden in libmount and /rub/mount/utab is private libmount file.

This patch introduces new libmnt_mount API to monitor also userspace
mount table.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-05 15:30:04 +01:00
Karel Zak 764b697c56 libfdisk: fix bug in cmp_numbers() and partitions sorting
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-04 13:06:03 +01:00
Karel Zak 19ff8ff7c4 libfdisk: fix cfdisk freespace analyze
The problem is how fdisk_partition_cmp_start() compare numbers, the
function returns result from "a->start - b->start", unfortunately the
numbers are uint64, but function returns "int".

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-04 10:27:39 +01:00
Karel Zak e017ef8bb9 lib/sysfs: add subsystem and hotplug detection
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-02 10:59:48 +01:00
Karel Zak cca51b9e45 include/carefulputc: encode also ' and $ in fputs_quoted() output
This change is important for commands linked with libsmartcols (e.g. lsblk(1))
to make it more safe for crazy scenarios like

   eval $(lsblk --fs --pairs /dev/sdb1)

where the command returns NAME="value" from filesystem LABELS (etc.)

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-27 13:36:09 +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 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
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
Sami Kerola c181617cfb mkswap: remove unnecessary size check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-07 13:21:05 +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 ef316a27de include/debug: improve and cleanup
* use ul_debug_ prefix for all routines
* support <NAME>_DEBUG=all also for programs without debug mask names
  (so we can avoid 0xffff mask in man pages)
* add function to print debug help

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-03 12:51:17 +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 819d9a2975 include/debug: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-24 11:19:23 +02:00
Karel Zak 3635f53ca2 whereis: cleanup debug stuff, fix argv[] usage
* use debug stuff from include/debug.h and make whereis(1) sensitive
  to WHEREIS_DEBUG=0xffff mask

* fix problem with argv[] usage

  # whereis -b -m -M /usr/share/man/man1 -B /usr/bin -f gcc
  bin: /usr/local/bin
  gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz

the code ignores "-B" and /usr/bin is interpreted as search pattern,
expected result is:

  # whereis -b -m -M /usr/share/man/man1 -B /usr/bin -f gcc
  gcc: /usr/share/man/man1/gcc.1.gz /usr/bin/gcc

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765306
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-23 13:44:00 +02:00
Sami Kerola aeeb81317e include/debug: remove duplicate 'const' declaration warning
./include/debug.h:89:55: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 13:09:35 +02:00
Sami Kerola 2a0d2a8e11 include: fix compiler warnings
This change has motivation to make -Wall -pedantic compiler options to
spit a little bit less noise, which with luck will increase change to
notice real issues.

Multiple of these:

warning: ISO C forbids braced-groups within expressions [-Wpedantic]

And nearly 300 times reported:

include/c.h:75:41: warning: struct has no named members [-Wpedantic]
 #define UL_BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:35 +02:00
Karel Zak 286f1e229b Merge branch 'misc' of git://github.com/kerolasa/lelux-utiliteetit
* 'misc' of git://github.com/kerolasa/lelux-utiliteetit:
  textual: share crypt() error message in sulogin and newgrp
  newgrp: avoid use of obsolete getpass() function
  newgrp: use libc function to read gshadow if it is available
  setarch: use personality() system call when it is available
  setarch: reindent code
  hwclock: remove referal to deprecated keyboard interface
  eject: make open_device() and select_speed() to use struct eject_control
  eject: add struct eject_control to remove global variables
  mountpoint: simplify if statement
  mkfs.minix: fix couple compiler warnings
  mountpoint: add struct mountpoint_control
  last: improve code readability by renaming variable names
  last: make is_phantom() when kernel config does not include audit support
  lib: remove xgetpass()
  include: simplify fputc_careful() in carefulputc.h
  libuuid: add extern qualifiers to uuid/uuid.h system header
2014-09-22 14:55:37 +02:00
Karel Zak 18b3e5495b swapon: split swapon-common.c
swapon    - requires libmount and libblkid
 swapoff   - requires libmount
 swaplabel - requires libblkid

This patch add lib/swapprober.c with blkid stuff for swap. It allows
to use and link libblkid only when necessary.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-22 13:16:25 +02:00
Sami Kerola 96c4bc4dd2 lib: remove xgetpass()
This function is not in use, and it has reference to obsoleted getpass().

Reference: http://man7.org/linux/man-pages/man3/getpass.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Sami Kerola c6d2d74ea0 include: simplify fputc_careful() in carefulputc.h
New version of comparisions does the same thing as the old without being
quite as difficult to understand.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Christoph Egger c32270d41f agetty: fixing FTBFS on !linux (Debian util-linux 2.20.1-1.2)
Handle vc flags missing on FreeBSD
Fix tty creation on kFreeBSD taking patch from 2.19

Addresses-Debian-Bug: #650185
2014-09-17 10:14:50 +02:00
Karel Zak d947f85df4 include/optutils: fix typo
Reported-by: Rafael Ferreira <rafael.f.f1@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28 08:39:54 +02:00
Karel Zak 22e9e9c8e9 libblkid: move string trim function to strutils.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-25 15:31:53 +02:00
Karel Zak 1e06330329 include/debug: allow to speficy empty masknames
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 14:19:21 +02:00
Karel Zak 03e4220d29 include/debug: cleanup masks
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 14:13:32 +02:00
Karel Zak 6d577b7089 include/debug: make masknames optional
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 13:51:42 +02:00
Ondrej Oprala 14ad2353cc libs/debug: accept human readable names for _DEBUG=
For example
	$ LIBMOUNT_DEBUG=tab,cache findmnt

to debug only TAB and CACHE subsystem.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 12:33:47 +02:00
Karel Zak b8731ebcf2 lib/colors: add function to return color from scheme
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 10:09:08 +02:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Karel Zak 6c987ca9d7 lib/sysfs: allow to write to sysfs attributes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-01 12:08:44 +02:00
Sami Kerola 25a365ef5a swaplabel: move swapon-common to include directory
This fixes the following compiler warning.

disk-utils/swaplabel.c:175:2: warning: implicit declaration of function
'get_swap_prober' [-Wimplicit-function-declaration]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-28 12:28:05 +02:00
Lauri Nurmi a5c523a0e7 Fix typo "ioclt" in various files. 2014-07-11 22:52:09 +03:00
Karel Zak 2ad2196349 build-sys: support ./configure ADJTIME_PATH=
.. to override the default /etc/adjtime path.

Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-19 10:30:56 +02:00
Karel Zak f272b32c57 lib/fileutils: xalloc stuff in library-like code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-18 12:57:42 +02:00
Karel Zak 62acb047a6 build-sys: remove obsolete wholedisk.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-17 12:16:29 +02:00
Karel Zak b55e5886ea lib/sysfs: add sysfs_devno_is_wholedisk()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-17 12:15:01 +02:00
Karel Zak 39866431ee lib/sysfs: add sysfs_devno_is_lvm_private() from libblkid
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-17 11:20:32 +02:00
Karel Zak d4eaabc86a lib/fileutils: add stripoff_last_component() from libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-09 11:54:32 +02:00
Karel Zak 934530c7e8 lib/fileutils: add mkdir_p() from libmount 2014-06-09 10:59:18 +02:00
Ondrej Oprala f1728a4cbd lslogins: add readtump.h header 2014-05-15 13:55:59 +02:00
Ondrej Oprala 29cc2a5568 lslogins: add functionality
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:55:59 +02:00
Karel Zak 7a4704d826 lib/colors: support schemes customization
* parse terminal-colors.d/*.scheme files, expected format is

    <name> <color-sequence>

 * supported color sequences:

     - color name (e.g. "red")
     - dir_colors compatible xx;yy (e.g. 01;31) where the sequence may
       contains control chars like \e \a  ..etc.

 * scheme is parsed on demand

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:09:03 +02:00
Karel Zak e66a662726 lib/colors: allow to temporary disable colors
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:09:02 +02:00
Karel Zak 570b32100f lib/colors: add support for @term and /home/kzak
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:09:02 +02:00
Karel Zak 5d7bdfd653 include/boottime: add a new file
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 16:38:53 +02:00
Karel Zak 08ca3e26a8 lib/timeutils: remove get_boot_time from libcommon
clock_gettime() needs -lrt, so let's keep this stuff
outside libcommon.la

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 13:16:05 +02:00
Benno Schulenberg 82b219f706 include/c: do not gettextize a wordless string
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:09:26 +02:00
Benno Schulenberg 459e95f391 include/carefulputc: remove a duplicate include
Also tweak a comment.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:09:22 +02:00
Benno Schulenberg 68411ba260 include/c: remove a duplicate include
Also tweak some comments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:09:21 +02:00
Sami Kerola 24f83f7392 swapon, swapheader, mkswap: move swap signature to header
Both swapon and mkswap need to know what is valid device signature, so
share the value.

[kzak@redhat.com: - use SWAP_SIGNATURE_SZ properly in write_signature()]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 10:16:54 +02:00
Sami Kerola d38b55375f include/swapheader.h: ensure type sizes
Use consistently the same type sizes as in libblkid and kernel.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-06 10:12:14 +02:00
Sami Kerola 506b499991 mkswap: remove legacy swap structure
If software archeolgists want to know how the old, and unused, swap
header looked they can dig it from the revision history.

[kzak@redhat.com: - use sizeof() for SWAP_HEADER_SIZE]

Reference: 4c85aa3a4c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 10:08:51 +02:00
Sami Kerola 8a101b1447 mkswap, swaplabel: move version number to header
Corrently only the swap version 1 is supported, which is a magic value so
move it to header.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-04 11:42:03 +01:00
Sami Kerola ff1aaf9966 include/c.h: add macro to print definitions as string
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-04 11:42:03 +01:00
Sami Kerola 929f939e6a dmesg: move get_boot_time() to lib/timeutils
In future the last(1) will use get_boot_time() as well.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-04 11:42:03 +01:00
Karel Zak 0c33fcbf23 lib/mbalign: report also size in bytes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-15 15:25:18 +02:00
Karel Zak c426f70fd4 lib/mbsalign: split mbs_safe_encode()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-15 13:58:34 +02:00
Ondrej Oprala 10a628c8b3 lib/tt.c: Goodbye!
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:19 +02:00
Karel Zak 78a3b0af30 include/carefulputc: cleanup and add fputs_{quoted,nonblank}()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Sami Kerola 0720d60cc1 mcookie: use lib/randutils
The mcookie should reuse existing code, and there is definitely no need
to prefer /dev/random for this utility.  See reference for explanation
about later statement.

References: http://www.2uo.de/myths-about-urandom/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-03-26 10:36:18 +01:00
Karel Zak e7b49879ad include/debug: add another debug macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-21 12:04:12 +01:00
Karel Zak d282c88df5 include/debug: fix coding style
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-21 11:21:56 +01:00
Karel Zak 9a7769141a Merge branch 'common_debug' of https://github.com/ooprala/util-linux
* 'common_debug' of https://github.com/ooprala/util-linux:
  clean up redundant macros and defines
  libfdisk: use include/debug.h
  libblkid: use include/debug.h
  libmount: further debug.h integration
  libcommon: don't mention lib versions in debug macros
  libcommon: define more debugging macros
  libmount: use macros from include/debug.h
  libcommon: add common debugging routines
2014-03-21 10:59:58 +01:00
Karel Zak 422f93bfbb include/closestream: don't wipe errno on EPIPE
... the code in close_stdout() is sensitive to EPIPE, so
wipe errno is close_stream() is probably bad idea.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-13 12:41:03 +01:00
Ondrej Oprala 274228fecc clean up redundant macros and defines
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-13 11:53:31 +01:00
Ondrej Oprala b681c25834 libcommon: don't mention lib versions in debug macros
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-13 10:42:11 +01:00
Ondrej Oprala cb3fa84753 libcommon: define more debugging macros
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-12 15:40:40 +01:00
Ondrej Oprala db08389d87 libcommon: add common debugging routines
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-12 14:37:41 +01:00
Karel Zak e11040bdfc lib/tt: keep track about output order
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak 9a66e1e76f lib/tt: add tt_line_get_userdata()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak 6736192af4 include/list: add void data to the sort cmp function
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 1b1f66e477 lib/mbalign: add mbs_safe_width() from tt.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 2e6c3a53f9 include/xalloc: add xvasprintf()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak ed494c8d50 include/tt: add function to convert table to string
Note that open_memstream() is POSIX-1.2008, so it's possible than not
all libc have already implemented this function.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 7358229637 lib/tt: add reduce term width functionality
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak b839bd4fa1 lib/tt: add TT_FL_MAX to fill screen
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 575a1de03a lib/tt: add tb_get_nlines()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 0cd73f41e8 lib/tt: don't hardcode stdout as output
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 11fd5edb9d include/tt: add tt_is_empty()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:11 +01:00
Ondrej Oprala d0c9ddc3cc lib/colors: check for /etc/terminal-colors.d/[util].disable
[kzak@redhat.com: - move paths to pathnames.h,
                  - use static path buffer]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 09:38:09 +01:00
Karel Zak df019e9be7 libmount: add statfs_magic.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-06 13:09:16 +01:00
Karel Zak 68f7b572ba lib/color: add colorscheme parser 2014-02-10 14:50:12 +01:00
Karel Zak 663bf04061 losetup: wait for udev
On system with /dev/lop-control the udevd creates /dev/loopN nodes.
It seems better to wait a moment after unsuccessful open(/dev/loopN)
and try it to open again.

The problem is pretty visible on systems where udevd also modifies
permission for loopN devices, then open() fails with EACCES when
losetup executed by non-root user (but user who is in "disk" group).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1045432
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-24 13:58:40 +01:00
Karel Zak a5bd793996 include/c.h: prefer nanosleep() over usleep()
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.

The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.

The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-24 13:04:14 +01:00
Lubomir Rintel 4da21e374e unshare: Add possibility to add mapping into root user in user namespace
This makes it very convenient to use make use of privileged actions
on CONFIG_USER_NS enabled kernels, without having to manually tinker
with uid_map and gid_map to obtain required credentials (as those
given upon unshare() vanish with call to execve() and lot of userspace
checks for euid==0 anyway).

Usage example:

$ unshare --uts
unshare: unshare failed: Operation not permitted

$ unshare --user --uts
[nfsnobody@odvarok ~]$ hostname swag
hostname: you must be root to change the host name

$ unshare -r --uts
[root@odvarok util-linux]# hostname swag
[root@odvarok util-linux]#

[kzak@redhat.com: - move code to map_id()
                  - use all-io.h
                  - add paths to pathnames.h]

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-07 11:04:42 +01:00
Karel Zak dd3bc51a53 lib/path: add path_strdup()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-06 16:48:13 +01:00
Sami Kerola d8a9b90756 docs: update links to http://git.kernel.org/ web repository views
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-12 11:47:57 +01:00
Ondrej Oprala 675de3f5c1 strutils: add skip_space() function
[kzak@redhat.com: - add also skip_blank(),
                  - remove duplicate implementation from libmount]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-08 14:14:34 +01:00
Michael Forney 00c505d9cf include: Add missing includes
sys/types.h: For u_char typedef
sys/params.h: For MAXNAMLEN
sys/ttydefaults.h: For various tty definitions (also add configure check)

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-04 11:51:21 +02:00
Karel Zak 88407b9321 nologin: add new command
Currently it's maintained as distro specific (or people use impolite
/bin/false way).

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-30 13:36:26 +02:00
Karel Zak e93d5475fe build-sys: fix include Makemodule.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-26 10:41:18 +02:00
Karel Zak 80a1712f54 fdisk: add -L to colorize output
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:09 +02:00
Karel Zak 0dd3dfb8e3 fdisk: (bsd) write/read PT code cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:06 +02:00
Karel Zak cc3d127e4c libblkid: move bsd definitions to pt-bsd.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:04 +02:00
Karel Zak 5099226711 libfdisk: move mbr code to the library
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:04 +02:00
Karel Zak e8bf93ded2 fdisk: add mbr_get_partition()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:02 +02:00
Karel Zak b44244cb98 fdisk: use functions from pt-mbr.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:02 +02:00
Karel Zak 71ade4da58 libblkid: rename sys_type to sys_ind
This makes struct dos_partition more compatible with the current fdisk
code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:02 +02:00
Karel Zak b198111523 include/pt-mbr: add functio to store le
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:02 +02:00
Karel Zak f917738efa libblkid: move MBR definitions to include/pt-mbr.h 2013-09-16 16:47:02 +02:00
Karel Zak d4caf70067 fdisk: (sgi) fix checksum calculation
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:58 +02:00
Karel Zak 7e5f8f3824 libblkid: move MBR partition types to include/
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:58 +02:00
Karel Zak 9fc1f5d809 fdisk: (sgi) cleanup devparams flags
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:58 +02:00
Karel Zak 1a9889ad7f fdisk: (sgi) cleanu sgi_info stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:57 +02:00
Karel Zak 5105f75f67 fdisk: (sgi) remove magic strings
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:57 +02:00
Karel Zak a78651d778 fdisk: (sgi) share disk label definition with libblkid
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:57 +02:00
Karel Zak 1c314b3183 libblkid: move SGI disklabel definitions to include/
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:57 +02:00
Karel Zak f234cc3b51 lib/tt: add TT_FL_FREEDATA
... to call free() for line data.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:53 +02:00
Karel Zak b34f097e75 agetty: add \S to output /etc/os-release data
This patch allows to use a new \S or \S{VARNAME} sequence in the
/etc/issue file. The sequence prints data from /etc/os-release.  The
reason is to keep /etc/issue file distribution and release
independent.

The \S{ANSI_COLOR} is converted to the real terminal escape seq.

For example:

   \S
   Kernel \r on an \m (\l)

or more complex example:

   Welcome to \S{ANSI_COLOR}\S{NAME}0m \S{VERSION}
   Report bugs at \S{BUG_REPORT_URL}.

See http://www.freedesktop.org/software/systemd/man/os-release.html
fr more details about /etc/issue.

Based on patch from Bill Nottingham <notting@redhat.com>.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-12 12:44:09 +02:00
Karel Zak db2a3dda74 lib: add crc64()
Based on bcache code from Rolf Fokkens.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-11 16:40:06 +02:00
Karel Zak 60f25deae7 lib: rename time-util.c to timeutils.c, fix headers
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-10 13:11:02 +02:00
Karel Zak 646e159aa9 lib/strutils: optimalize {starts,ends}with()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-10 12:18:20 +02:00
Sami Kerola 199e939d88 lib/strutils: move *swith() functions to private library
Avoid code dublication in libmount and time-util.

Proposed-by: Karel Zak <kzak@redhat.com>
Reference: http://markmail.org/message/h7zexvqsieqngtmx
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:08 +01:00
Sami Kerola 2659a49ef0 lib/time-util: copy time parsing functions from systemd
The functions are copied nearly as-is.  Coding style has been modified to
match with util-linux project, while the functionality remains untouched.

CC: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:08 +01:00
Sami Kerola ada6c48f06 include: carefulput: print determined char when unprintable char is found
This is done to allow reuse of the functin in last(1).

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23 10:58:48 +02:00
Karel Zak 3cb2413b02 losetup: use loop-control to explicitly ask for device
Now we use LOOP_CTL_GET_FREE ioctl to ask for free device, for example

  losetup -f foo.img

Unfortunately, losetup(8) allows to ask for specified device

  losetup /dev/loop100 foo.img

and in this case we assume that the device already exists in the
system. This is incorrect, we should be able to use loop-control
LOOP_CTL_ADD ioctl to ask for the specified device.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-06 11:04:35 +02:00
Karel Zak c9678832b1 include/xalloc: add warn_unused_result to allocation functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-09 10:44:06 +02:00
Karel Zak b8b8e76806 agetty: don't remove ECHOCTL from c_lflag
It's really unexpected that arrows keys move cursor when agetty/login
asks for login name or password.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=969458
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-06-03 14:06:18 +02:00
Ondrej Oprala fb2627cec4 lscpu: detect more hypervisor vendors
[kzak@redhat.com: - cleanup coding style,
                  - use path_exist()]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-20 16:30:23 +02:00
Karel Zak 507341f832 lib/tty: don't hardcode terminal fd in get_terminal_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-13 15:40:57 +02:00
Karel Zak b7faf99128 lib/colors: add colormode_or_err()
... to make the code easy to use in utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-07 09:09:35 +02:00
Karel Zak a10c043493 lib/colors: add support for auto, always and never modes
... to implement --color[=<when>]

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-06 19:07:23 +02:00
Sami Kerola f416563b28 include: add close_fd() for noticing write errors before close()
Essentially this helper function is similar to close_stream(), but for
file descriptors.

When a file descriptors are close()'d status of write is often
overlooked.  The close_fd() will try to determine what happen to writes
with fsync() before closing the file descriptor.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-26 13:26:06 +02:00
Karel Zak 6d791b4cc0 include: fix SYS_{unshare,nsenter} usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-17 16:58:00 +02:00
Karel Zak 09daba4069 libblkid: arch independent minix detection
It seems that on-disk MINIX FS superblock is native-endian.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=833841
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-15 15:14:33 +02:00
Karel Zak 2b88d3d72b lib/xalloc: add xstrndup()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-10 17:16:01 +02:00
Jeff Mahoney 293714c0d1 loopdev: sync capacity after setting it
I recently tried to mount an hfsplus file system from an image file with
a partition table by using the loop offset and sizelimit options to specify
the location of the file system.

hfsplus stores some metadata at a set offset from the end of the partition,
so it's sensitive to the device size reported by the kernel.

It worked with this:

But failed with this:

/dev/loop0: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000
/dev/loop1: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000

/proc/partitions shows the correct number of blocks to match the sizelimit.

But if I set a breakpoint in mount before the mount syscall, I could see:
102400000
102432768

The kernel loop driver will set the gendisk capacity of the device at
LOOP_SET_STATUS64 but won't sync it to the block device until one of two
conditions are met: All open file descriptors referring to the device are
closed (and it will sync when re-opened) or if the LOOP_SET_CAPACITY ioctl
is called to sync it. Since mount opens the device and passes it directly
to the mount syscall after LOOP_SET_STATUS64 without closing and reopening
it, the sizelimit argument is effectively ignroed. The capacity needs to
be synced immediately for it to work as expected.

This patch adds the LOOP_SET_CAPACITY call to loopctx_setup_device since
the device isn't yet released to the user, so it's safe to sync the capacity
immediately.

[kzak@redhat.com: - port to the current git HEAD,
                  - use uint64_t]

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-09 14:32:50 +02:00
Karel Zak 7e3729e750 include/fileutils: use O_CLOEXEC for mktemp stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-03 16:12:34 +02:00
Karel Zak 2ffad204c0 include/c: add macro UL_CLOEXECSTR
... to make "e" for fopen() portable to systems without O_CLOEXEC.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-03 16:11:19 +02:00
Karel Zak 8362545b4a lib/xalloc: fix mamory leak in xgethostname() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:08:47 +01:00
Karel Zak 7528fae9e9 include/pathnames: rename _PATH_ADJPATH to _PATH_ADJTIME
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-26 11:45:45 +01:00
Sami Kerola 2ba83ec2e0 docs: arch is gone, use delpart as usage() function example
The arch.c was removed in commit 27abd809.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-03-26 10:53:30 +01:00
Karel Zak 5ad0923904 remove duplicate includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-20 14:40:19 +01:00
Pádraig Brady 36c7f78524 lib/mbsalign: correct license header from GPLv[23] to LGPLv2+
* lib/mbsalign.c: s/GPLv3/LGPLv2+/
* include/mbsalign.h: s/GPLv2/LGPLv2+/
* README.licensing: Remove mention GPLv3 as it's not actually used.
2013-03-20 14:03:28 +01:00
Karel Zak 5aaee63cdf dmesg: more colors, more fun
* colorize subsystem prefix
 * colorize time
 * colorize by keywords (now "segfault" only)

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-18 12:28:32 +01:00
Josh Triplett b00456d2f0 namespace.h: Fix typo: s/CLONE_NEWSNS/CLONE_NEWNS/
This typo causes namespace.h to always unconditionally define
CLONE_NEWNS rather than using the system definition.

Bug present since the initial version of unshare in commit
4205f1fda1.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Anton Cherkashyn <mail@antonc.com>
2013-03-13 14:47:25 +01:00
Karel Zak 77fa36d7c6 include/timer: return setitimer return value
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13 14:07:23 +01:00
Karel Zak 2c7bcdf868 include/optutils: make collisions detection between options more robust
- don't rely on the correct ul_excl_t usage
 - don't print --(null) for non-existing long options

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13 13:04:02 +01:00
Karel Zak 01acff6e09 include: add timer.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13 12:13:11 +01:00
Karel Zak 477254da93 lib/strutils: add strtotimeval_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13 11:51:15 +01:00
Karel Zak 13377dd64a lib/procutils: add simple API to scan /proc/PID/*
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-12 17:24:14 +01:00
Karel Zak 9d3d9754e7 libblkid: rename in sun_disklabel for compatibility with fdisk
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:55 +01:00
Karel Zak ce337318fa inlude/pt-sun: add flags and tags
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:55 +01:00
Karel Zak a08dc0ca89 libblkid: move sun PT definition to include/
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:55 +01:00
Karel Zak 23106a29b0 lib/strutils: simplify strtosize(), return info about suffix
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:54 +01:00
Karel Zak 416c43a9a5 fdisk: add callback for ask-numbers API
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:54 +01:00
Bernhard Voelker 96f4747712 build-sys: add exec_shell.h to distribution
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2013-03-04 12:28:39 +01:00
Karel Zak d48f6c5db8 Merge branch 'patch-1' of https://github.com/dtrebbien/util-linux
* 'patch-1' of https://github.com/dtrebbien/util-linux:
  Implement mempcpy() in terms of memcpy() if mempcpy() is unavailable
2013-02-20 13:07:07 +01:00
Karel Zak 3785056ca8 lib/tty: don't truncate output on non-terminals
for example:

	$ findmnt | cat
	$ lslocks > foo

 the output should not be truncated.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-19 14:10:24 +01:00
Zbigniew Jędrzejewski-Szmek 5758069426 unshare,nsenter: spawn shell by default
The behaviour mimics chroot.

Possibly it would have been nicer to to query the password database in
the new namepace and run the shell of the user there, but it's hard to
do correctly. getpwuid() might need to load nss plugins, and the arch
in the new namespace might be different (in case of NEWNS mounts), or
the hostname might be different, etc. So in general it's not possible
to do it reliably.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2013-02-14 14:42:35 +01:00
Sami Kerola 4190e08e8d build-sys: add namespace.h to distribution
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06 12:03:04 +01:00
Karel Zak 59c68b4368 setpriv: move paths to pathnames.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-05 11:48:55 +01:00
Daniel Trebbien 02887b73eb Implement mempcpy() in terms of memcpy() if mempcpy() is unavailable 2013-01-30 18:53:00 -05:00
Sami Kerola a167328a74 nsenter: fix indentation
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 15:42:11 +01:00
Sami Kerola f5152f1aad include: add missing values to sysfs_cxt initializer definition
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-24 16:33:30 +01:00
Eric W. Biederman c91280a4bd unshare,nsenter: Move the old libc handling into a common header namespace.h
Move the defitions of CLONE_NEWNS, CLONE_NEWUTS, CLONE_NEWIPC,
CLONE_NEWNET, CLONE_NEWUSER, CLONE_NEWPID into namespace.h in case
sched.h does not provide those definitions.  Are there systems
around that are old enough that still need this?

Move the definitions of unshare() and setns() into namespace.h
for supporting old versions of libc that does not provice these.
I have tested this support with setns as I still have systems
old enough that glibc does not wrap setns.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2013-01-17 13:18:08 +01:00
Sami Kerola fb26bfaf6b build-sys: add files to distribution
To fix 'make distcheck' compilation.  The fdisks/Makemodule.am has one
new entry 'dos_part_types.h', the rest is about sorting the list.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-10 11:26:55 +01:00
Werner Fink f5664477cb include/ttyutils: add default chardata
this one moves the init_chardata to include/ttyutils.h as well as to
lib/include/ttyutils.c.  Also the macros CTL/CTRL are fixed in
agetty.c and sulogin.c to use the XOR variant CTL.

[kzak@redhat.com: use macro rather than global variable for default
                  chardata]

Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 15:42:12 +01:00
Karel Zak 0f23ee0c85 include: cleanup copyright headers
We use the code from include/ and lib/ on many places, so use public
domain if possible or LGPL for code copied from libs.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 15:10:17 +01:00
Karel Zak 1a1eb4e188 include/bitopts: Use the operating system byteswapping functions
The swap macros are already in libc.

Co-Author: Cristian Rodríguez <crrodriguez@opensuse.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 14:07:48 +01:00
Karel Zak f35336526f build-sys: remove consoles.h
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-27 17:37:27 +01:00
Karel Zak a73f59fa03 sulogin: remove consoles.c from libcommon
- move struct chardata to include/ttyutils.h
- move console.{h,c} to login-utils/sulogin-* (it's sulogin specific)
- fix sulogin and agetty includes

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-23 22:14:21 +01:00
Werner Fink b33f24b250 sulogin: make usleep() workaround work
Simply fix a compile problem found during debugging console.c

Signed-off-by: Werner Fink <werner@suse.de>
2012-12-18 15:07:58 +01:00
Werner Fink cae29b3717 sulogin: use the linked lists from list.h for consoles list
with this the double linked list feature from util-linux is used
instead of the single linked list.

[kzak@redhat.com: use list_last_entry() and list INIT macros]

Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-18 15:02:35 +01:00
Karel Zak 59da1544ce include/list: add list_last_entry()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-18 15:00:03 +01:00
Sami Liedes becd09500f include/list: fix undefined behavior in list_entry() macro
Update list_entry() macro, which is basically the same as the
container_of() macro in the kernel, to use offsetof() to fix undefined
behavior.

Caught using clang -fsanitize=undefined.

[kzak@redhat.com: port from e2fsprogs]

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-17 16:23:35 +01:00
Karel Zak 33c5fd0c5a lib/canonicalize: add canonicalize_path_restricted() to canonicalize without suid permisssions
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-26 16:24:28 +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 37a5c7ee41 lib/path: add path_read_u64()
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
Sami Kerola d2b5c8c4fb ipcs: add /proc and /sys path definitions
The necessary proc and sysfs files are tested to be present.  When
information files are missing the ipcs will use obsolted system calls,
and data structures, as fallback.

[kzak@redhat.com: - fix #define _PATH_PROC_IPC_MSG "/proc/sys/kernel/sem" typo]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:47:14 +01:00
Karel Zak 1ef28920f8 lib/ttyutils: add get_terminal_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 14:40:14 +01:00
Karel Zak 4e76adb0e1 lib/ttyutils: create .c file
Well, now all tty stuff are incline functions in include/ttyutils.h.
It's seems more elegant to create regular lib/ttyutils.c for libcommon
and write test program.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 14:26:41 +01:00
Karel Zak cf987d0aa7 lib/consoles: remove global variable consoles
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 10:06:23 +01:00
Werner Fink 3a08f74f1d lib/consoles: add code to detect all system consoles
Signed-off-by: Werner Fink <werner@suse.de>
2012-11-08 15:55:48 +01:00
Karel Zak f308ec19a7 libmount: add private mnt_get_kernel_cmdline_option()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-08 11:59:36 +01:00
Karel Zak e21e6d265d build-sys: cleanup cpu_set_t usage
- make taskset depend on cpu_set_t
 - make cpuset.c optional for libcommon and lib/path.c

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-02 12:07:36 +01:00
Karel Zak a5dc4d2d95 lib/sysfs: add SCSI link functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:21:23 +02:00
Karel Zak 23a11c74a6 lib/sysfs: add functions for SCSI host attributes
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:18:57 +02:00
Karel Zak d0f7e5b4a0 include/sysfs: add SCSI host:channel:target:lun support
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:15:58 +02:00
Karel Zak 2a31396a9c include/c: move usleep() fallback to c.h
To make it available everywhere in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-22 11:03:09 +02:00
Karel Zak 4ca5163aa4 include/c: remove MAXHOSTNAMELEN macro
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 16:58:11 +02:00
Karel Zak 1b2aa6293d include/xalloc: add xgethostname()
The new function allocates memory by xalloc() for hostname and
fill in the buffer by gethostname().

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 16:23:54 +02:00
Sami Kerola e0b6ab5687 include/env: unify indentation
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 15:07:44 +02:00
Sami Kerola 1ee4dff724 include/c: add get_hostname_max() inline function
Using sysconf(_SC_HOST_NAME_MAX) does not work everywhere.  At such even
header values for hostname length should be preferred, and if nothing
else works guess the maxium being 64 bytes.

Based-on-code-by: Karel Zak <kzak@redhat.com>
CC: Mike Frysinger <vapier@gentoo.org>
References: http://www.spinics.net/lists/util-linux-ng/msg07050.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 14:50:27 +02:00
Ondrej Oprala dfa68ad183 lib/color: add module for work with terminal colors
[kzak@redhat.com: - split from dmesg patch
                  - add more colors]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-16 16:39:00 +02:00
Ludwig Nussel 5cf05c7147 mount: losetup: remove obsolete encryption support
kernel cryptoloop is deprecated since ages and support for cryptoloop
in util-linux is incomplete/broken.
- no password hashing
- last 8 bit of key are always set to zero
- no binary keys possible (stops reading key at \n and \0)

In the past some Distros added the above features with patches. So
remove cryptoloop support from util-linux completely to make sure
people won't try using it.

Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-11 10:46:11 +02:00
Karel Zak 778ad369f6 lib/sysfs; add sysfs_partno_to_devno()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-13 22:06:18 +02:00
Milan Broz f5077b5180 lib/strutils: add string_add_to_idarray() - parse and add to id list
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 16:26:27 +02:00
Sami Kerola d0aa8a446d include: define format to be constant in xasprintf()
Add also format function attribute to add robustness.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:24 +02:00
Karel Zak f69b4c5b62 include/optutils: remove unnecessary exclusive_option()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:27:42 +02:00
Karel Zak 217d20a73c include/optutils: add err_exclusive_options()
This is improved implementation of exclusive_option(). The new
implementation:

  - uses regular struct option to compose error messages
  - relationships between options are described in one const static array
  - the current status is stored in one int array

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:22:35 +02:00
Karel Zak 9199f5cd0a dmesg: add fileback for SEEK_DATA
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-24 14:06:25 +02:00
Sami Kerola 01c5b78794 agetty: use configured run state directory
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-10 13:00:20 +02:00
Karel Zak 8d398470c0 build-sys: add pager.h to Makemodule.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:57:45 +02:00
Karel Zak 8365ed42ac build-sys: convert include/ to module
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 17:08:57 +02:00
Karel Zak defa0710b6 lib/loopdev: use warn_unused_result forimportant functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21 10:40:43 +02:00
Karel Zak 1aae31c048 lib/sysfs: use warn_unused_result for sysfs_init()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21 08:28:49 +02:00
Sami Kerola 8f77d454a9 include [optutils]: add exclusive_option() inline function
The exclusive_option() will unify how exclusive options are
determined.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:58 +02:00
Karel Zak 2fc4a256ce lib/blkdev: return static strings by blkdev_scsi_type_to_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 13:14:30 +02:00
Karel Zak aa323539cf include/blkdev: cleanup up
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 13:01:51 +02:00
Karel Zak d5f9b6e5fb Merge branch '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit
* '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit:
  lsblk: use blkdev_scsi_type_to_name()
  blkdev: add blkdev_scsi_type_to_name()
  wipefs: use symbolic value for markup mode
  eject: inform if CD-ROM drive is not ready
  docs: clean up partx.8 manual
  include: fix void pointer arithmetics warnings
  sysfs: fix printf format warnings
  build: fix unused parameter warnings
  build: fix redundant redeclaration warnings
  include: fix spurious list.h warnings
  uuidd: use output redirection which works [checkbashisms]
  blkid: fix realloc memory leak [cppcheck]
  setarch: do not use -1 as array index [cppcheck]
2012-06-15 12:44:17 +02:00
Karel Zak e4062c72d1 losetup: improve -a to report loopdevs < 512 bytes
# ll ~/xxx2
  -rw-r--r-- 1 root root 500 Jun 12 14:30 /root/xxx2

 old version:
  # losetup -a

 new version:
  # losetup -a
  /dev/loop0: [2052]:535312 (/root/xxx2)

The new version scans /sys/block/loopN, kernel >= 2.6.37 is required
otherwise fallback to the original not-so-smart /proc/partitions scan.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=730266
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-12 15:41:47 +02:00
Sami Kerola ba32a9465a blkdev: add blkdev_scsi_type_to_name()
Add a function, and necessary symbols, to convert scsi type id's
to name strings.

Reference: http://permalink.gmane.org/gmane.linux.utilities.util-linux-ng/5994
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 22:06:06 +02:00
Sami Kerola 667d375ea8 include: fix void pointer arithmetics warnings
all-io.h:18:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]
all-io.h:38:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Sami Kerola c42206e4a7 include: fix spurious list.h warnings
include/list.h:224:17: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]
include/list.h:255:19: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]

Compilation warned about that at least 110 times.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Karel Zak abb53be5cb Merge branch '2012wk22' of git://github.com/kerolasa/lelux-utiliteetit
* '2012wk22' of git://github.com/kerolasa/lelux-utiliteetit:
  docs: clean up getopt.1 manual
  docs: clean up dmesg.1 manual
  docs: clean up chcpu.8 manual
  fileutils: xmkstemp() interface change
  docs: fix all man page groff warnings
  tools: add checkmans.sh
  docs: clean up wdctl.8 manual
  docs: clean up login.1 manual
  login: allow TTYGROUP name begin by number
  build-sys: add su executable to .gitignore
  logindefs: change getlogindefs_num() to return unsigned long

Conflicts:
	login-utils/su.c
	sys-utils/dmesg.1
2012-06-05 16:57:01 +02:00
Karel Zak 90af3fe39b inclide/env: innclude c.h, remove _() macro from xsetenv()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-05 15:44:12 +02:00
Ludwig Nussel e557efdedd su: introduce xsetenv globally
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
2012-06-05 15:16:18 +02:00
maximilian attems ab65d635c8 lib/strutils: circumvent missing localeconv()
Add stub too nls.h, include it instead of locale.h.
Code in strutils handles already returned NULL.

Signed-off-by: maximilian attems <max@stro.at>
2012-06-05 14:54:12 +02:00
Dave Reisner 3c4fed097d fileutils: xmkstemp() interface change
We can not let the user control where TMPDIR is for this tempfile.
This will be where we write the updated passwd file, and must be
capable of being moved atomically with rename(2).  Therefore, it
cannot be on a different device, or setpwnam() and vipw/vigr programs
will invariably fail with EXDEV.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-02 20:29:12 +02:00
Karel Zak 3a9c3f3fb7 include/c: move fallback for MAXHOSTNAMELEN to c.h
Reported-by: Thomas Schwinge <thomas@codesourcery.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-29 10:08:25 +02:00
maximilian attems ae278c88cf include: [c.h] protect container_of
fixes lots of warning noise:
../../../include/c.h:112:0: warning: "container_of" redefined [enabled
by default]
/usr/lib/klibc/include/stddef.h:52:0: note: this is the location of the
previous definition

Signed-off-by: maximilian attems <max@stro.at>
2012-05-23 10:31:07 +02:00
Karel Zak b776c15e8a lib/tt: export tt_fputs_{quoted,nonblank} function
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-22 13:27:46 +02:00
Karel Zak 551dae405a lib/strutils: create type specific strtoxx_or_err()
We need [un]signed int ([u]int32_t) on many places. It's also more
readable and robust to use uintXX_t types than for example "long long".

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:40:03 +02:00
Karel Zak 7e9a9af14f include/ttyutils: more robust get_terminal_width()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 11:58:20 +02:00
Petr Uzel e872e32064 include: move get_terminal_width() to ttyutils.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:53 +02:00
Petr Uzel f80e9bc30a libuuid: move read_all to include/all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:36 +02:00
Petr Uzel e12c9866b5 include: rename writeall.h to all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:27 +02:00
Petr Uzel c544aa2c25 libuuid: avoid double open and leaking fd (reworked)
This reverts commit 6126f7a53c
and fixes the double open and leaking descriptor in a different way,
that is by using newly introduced function 'have_random_source()'
to check whether good random source is available while deciding
which uuid type to generate (random/time).

This is better than calling random_get_fd() twice, passing the file
descriptor down the stack and reusing it in next call to
random_get_fd().

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-10 11:43:49 +02:00
Petr Uzel 6126f7a53c libuuid: avoid double open and leaking descriptor
We are opening /dev/urandom twice in uuid_generate(): first to check if
the file is available and then later __uuid_generate_random() again to
actually get the random data. Moreover, descriptor from the first open
is leaking.

Fix by passign the descriptor down the stack and reusing it there.

References: http://marc.info/?l=util-linux-ng&m=133406051131131&w=2

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:24 +02:00
Karel Zak 5ef167714e lib/strutils: add string_to_bitmask()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 17:28:44 +02:00
Karel Zak 4a695b1a8b include/tt: remove obsolete stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 15:25:23 +02:00
Sami Kerola 33a0de92e9 wdctl: align with other util-linux commands
* Add watchdog device path to pathnames.h
* Check output stream status at exit.
* Adjust usage() notation to follow howto file.
* Retire numeric return value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-03 15:00:07 +02:00
Karel Zak 1f13d6fcd0 Merge branch '2012wk17' of https://github.com/kerolasa/lelux-utiliteetit
* '2012wk17' of https://github.com/kerolasa/lelux-utiliteetit:
  build-sys: determine availability of __fpending()
2012-05-02 09:34:39 +02:00
Petr Uzel 7f64f9bde7 build-sys: add ttyutils.h to dist
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-04-27 12:30:37 +02:00
Petr Uzel 95c46edd67 build-sys: add randutils.h to dist
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-04-27 12:30:34 +02:00
Karel Zak 95387b6696 lib/mangle: cleanup, add unhexmangle
* use strchr() rather than for()
 * small refactoring in mangle code
 * add un-hex-mangle

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-26 09:17:44 +02:00
Sami Kerola 78288764e4 build-sys: determine availability of __fpending()
Needed to for making Cygwin more possible.

Reference: http://comments.gmane.org/gmane.linux.utilities.util-linux-ng/5656
Reported-by: Bernhard Voelker <bernhard.voelker@siemens-enterprise.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-23 14:26:23 +02:00
Karel Zak be92327e71 lib/fileutils: add get_fd_tabsize()
as a fallback for the function getdtablesize()

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-23 13:58:39 +02:00
Davidlohr Bueso 35717a57ac lib: add pager functionality
When some program' output exceeds the terminal's dimensions, it is a nice
feature to call a pager that acts as calling 'less' to allow better user
navigation. This patch adds this functionality, based on what perf and git
have (ie: git log).

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 11:52:39 +02:00
Karel Zak fc387ee14c libblkid: add support for PARTUUID= and PARTLABEL=
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:33:49 +02:00
Karel Zak 6259c257d8 Merge branch 'close_stream' of git://github.com/kerolasa/lelux-utiliteetit
* 'close_stream' of git://github.com/kerolasa/lelux-utiliteetit:
  disk-utils: verify writing to streams was successful
  fdisk: verify writing to streams was successful
  getopt: verify writing to streams was successful
  hwclock: verify writing to streams was successful
  login-utils: verify writing to streams was successful
  misc-utils: verify writing to streams was successful
  mount: verify writing to streams was successful
  partx: verify writing to streams was successful
  schedutils: verify writing to streams was successful
  sys-utils: verify writing to streams was successful
  term-utils: verify writing to streams was successful
  text-utils: verify writing to streams was successful
  include: add stream error checking facility

Conflicts:
	fdisk/fdisk.c
2012-04-11 12:37:59 +02:00
Davidlohr Bueso fe72459e41 lib: random utilities
Add a random number(s) generator specific file. The intial functions are based
on what libuuid provide. I did some modifications like avoid WIN32 checks - this
is util-LINUX.

[kzak@redhat.com: - move jrand_seed to lib/randutils.c
                  - use TLS for jrand_seed (like original code from libuuid)
                  - use size_t for buffer sizes
                  - add close() to random_get_bytes]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-10 13:12:43 +02:00
Davidlohr Bueso 64128b705c fdisk: move kernel geometry into blkdev
This is a more generic place for this ioctl.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-10 12:21:16 +02:00
Karel Zak 4f469e588d Merge branch 'eject'
* eject: (47 commits)
  tests: use eject --force
  eject: use BUILD_EJECT, move to sys-utils
  eject: clean up usage()
  eject: clean up man page
  eject: add --force option
  eject: check for hotplug/removable attribute
  eject: remove obsolete code, use EXIT_* macros
  tests: add umount-by-eject tests
  eject: improve work with partitioned devices
  lib/sysfs: improve sysfs_is_partition_dirent()
  eject: call umount <mountpoint> rather than <device>
  eject: use libmount to detect if cdrom is mounted
  eject: make the code robust
  eject: use SG_IO ioctl for scsi
  eject: support CDIOCEJECT ioctl
  eject: new close_tray code from Fedora
  eject: new auto_eject code from Fedora
  eject: add -X from Fedora
  eject: add --manualeject from fedora
  eject: clean up devname usage
  ...
2012-04-05 15:58:28 +02:00
Sami Kerola 302e423dc1 include: add stream error checking facility
The close_stream() is copied from GNU lib.  Inspiration to do this is
talk by Jim Meyering - Goodbye World! The perils of relying on output
streams in C.

Reference: http://www.irill.org/events/ghm-gnu-hackers-meeting/videos/jim-meyering-goodbye-world-the-perils-of-relying-on-output-streams-in-c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:45:37 +02:00
Karel Zak 6219c25ecb lib/loopdev: more robust initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-02 17:33:41 +02:00
Sami Kerola 16d8a9c967 raw: use pathnames.h for file locations
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-30 16:48:12 +02:00
Karel Zak a99c913091 lib/strutils: add strtosize_or_err, clean up
* add strtosize_or_err(), we use strtosize() + err() on many places

 * add STRTOXX_EXIT_CODE to overwrite the default EXIT_FAILURE

 * remove else-after-noreturn (e.g. if (foo) err(...); else err(...))

 * clean up indent...

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-30 16:11:31 +02:00
Karel Zak 1abc33266f eject: add -X from Fedora
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-27 17:38:28 +02:00
Michal Luscon 3b66f48e23 sysfs: move blkid_devno_to_wholedisk to sysfs_devno_to_wholedisk
Signed-off-by: Michal Luscon <mluscon@redhat.com>
2012-03-27 13:16:19 +02:00
Karel Zak a36e9a9408 build-sys: move obsolete lib/fsprobe to mount/
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-27 12:23:07 +02:00
Karel Zak 70b604b827 include/exitcodes: clean up names, add _EX_ suffix
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-20 11:22:08 +01:00
Karel Zak e50ad21838 include/exitcodes: add FSCK_DESTRUCT alias
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-20 11:22:08 +01:00
Dave Reisner 0b6198ec07 include/ttyutils.h: add include guards
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-20 09:53:48 +01:00
Sami Kerola 7961acce46 fileutils: differentiate xmkstemp and xfmkstemp
Let developer to choose, case by case, what sort of return value is
best in her code.  The xmkstemp() is for users who want file
descriptor as return value of the function, xfmkstemp() will return
FILE pointer.

Proposed-By: Karel Zak <kzak@redhat.com>
CC: Davidlohr Bueso <dave@gnu.org>
Reference: http://marc.info/?l=util-linux-ng&m=133129570124003&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:29:38 +01:00
Sami Kerola eeb31db9b9 include: add asprintf wrapper
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:05 +01:00
Sami Kerola 6a91958bf8 pathnames: clean up various user database paths
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:05 +01:00
Sami Kerola 6b79eb38ba lib: add fileutils function collection
The fileutils contains xmkstemp function will create temporary file
safe and reusable manner.

Reference: http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO.html#TEMPORARY-FILES
CC: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:04 +01:00
Sami Kerola c900336d8b chsh: use pathnames.h for paths
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:04 +01:00
Karel Zak 879a7ab470 agetty: move vc initialization to ttyutils.h
... to make the code usable for sulogin.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-12 14:39:32 +01:00
Karel Zak 7293e97a42 libmount: fix "already mounted" detection on systems with mtab
For systems with regular mtab the fs->root should be ignored in
"already mounted" heuristic.

Reported-by: Matt Burgess <matthew@linuxfromscratch.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-09 13:11:24 +01:00
Karel Zak 4c5bbc5d7e libblkid: fix sysfs context usage
Reported-by: Elan Ruusamäe <glen@delfi.ee>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-06 11:24:54 +01:00
Davidlohr Bueso 79b1280725 include: add /proc/locks path to pathnames
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-29 12:27:41 +01:00
Sami Kerola f06b43285d build-sys: enhance readability of the autotools files
Several horizontal lists are turned to vertical, and sorted to
alphabetical order. Additionally spaces are converted to tabs where
ever possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-28 13:29:35 +01:00
Karel Zak bb4f071520 lib/fsprobe: mar this internal API as deprecated
The fsprobe has been added many years ago to provide unified API for

	- built-in libblkid
	- e2fsprogs libblkid
	- udev libvolume_id

these all is unnecessary as we strictly depends on built-in libblkid.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-13 15:10:55 +01:00
Karel Zak 497d2ce7ea mount: (new) share exit codes by include/exitcodes.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-23 10:55:35 +01:00
Karel Zak aa1f95c3d0 losetup: make xgetpass more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-17 17:02:34 +01:00
Karel Zak 6c503d5916 losetup: move xgetpass() to lib/xgetpass.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-11 15:17:06 +01:00
Karel Zak 916bf85e62 losetup: add --partscan option
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-09 23:28:50 +01:00
Karel Zak 59d749c331 loopdev: support LO_FLAGS_PARTSCAN flag (kernel 3.2)
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-09 23:28:43 +01:00
Davidlohr Bueso 8150beac7c blkdev: add is_blkdev function
We should have the most basic of checks in this library to see whether or not a block device is being used.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-01-05 17:09:27 +01:00
Davidlohr Bueso 3b622ddd72 fdisk: use CDROM_GET_CAPABILITY ioctl
And replace the current archaic logic of is_ide_cdrom_or_tape().

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-01-02 13:43:06 +01:00
Karel Zak c7e0925def losetup: rewrite loop setup
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak 6c224de18b lib,loopdev: add missing functions
- improve loop_info usage (don't call ioctl more than once)
 - add functions to get devno and inode of the backing file
 - add function for compare any file with backing file by devno + inode
   or by filename

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Davidlohr Bueso 5b9df0280a lists: add list sorting routine
We need a list sorting function, just to mention one example user that could
benefit is the lib/tt code to sort columns.

This patch adds list_sort() which uses the Merge Sort algorithm, behaving
nicely in O(nlog(n)), heavily based on the kernel's implementation[1].  The
private data (void *priv) passed to the comparison function as been removed to
adopt a qsort(3)-like syntax, and IMHO we don't really need it anyways.

[1]: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=lib/list_sort.c;h=d7325c6b103f0be078ff3672c35c468ed35738f1;hb=HEAD

[kzak@redhat.com: - use size_t in list_sort()]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-16 12:37:07 +01:00
Sami Kerola fbc333fec0 build-sys: check HAVE_ definitions with #ifdef [smatch scan]
Fix to `warning: undefined preprocessor identifier' messages.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-02 18:21:46 +01:00
Sami Kerola 8a3f94862c build-sys: add missing headers to dist
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-02 18:21:42 +01:00
Karel Zak 914c8b7102 Merge branch 'login-utils' of https://github.com/kerolasa/lelux-utiliteetit
* 'login-utils' of https://github.com/kerolasa/lelux-utiliteetit: (23 commits)
  last: fix few compiler warnings
  setpwnam: remove non-ANSI definitions [smatch scan]
  last: possible buffer overflow fixed [smatch scan]
  vipw: fix coding style
  setpwnam: fix coding style
  selinux_utils: fix coding style
  newgrp: fix coding style
  logindefs: fix coding style
  islocal: fix coding style
  chsh: fix coding style
  chfn: fix coding style
  chfn, setpwnam: let config.h be in control of extensions in use
  chfn, chsh: new file pamfail.h for error printing
  chsh: build bug: do not override config.h definition
  chfn, chsh, setpwnam: get true/false from stdbool.h
  login: add version printing option
  newgrp: add version and help options
  vipw: stop printing non-sense version string
  vipw: use libc error printing facilities
  chsh: use libc error printing facilities
  ...
2011-11-29 19:02:42 +01:00
Karel Zak 732a631126 include,optutils: add option_to_longopt()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-29 18:21:49 +01:00
Sami Kerola 57b35f3ba7 chfn, chsh: new file pamfail.h for error printing
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-29 17:57:39 +01:00
Karel Zak 1208915521 lib,match: split match_fstype() from libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-15 15:17:19 +01:00
Karel Zak 7aa69cf2e3 lib,tt: add TT_FL_NOEXTREMES
If you mark a column with TT_FL_NOEXTREMES flag then extremely
large fields will no have effect to column width. Foe example:

 without the TT_FL_NOEXTREMES flag for the 'AAA' column:

	 AAA         BBB CCC  DDD
	 aa          bbb ccc  ddd
	 aaaaaaaaaaa  bb ccc  ddd
	 aa           bb ccc  ddd
	 aa           bb ccc  ddd

 with the flags:

	 AAA  BBB CCC  DDD
	 aa   bbb ccc  dddddddddd
	 aaaaaaaaaaa
	       bb ccc  dddddddd
	 aa    bb ccc  dddddd
	 aa    bb ccc  ddddddddd

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-10 12:39:02 +01:00
Petr Uzel b106d05238 libmount: ignore tailing slash in netfs source paths
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=728480
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-08 16:25:01 +01:00
Karel Zak 0b14bf7af1 lib,loopdev: add LOOP_CTL_GET_FREE support
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-07 16:45:11 +01:00
Karel Zak c82d9c977c login: add login.defs code and tests
The new logindefs.c file contains /etc/login.defs parser and functions
for searching in the list of the login default variables. The patch
also contains a new regression test for the code.

Based on pam_login-4.0 from Suse.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-26 23:17:17 +02:00
Karel Zak 918b1a9ddd login: improve hushed mode (merge suse changes)
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-26 23:17:16 +02:00
Karel Zak 52b7b4876c lib: cleanup setproctitle.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-26 23:17:15 +02:00
Karel Zak 5d1a454ac9 login: move _PATH_BTMP to pathnames.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-26 23:17:15 +02:00
Davidlohr Bueso af7df9ee67 lib,strutils: add default value to parse_range()
This function currently sets the low or high values to 0 when the string doesn't
contain a value, like '123:' or ':123'. In order to make it more flexible, we allow it
to be passed an arbitrary value.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-10-17 11:06:48 +02:00
Davidlohr Bueso a883c6349c lib,strutils: share parse_range()
This function is currently only being used by partx(8), but it's handy and
generic enough that we can use it elsewhere as well.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-10-12 10:01:26 +02:00
Dave Reisner c8ea35145e include/loopdev.h: add missing function prototype
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-12 10:01:09 +02:00
Karel Zak 640fc1b819 build-sys: check scanf %ms modifier
Without the check libmount builds on systems that has older than 2.7
glibc are silently unsuccessful.  The missing %ms modifier will, at
least, result on such system missing output of findmnt and lsblk
commands.  If either %ms or %as modifiers are present the libmount
build is disabled.

Based on patch from: Sami Kerola <kerolasa@iki.fi>

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-10 14:42:40 +02:00
Sami Kerola bfda68fdb1 build-sys: rename BUILD_BUG_ON_ZERO definition
Definition name is changed to UL_BUILD_BUG_ON_ZERO to avoid collision
with a system header.

../include/c.h:72:1: warning: "BUILD_BUG_ON_ZERO" redefined
In file included from /usr/include/sys/sysinfo.h:25,
                 from dmesg.c:16:
/usr/include/linux/kernel.h:34:1: warning: this is the location of the previous definition

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-10-10 13:57:16 +02:00
Karel Zak ffbe3270f1 Merge branch 'sys-utils-again' of https://github.com/kerolasa/lelux-utiliteetit
* 'sys-utils-again' of https://github.com/kerolasa/lelux-utiliteetit:
  cytune: fix printf type warning
  docs: mention long options in cytune.8
  cytune: coding style fixes
  cytune: refactor main(), new function query_tty_stats()
  cytune: use libc error printing facilities
  cytune: check numeric user inputs
  cytune: add long options and usage()
  docs: restructure flock.1 manual page
  flock: simplify strtotimeval()
  lib: [strutils] add strtod_or_err() function
  flock: use strutils.h to check numeric user input
  flock: use sysexit.h for all exit values
  flock: use function attributes
  flock: align with howto-usage-function.txt
  flock: use libc error printing facilities
  flock: move long_options struct to function scope
  flock: fix coding style
  docs: align fallocate.1 with howto-man-page.txt
2011-10-03 15:40:15 +02:00
Karel Zak d568813071 umount: use new lib/loopdev.c code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-30 11:09:38 +02:00
Dave Reisner 12218ccde2 include,xalloc: fix whitespace to be consistent
We use spaces for the rest of this file, so the random tabs within
xstrdup stand out.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-30 00:24:16 +02:00
Dave Reisner 8ddb6b0cae include,xalloc: check for NULL before calling strdup
This fixes a segfault in mount (and possibly elsewhere) when invoked
without a -t parameter.

Broken in 7ef9fd7 when the common xalloc.h libs were introduced.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-30 00:24:05 +02:00
Karel Zak aee31ddc59 lib,loopdev: add debugu messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-29 23:28:36 +02:00
Sami Kerola a9f97001c3 lib: [strutils] add strtod_or_err() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:45:27 +02:00
Petr Uzel 960cf5737e misc: use %m in format string instead of %s and strerror(errno)
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:46:07 +02:00
Karel Zak 716e6f5c9a build-sys: add path.h to Makefile.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 14:59:57 +02:00
Heiko Carstens 9bc2b4b185 chcpu: convert to use lib/path.c
Use the common path access functions. In order to simplify chcpu also implement
and use path_writestr() which writes a string to the path specified.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 13:36:54 +02:00
Heiko Carstens 8148217b5b lib,path: move path access functions from lscpu into lib/path.c
A couple of these functions already have been copied to chcpu.c,
so it makes sense to move these functions into an own file.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 13:36:41 +02:00
Karel Zak 9fc7bf00ad Merge branch 'sys-utils' of https://github.com/kerolasa/lelux-utiliteetit
* 'sys-utils' of https://github.com/kerolasa/lelux-utiliteetit: (29 commits)
  docs: add non-return function and if shorthand tips
  build-sys: fixes to USAGE_* macros
  ipcrm: check IPC syscalls
  ipcrm: add --verbose option
  ipcmk: allow high speed ipc creation
  ipcrm: add --all option
  docs: add long options to ipcs.1 man page
  docs: add long options to ipcrm.1 man page
  docs: add long options to ipcmk.1 man page
  docs: add --version to setarch.8
  docs: mention long options in ctrlaltdel.8
  ctrlaltdel: add version & help options
  docs: mention long options in pivot_root.8
  pivot_root: add version & help option
  ipcs: comment & white space clean up
  ipcs: include-what-you-use header check
  ipcs: add long options
  ipcrm: include-what-you-use header check
  ipcrm: refactor new and old main to share code
  ipcrm: exit if unknown error occurs
  ...
2011-09-27 12:56:48 +02:00
Sami Kerola 6f162034d0 build-sys: fixes to USAGE_* macros
The USAGE_BEGIN_TAIL is removed as unnecessary.

In between command specific options and --help & --version
USAGE_SEPARATOR is inserted. For now the separator is empty line.

The USAGE_MAN_TAIL is changed to take an argument.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 15:07:52 +02:00
Karel Zak e9d00e66fb include,c.h: include fcntl.h before check for O_CLOEXEC [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 13:53:10 +02:00
Karel Zak e9d659ea85 lscpu: use function to search in cpu masks arrays
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-09 23:27:40 +02:00
Karel Zak b82c15bd19 Merge branch 'chcpu' of git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux
* 'chcpu' of git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux:
  chcpu: new tool
  cpuset: add option to allow cpulist_parse() to fail
2011-08-31 11:49:27 +02:00
Sami Kerola cd7accd446 arch: start using arch as a usage() example
The arch command is hijacked to be example of howto write usage
as defined in Documentation/howto-usage-function.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-08-28 10:50:36 +02:00
Heiko Carstens b16f615afb cpuset: add option to allow cpulist_parse() to fail
This is a preparation patch for chcpu. If a cpu should be added to
a cpu_set where the cpu doesn't fit into the cpu_set this got silently
ignored.
Since the cpu-list is user space provided it should be checked if cpus
are specified that are completely out of range of the system.
In order to do that add a parameter which specifies if cpulist_parse()
should fail if it parses a cpu-list with "impossible" cpus.
The current callers have been converted so they behave like before.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-15 07:52:44 +02:00
Benno Schulenberg 27cc25474f include: [nls.h] define a macro for handling plurals with ngettext()
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-02 14:13:44 +02:00
maximilian attems 4d49851351 include: [c.h] Include stdlib.h unconditionaly
No point in hiding it down in an ifdef maze,
as it may get used by exit(3).

Signed-off-by: maximilian attems <max@stro.at>
2011-08-02 13:58:46 +02:00
maximilian attems 4b2b671697 include: [c.h] move up declaration of program_invocation_short_name before usage
fixes:
../include/c.h: In function ‘errmsg’:
../include/c.h:111:26: error: ‘program_invocation_short_name’ undeclared
(first use in this function)
../include/c.h:111:26: note: each undeclared identifier is reported only
once for each function it appears in

Signed-off-by: maximilian attems <max@stro.at>
2011-08-02 13:58:24 +02:00
Karel Zak 330f543985 include: [writeall] add fwrite_all()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-02 13:53:41 +02:00
Karel Zak d1425592a2 include: [bitops.h] make return values consistent
The *_to_cpu() and cpu_to_*() macros have to return always the same date types
independently on CPU type.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-02 12:33:10 +02:00
Karel Zak 3922ef8025 lib: [tt.c] clean up used types
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 12:16:00 +02:00
Karel Zak 9feec79cc5 misc: use unsigned int for bit-fileds
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-29 10:51:06 +02:00
Karel Zak ce75b60528 build-sys: fix 'make checkincludes' warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-28 13:21:00 +02:00
Karel Zak c87638ad30 include: [strutils.c] add list parsers
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27 16:41:21 +02:00
Karel Zak bdc3ed6678 include; [tt.c] check for array size in columns parser
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27 16:21:11 +02:00
Karel Zak a4863bdf6e Merge branch 'hwclock' of https://github.com/kerolasa/lelux-utiliteetit 2011-07-27 09:56:39 +02:00
Sami Kerola 9d413ecb6e hwclock: move path definitions to pathnames.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-26 17:54:43 +02:00
Karel Zak 9ae45d23de Merge branch 'cramfs' of https://github.com/kerolasa/lelux-utiliteetit
* 'cramfs' of https://github.com/kerolasa/lelux-utiliteetit:
  include: move fsck return values to exitcodes.h
  include: move disk-utils/mkfs.h -> include/exitcodes.h
  mkfs.cramfs: coding style
  mkfs.cramfs: include-what-you-use header check
  mkfs.cramfs: error printing fixes
  mkfs.cramfs: convert spaces to tabs
  mkfs.cramfs: validate numeric user inputs
  mkfs.cramfs: few symbolic exit codes where missing
  md5: use symbolical digest length
  mkfs.cramfs: use program_invocation_short_name
  mkfs.cramfs: use xalloc.h
  fsck.cramfs: add missed strings to translation
  fsck.cramfs: coding style
  fsck.cramfs: use xalloc.h
  fsck.cramfs: retire die function
  cramfs.h: coding style
  cramfs: use stdint.h instead of u{8,16,32}
  cramfs_common: coding style

Conflicts:
	disk-utils/Makefile.am

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-26 14:41:28 +02:00
Sami Kerola 5d6fb944bf include: move fsck return values to exitcodes.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-22 00:34:12 +02:00
Sami Kerola b8f040cdd4 include: move disk-utils/mkfs.h -> include/exitcodes.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-22 00:30:04 +02:00
Sami Kerola e429d14106 md5: use symbolical digest length
Magic hash lenght number 16 is turned to a definition MD5LENGTH,
and put into use everywhere where md5 checksum is in use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-21 23:56:48 +02:00
Karel Zak c1d26b1981 minix: add MINIX_ prefix to some global macros
... and remove some tailing whitespaces.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 12:23:01 +02:00
Karel Zak 058cda4c1d minix: cleanup global variables and macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 12:13:33 +02:00
Sami Kerola e9ab36a73a libblkid: move MINIX_MAXPARTITIONS to minix.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-20 20:43:40 +02:00
Sami Kerola 7cc112d927 minix: move globals and inline functions to minix_programs.h
Global variables and inline functions are moved from minix.h to
minix_programs.h which is included in mkfs.minix and fsck.minix.
The minix.h will have only struct definitions etc generic
contents which is reasonable to share with utilities and
libraries.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-20 20:43:16 +02:00
Sami Kerola 63883af765 libblkid: use MINIX_BLOCK_SIZE from minix.h
In the minix.h two definitions where renamed, so that the single
definition is reusable in fsck.minix, mkfs.minix and libblkid.

BLOCK_SIZE_BITS -> MINIX_BLOCK_SIZE_BITS
BLOCK_SIZE      -> MINIX_BLOCK_SIZE

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-20 20:13:08 +02:00
Sami Kerola 532055e2e6 include: move minix.h to include directory
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-20 19:58:51 +02:00
Davidlohr Bueso 0e75337c31 lib: [blkdev.c] add blkdev_get_physector_size()
This function uses the BLKPBSZGET ioctl to get the physical block size
of the device.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-27 15:57:31 +02:00
Karel Zak fd7f0718d4 lib: [loopdev.c] cleanup flags usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-10 15:38:13 +02:00
Sami Kerola e53bc9604c lib: add strtoul_or_err() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-01 09:57:43 +02:00
Karel Zak 10ee593293 lib: [loopdev.c] add module for work loop devices
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-30 16:37:46 +02:00
Francesco Cosoleto 5d2a98490e This adds a second parameter to size_to_human_string() to return a
string with a different format based on the following flags:

        SIZE_SUFFIX_1LETTER  = "1K"
        SIZE_SUFFIX_3LETTER  = "1KiB",
        SIZE_SUFFIX_SPACE    = "1 KiB" or "1 K"

[kzak@redhat.com: - rename flags to SIZE_SUFFIX_* format,
                  - fix suffix[] buffer size
                  - add 3 letter version to the test]

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-26 15:32:33 +02:00
Sami Kerola dd9a787376 build-sys: add required files to dist
Files mkfs.h procutils.h sysfs.h where missing from dist file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-26 15:03:27 +02:00
Karel Zak 413993fcb1 lib: [sysfs.c] add sysfs_readlink and name/path functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-18 16:24:37 +02:00
Karel Zak cdc9c4194a lib: [at.c] add readlink_at(), fix semantic for absolute paths
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-18 15:57:16 +02:00
Karel Zak 90e9fcda3b lib: [sysfs.c] make sysfs_read_* function more robust
The functions does not modify result if the requested sysfs attribute
does not exist.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-18 11:57:17 +02:00
Werner Fink 729def03e1 agetty: cleanup argv parsing, utmp update, use writeall(), etc.
Next cleanup, that is split off special character parsing in do_prompt()
and parse_args(), handle name of line of virtual console and use it in
utmp update as well as the session id.  Also move the initial TERM
variable to open_tty() as we use this later in open_tty().  Use writeall()
but avoid repeat to often for EAGAIN (compare with info page of the
(g)libc, description of the macro EAGAIN).

Signed-off-by: Werner Fink <werner@suse.de>
2011-05-17 11:10:03 +02:00
Karel Zak d8a84552fb libblkid: use stuff from sysfs.h and at.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-16 20:22:52 +02:00
Karel Zak 7fe16fdaf4 lib: add generic sysfs utils
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-16 20:22:52 +02:00
Karel Zak bfe695ff5b lib: [tt.c] support key="value" output format
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-10 10:37:39 +02:00
Davidlohr Bueso 86a84a17d2 procutils: include missing header
To be able to use DIR we need to include the dirent.h header. This fixes issues such as:

../include/procutils.h:5: error: syntax error before "DIR"
../include/procutils.h:5: warning: no semicolon at end of struct or union

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-05-05 14:01:39 +02:00
Karel Zak 5b1f031123 lib: [procutils.c]: add missing files. Sorry.
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-04 15:52:39 +02:00
Sami Kerola 96cc7b0b3e agetty.c: move issue path to pathnames.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-04-27 23:21:19 +02:00
Karel Zak ce56db8466 lib: [tt.c] support fixed width and multiple tt_print_table() calls
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-04-27 17:15:36 +02:00
Davidlohr Bueso ba32692970 blkdev: add blkdev_is_misaligned()
This functions returns the status of the device's alignment. It will
be 0 when aligned, otherwise return the offset.

[kzak@redhat.com: - returns 0 if the ioctl failed]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-04-12 13:08:52 +02:00
Davidlohr Bueso 7cf78990fc include: [c.h] add definition wrappers for old libc versions
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-29 10:35:40 +02:00
Sami Kerola 37f44962dd include: [c.h]: remove strings.h include dublicate
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-03-08 13:08:54 +01:00
Sami Kerola c764e1a41d include: [c.h]: typeof to __typeof__ fix
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-03-08 13:08:48 +01:00
Sami Kerola 94d32126bf strutils: new wrapper function strtoll_or_err
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-02-21 15:32:50 +01:00
Petr Uzel 8ba013af64 include: [xalloc.h]: mention strdup in the file description
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-21 14:41:37 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Karel Zak 4799c95f94 include: [c.h]: add fallback for old libs without O_CLOEXEC
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-11 10:49:50 +01:00
Karel Zak 067e396b12 include: [at.h]: include c.h for PATH_MAX
Reported-by: Peter Breitenlohner <peb@mppmu.mpg.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-11 10:36:12 +01:00
Karel Zak c25dc28dff include: [c.h]: add unused attribute to ignore_result()
unfortunately, gcc 4.6

	void fn (void) {
		int foo;
		foo = bar ();
	}

evaluates that foo is never used. The __attribute__((unused)) is
necessary...

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-09 20:40:06 +01:00
Karel Zak 50a1e0cf8b include: [c.h]: fix __alloc_size__ test
Reported-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-08 16:35:41 +01:00
Marek Polacek b45fa8b2f1 include: [xalloc.h] include string.h
xalloc.h needs string.h for declaration of strdup().  Otherwise we
can get implicit declaration warning.  This patch prevents it.

Signed-off-by: Marek Polacek <mpolacek@redhat.com>
2011-02-07 17:46:15 +01:00
Karel Zak 40084d0d5c include: [c.h] add fallback for alloc_size attributes
Reported-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-07 17:29:47 +01:00
Karel Zak 2dd570ec85 include: [c.h] move ignore_result() to gcc-only block
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-07 15:52:21 +01:00
Fabian Groffen a804f444eb provide a workaround if program_invocation_short_name is missing
Try some replacements, such as getexecname() on Solaris and __progname
on BSDs and Darwin.  When not found, base program_invocation_short_name
on the source filename it is used in, as not to require argv[0] to be
passed along.  This latter approach is not dynamic, but doesn't require
code changes for all places where program_invocation_short_name is used
now.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-31 15:51:06 +01:00
Karel Zak 1f51db365f include: [tt] enlarge output buffer
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-25 00:24:17 +01:00
Fabian Groffen d58c47d9a4 include: emulate dirfd when necessary
dirfd is not available on Solaris 10, it is available on latest
OpenSolaris releases though.  Do some autoconf trickery to determine if
providing an alternative dirfd function is necessary and possible.

shlibs/blkid/src/read.c: Do not define _XOPEN_SOURCE to 600, or DIR will
lose it's dd_fd member again.  Rearrange defines and includes to make
sense per comments, and not conflict on Solaris.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-01-23 22:17:14 +01:00
Karel Zak 3e27b34eb0 lib: [xalloc] don't use hardcoded return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-23 21:28:19 +01:00
Fabian Groffen 0bf9d41da2 build-sys: check for paths.h
paths.h doesn't exist on Solaris

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-01-20 23:47:52 +01:00
Fabian Groffen 3edaa2019b make _IO macros available on Solaris
The _IO macro is defined in sys/ioccom.h on various platforms.  However,
on Solaris it isn't included by ioctl.h, so include it explicitly if
available.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-01-20 23:31:14 +01:00
Karel Zak 960f668f17 make major and minor available on Solaris
Reported-by: Fabian Groffen <grobian@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-20 23:16:41 +01:00
Fabian Groffen 5be1c0330b build-sys: check for loff_t, it may not exist
On some systems, loff_t does not exist.  Define it as int64_t in that
case.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-01-20 22:40:58 +01:00
Karel Zak bded43d7ca build-sys: add rpmatch.h to Makefile.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-19 09:42:28 +01:00
Fabian Groffen aabe244176 build-sys: use WORDS_BIGENDIAN to determine platform byte-order
Autoconf contains the right magic to determine the endianness on many
platforms next to Linux.  This reverses previous commits to move away
from WORDS_BIGENDIAN:
"use __BYTE_ORDER rather than AC specific WORDS_BIGENDIAN"

This is necessary to compile on non Linux platforms like Darwin and
Solaris.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-01-17 15:34:45 +01:00
Karel Zak 85950b68e4 include: fix list.h ifdefs
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-14 15:49:07 +01:00
Francesco Cosoleto e66ac5d344 include: add fallback for rpmatch()
Simple replacement code with hardcoded y/n responses to allow
compilation on systems without rpmatch() such as Cygwin.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-05 16:18:08 +01:00
Karel Zak 06ceeef851 lib: [c] add ignore_result()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-04 21:34:45 +01:00
Karel Zak 049caefdcf findmnt: add --submounts option
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-04 14:01:33 +01:00
Karel Zak 035507c84b lib: [env] consolidate safe_getenv() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:48 +01:00
Karel Zak 5ac6a13327 libmount: cleanup mangle() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:47 +01:00
Karel Zak dd36965211 libmount: use better format for utab, improve bind mounts
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:46 +01:00
Karel Zak 8f3f6383a5 libmount: rewrite mountinfo/fstab parsers to use sscanf()
The old solution (without scanf()) was based on old code from
mount(8). It seems that the modern libc is able to provide all
necessary functionality by sscanf() and %ms directive.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:43 +01:00
Karel Zak 3c5e4ef888 libmount: add unmangle/mangle() functions to API
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:40 +01:00
Karel Zak 9826a63737 libmount: add /etc/fstab.d support
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:39 +01:00
Karel Zak 5a5eeb1513 lib: add wrappers for "at" functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:39 +01:00
Davidlohr Bueso c4ecaf21d5 partx: complete rewrite
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-12-09 21:54:17 +01:00