Commit Graph

835 Commits

Author SHA1 Message Date
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
Karel Zak b61e939013 losetup: use /sys/dev/block/.../loop/backing_file
The basic loopdev attributes are available in sysfs since kernel
2.6.37. This patch uses the backing_file attribute from sysfs for very
long filenames (the LOOP_GET_STATUS ioctl uses only 64 bytes for the
filename).

old version:
 # losetup -a
 /dev/loop0: [0804]:12865322 (/home/images/filesystems/this_is_really_really_long_directory_*)

new version:
 # losetup -a
 /dev/loop0: [0804]:12865322 (/home/images/filesystems/this_is_really_really_long_directory_name/ext2.img)

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-12-01 14:04:35 +01:00
Karel Zak 43bc1a1ba4 build-sys: add missing header
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-30 11:52:10 +01:00
Karel Zak ce877f2d16 lib: [strutils] move strmode() from namei.c to strutils.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-24 17:08:32 +01:00
Karel Zak ecc264bc39 lib: [xalloc] add xstrdup()
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-24 17:08:32 +01:00
Karel Zak 3e451589d5 lib: [tt] add TT_FL_RIGHT, add columns list parser
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-24 17:08:31 +01:00
Davidlohr Bueso 8abcf29002 lib: [strutils] general purpose string handling functions
This patch replaces a few functions used throughout the source:
* Renames getnum (from schedutils) to strtol_or_err
* Moves strtosize (from lib/strtosize.c)
* Moves xstrncpy (from include/xstrncpy.h)
* Adds strnlen, strnchr and strndup if not available (remove it from libmount utils)

A few Makefile.am files were modified to compile accordingly along with trivial renaming
in schedutils source code.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-11-23 21:06:49 +01:00
Karel Zak dc61d398ba lib: add fallback for nl_langinfo()
The fallback ignores locales and returns hardcoded static strings. It
should be enough to include "nls.h" to work with nl_langinfo() on all
systems.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-15 16:42:45 +01:00
Davidlohr Bueso d7df7ba264 xalloc: general purpose memory allocation handling wrappers
[kzak@redhat.com: - use %zu for size_t]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-10-21 10:28:05 +02:00
Karel Zak 973af80642 libblkid: fix MBR detection on iPod and cleanup vfat code
- move all FAT code to superblocks/vfat.c only
 - add a generic function to verify FAT superblock and use it
   in FAT prober as well as in MBR parser
 - add a more robust FAT cluster_count check
   (it seems that iPod contains an "almost valid" FAT superblock before MBR)

Reported-by: Davidlohr Bueso <dave.bueso@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-10-15 01:33:28 +02:00
Karel Zak 9ef30d6178 include: cleanup blkdev.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-08-24 12:04:24 +02:00
Karel Zak 1519ab5ffc blockdev: add BLKDISCARDZEROES
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-08-24 11:47:55 +02:00
Karel Zak 7d2a8dd00d lscpu: fix CPU_EQUAL_S macro
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-16 22:50:42 +02:00
Karel Zak e67690f35a lscpu: add CPU_EQUAL_S definition for old/obscure libc
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-14 11:25:31 +02:00
Karel Zak 42cb90dcaa build-sys: update include/Makefile.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-07 12:48:51 +02:00
Karel Zak ac3d410c46 lib: tt.c - fix minimal width of column
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-03 15:20:12 +02:00
Karel Zak c15b21e4e3 lib: add tt.c (Tree and Table output)
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-03 15:20:12 +02:00
Karel Zak c391642d0f include: move shlibs/.../list.h to the include/ directory
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-03 15:20:11 +02:00
Karel Zak 04fd7a9feb findmnt: add new command
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-03 15:20:11 +02:00
Karel Zak bae91ecf07 taskset: move NR_CPUS determination to lib/cpuset.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:11:26 +02:00
Karel Zak ee32c514b5 lib: add fallback for libc (uClibc) without CPU_ALLOC
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:09:23 +02:00
Karel Zak ff5a6d2067 taskset: use libc based cpu_set_t
The glibc already supports dynamically allocated CPU sets. We don't
have to maintains our private non-compatible implementation.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:06:50 +02:00
Karel Zak efcb71f8ff taskset: move bitmap routines to lib/cpuset.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:04:44 +02:00
Hajime Taira f0bef3ca0f fsfreeze: new command
[kzak@redhat.com: - cleanup
                  - add long options
                  - add note about DM to the man page
                  - use err.h and nls.h]

Signed-off-by: Hajime Taira <htaira@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-05-14 13:01:01 +02:00
Karel Zak 5f94ca33cf cfdisk: support non-ascii characters in input
On Sat, Apr 03, 2010 at 12:58:48PM +0000, Jorge wrote:
> When you want to write changes to disk you're asked for a
> confirmation, like this one:
>
>   Are you sure you want to write the partition table to disk? (yes
>   or no)
>
> There is no problem on the English version, but when you launch the
> program in Spanish you get this:
>
>   ¿Está seguro de que desea escribir la tabla de particiones en el
> disco?
>      (sí o no):
>
> You can't type the "í" character. Trying to do so will end in no
> input at all. That is, typing in my keyboard "´" then "i" leads to
> nothing. So you can't write changes to disk, and you must launch the
> program in English for it to operate.

Reported-by: Jorge <yo@jorgesuarezdelis.name>
Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/205327
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-05-07 14:12:26 +02:00
Karel Zak ca55a451cd mount: revert ugly ENOMEDIUM support
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-27 15:15:11 +02:00
Jason Borden 4dddc2d4aa swaplabel: new command
Print or change the label / UUID of a swap area.

[kzak@redhat.com: - code refactoring
                  - add long options
                  - clean up Makefile.am]

Signed-off-by: Jason Borden <jborden@bluehost.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-02 16:16:59 +02:00
Karel Zak 865deca224 swapon: move DELETED_SUFFIX to include/pathnames.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-02 11:43:36 +02:00
Karel Zak 7771431278 mkswap: move write_all() to include/writeall.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-01 16:17:17 +02:00
Karel Zak cf8de26afe lib: add strtosize() function
This function

  int strtosize(const char *str, uintmax_t *res)

supports {K,M,G,T,E,P}iB and {K,M,G,T,E,P}B suffixes.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-30 13:51:58 +02:00
Karel Zak 70502c5246 lib: add #ifndef around min() max() macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-16 15:24:04 +01:00
Pádraig Brady 104b92f848 cal: factor out and update multibyte alignment code
* include/mbsalign.h: New module interface
* lib/mbsalign.c: Updated implementation synced from coreutils
* include/Makefile.am: Add mbsalign.h
* misc-utils/Makefile.am: Make cal dependent on mbsalign module
* misc-utils/cal.c: Call mbsalign()

[kzak@redhat.com: - use min() macro from c.h]

Signed-off-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-16 15:16:11 +01:00
Karel Zak c6c98f93f5 mount: report ambivalent FS detection, improve brute force detection
The ambivalent probing result should be properly reported and user
should be informed that the problem is possible to bypass by "-t
<type>" or resolved by wipefs(8).

The mount(8) command uses a brute force stage (calls mount(2) for all
/{proc,etc}/fylesystems) if there is not any other way how to detect
the filesystem type. The brute force stage should not be restricted by
libblkid. It's possible that libblkid is not able to detect slightly
corrupted filesystem, but kernel is able to mount such filesystem.

Note that the brute force stage should not be used if libblkid returns
ambivalent probing result. In this case user's intervention is required
(e.g. mount -t <type>).

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-15 13:46:43 +01:00
Karel Zak 21169393e3 lib: add mangle.c for mtab (fstab or swaps) encoding
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-10 23:54:11 +01:00
Karel Zak 3069624180 liblkid: move getsize.c code to lib/
.. and cleanup blkdev_get_size() usage in libblkid.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-10 15:41:40 +01:00
Karel Zak 1cb1641dde include: add min/max macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-12 21:42:46 +01:00
Karel Zak 49361dc4dc libblkid: add blkid_probe_all_removable()
The libblkid probing is based on devices from /proc/partitions by
default. This file usually does not contain removable devices (e.g.
CDROMs) and this kind of devices are invisible for libblkid.

The blkid_probe_all_removable() function adds removable block devices
to blkid cache. The probing is based on information from the /sys
directory. The devices which were detected by this function won't be
written to blkid.tab cache file.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=533874
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-01 14:23:55 +01:00
Karel Zak a992137b7b mount: and libblkid: covert /dev/dm-N to /dev/mapper/<name>
* mount(8) uses private device-mapper names in mtab

 * libblkid returns private device-mapper names when evaluate udev
   /dev/disk-by symlinks.

 * on systems where DM is fully integrated with udev the /dev/mapper/<name>
   files are symlinks to /dev/dm-N. It means we need a special care to hide
   private device-mapper names.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-26 13:33:03 +01:00
Karel Zak 45bda5c8dd include: use c.h in canonicalize.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16 01:45:42 +02:00
Karel Zak 4d0dbb8b63 include: add c.h with fundamental C definitions
Add:
  * ARRAY_SIZE with array type check
  * PATH_MAX, TRUE and FALSE macros
  * dummy __attribute__ for non-gcc compilers

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16 00:57:50 +02:00
Karel Zak e98754d6bb fsck.minix: fix broken zone checking
This bug has been introduced by commit
95356e8b74.

The fsck.minix code assumes that isset() macro returns boolean,
unfortunately the generic implementation from libc returns integer.

This patch also add a fallback for the bitmap macros to include/bitops.h.

Reported-by: "Andries E. Brouwer" <Andries.Brouwer@cwi.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-15 14:14:32 +02:00
Karel Zak ed98508a1c blockdev: fix topology ioctls
kernel 2.6.32-rc4 (kvm):

 # blockdev -v --getss --getpbsz --getiomin --getioopt --getmaxsect --getalignoff   /dev/sda
 get logical block (sector) size: 512
 get physical block (sector) size: 512
 get minimum I/O size: 512
 get optimal I/O size: 0
 get max sectors per request: 1024
 get alignment offset: 0

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-15 02:32:03 +02:00
Karel Zak d965d63f64 blockdev: add topology ioctls support
new options:

   --getpbsz                      get physical block (sector) size
   --getiomin                     get minimum I/O size
   --getioopt                     get optimal I/O size
   --getalignoff                  get alignment offset
   --getmaxsect                   get max sectors per request

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-15 01:22:42 +02:00
Karel Zak acf6ab6f67 lib: import whole ismounted.c code from e2fsprogs
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-14 01:13:18 +02:00
Karel Zak a4532e10e3 lib: remove pttype.c
The libblkid library supports partition tables detection now.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-09-29 13:31:32 +02:00
Karel Zak 7ef93b3eff libblkid: add blkid_driver_has_major()
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-09-18 13:07:05 +02:00
Karel Zak 7176f22db5 lib: add a generic crc32()
This is public domain implementation, based on static crc32_table[].
This implementation is used on may places (libparted, FreeBSD kernel,
PostgreSQL, ...). The Linux kernel uses on-the-fly generated and
allocated tables. That's useless in shared libraries.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-09-16 16:17:41 +02:00
Karel Zak 77f5744c98 rtcwake: add S5 support
Based on patch from
   Piergiorgio Sartor <piergiorgio.sartor@nexgo.de>
at
   https://bugzilla.redhat.com/show_bug.cgi?id=449115

Piergiorgio's note about S5:
> According to the ACPI specifications, chapter 4.7.2.4 "Real Time
> Clock Alarm", the wakeup from RTC, when supported, should work from
> *sleep* state S1-S3 and, optionally, from S4.
>
> Note 3 (same chapter) says that S5 is *not* a sleep state and should
> not be supported. Actually it also says that: "The OS will disable
> the RTC_EN bit prior to entering the G2/S5 or G3 states regardless."
>
> Nevertheless, on all PC supporting the RTC wakeup I tested, all were
> able to wake from S5.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-09-07 12:04:26 +02:00
Daniel Mierswa 437fa54f05 replace usleep() for systems that don't have them
This function is marked obsolete in POSIX.1-2001 and removed in
POSIX.1-2008.

Conditionally replaced with nanosleep().

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
2009-08-21 09:58:17 +02:00
Karel Zak 14b613f3a9 include: fix _PATH_DEV
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-07-02 09:50:26 +02:00
Karel Zak c74c0dafff include: clean up _PATH_DEV_* macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-06-30 01:13:42 +02:00
Karel Zak dcbf520914 include: bitops - explicitly include endian.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-17 14:27:38 +01:00
Karel Zak 015ea51c10 libs: pttype - fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-12 14:34:47 +01:00
Karel Zak dfbc185e53 lib: wholedisk - extend API, add test program
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-12 14:31:50 +01:00
Karel Zak 17c0248447 lib: pttype - extend the API to work with file descriptors
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-12 14:17:59 +01:00
Karel Zak 2fb83c6752 include: add missing files to Makefile.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-12 10:22:30 +01:00
Karel Zak e85a2a9392 lib: add pttype.c for PT types detection
This is a small fragment from libdisk (from xfsprogs). The final
solution will be to move the library to util-linux-ng.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-12 10:15:50 +01:00
Karel Zak 929f243f79 lib: add is_whole_disk() from fdisk code
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-11 14:00:21 +01:00
Karel Zak 7926576ec2 lib: fix fsprobe wrapper (const char * is nonsense)
The fsprobe_ functions return newly allocated strings.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-03 16:25:23 +01:00
Karel Zak f314a6becc fdisk: (and partx) remove BLKGETLASTSECT
This odd ioctl is unsupported in the current 2.4 and 2.6 mainline.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-02-26 23:03:46 +01:00
Karel Zak 77be714e05 build-sys: add missing files to include/Makefile.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-02-20 13:21:40 +01:00
Karel Zak 607c2a7295 fsck: move fsck from e2fsprogs to util-linux-ng
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-02-18 15:09:34 +01:00
Karel Zak 17f29d7bac mount: generic blkid/volume_id wrapper, use blkid_evaluate_*
* moves the generic libblkid/libvolume_id wrapper (fsprobe.c) from
   mount/ to lib/. We'll use the wrapper in cfdisk and fsck.

   The wrapper supports:

    - obsolete volume_id (udev)
    - obsolete libblkid (e2fsprogs)
    - libblkid (util-linux-ng)

 * mount, umount and swapon when linked against the new libblkid use

    - low-level probing code to read LABEL, UUID or FSTYPE from a device
    - high-level blkid_evaluate_spec() to convert LABEL/UUID to devname

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-02-17 01:18:22 +01:00
Karel Zak 74a9c6f7b7 mount: move realpath.c code to lib/
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-02-11 23:55:51 +01:00
Karel Zak 525dd31635 fdisk: cleanup _PATH_DEV_* macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-02-06 22:23:13 +01:00
Karel Zak 8bce47d976 include: use __BYTE_ORDER rather than AC specific WORDS_BIGENDIAN
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-12-08 11:16:37 +01:00
Karel Zak dee98cdedc include: swapheader.h is missing in Makefile.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-12-05 15:53:40 +01:00
Matthias Koenig d60819b36d include: move swapheader.h to include
[kzak@redhat.com: add ifndef _SWAPHEADER_H]

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-12-05 11:51:40 +01:00
Karel Zak edb68d0ca3 losetup: looplist_* refactoring, remove scandir()
This patch replaces scandir-based implementation with readdir(). The
readdir(3) is less expensive and more portable (to non-glibc environment).

The patch also replaces sysfs-based solution with simpler /proc/partitions
parsing. The /proc/partitions includes all used loop devices on all systems
(include 2.4). This solution seems faster than scandir(/sys/block/) too.

Summary, the losetup (with this patch) uses three methods to found a
loop device:

  a) parse /proc/partitions to found already used loop devices (for
     loserup -a)

  b) stat(2) for all loop[0-7] devices (default number of loop devices).
     This is classic method from util-linux <= 2.13. This method is good
     enough for standard Linux machines with default number of loop
     devices.

  c) scan all /dev or /dev/loop/ for loop devices. This is useful for
     crazy people who need more than 8 loop devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-04 13:54:27 +02:00
Matthias Koenig d50c5917f0 mount: retry on ENOMEDIUM
Due to a change in kernel behaviour when opening CDROM devices,
we need to retry the open/mount call when ENOMEDIUM is returned.

Explanation from Tejun Heo:
Okay, the difference is from the addition of cdrom_get_media_event()
call to both sr_drive_status() and ide_cdrom_drive_status().
Previously, the cdrom driver can't differentiate between tray closed
w/ no media and tray open and always returned tray open, which
triggers close and retry in the open logic which probably have delayed
things enough to get the media recognized.

Now the cdrom driver can discern between tray closed w/o media and
device not ready for other reasons and returns -ENOMEDIUM on the
former.  This is all good and dandy but the problem seems that some
drives report no media right after the tray is closed but it hasn't
properly detected the media yet.

It seems the only way to work around the problem is via sensible
retries (e.g.  try three times 5 secs apart) and I don't think we can
add that type of retry logic into cdrom open path.  Please note that
the previous logic wasn't water proof.  Some drives can take longer to
recognize the media is there and could have failed the in-kernel retry
too.  Also, reading the media can take quite some time and during that
period the drive reports media present but device not ready.  The
driver will retry the command (e.g. READ TOC for open) five times but
all of them can fail w/ EMEDIUMTYPE.

[kzak@redhat.com: - add CRDOM_NOMEDIUM_RETRIES to blkdev.h
                  - add verbose message to mount.c]

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-07-30 13:21:14 +02:00
Samuel Thibault 268cefe6cb lib: blkdev.c clean up, non-linux support
[kzak@redhat.com: split the original patch to small patches]

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-07-24 00:52:52 +02:00
Samuel Thibault 580cb0d069 include: <stdint.h> provides everything
Do not include <linux/posix_types.h> as <stdint.h> provides everything.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2007-12-18 01:10:48 +01:00
Karel Zak a34fc3d4ad include: add bitops.h with swab{16,32,64} macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-12-17 13:41:13 +01:00
Karel Zak 1ed3367f61 include: add bitops.h with swab{16,32,64} macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-12-17 13:18:12 +01:00
Karel Zak 4d43977ffc include: add mount paths to pathnames.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-11-28 14:08:33 +01:00
Karel Zak 2f4564eac4 include: cleanup pathnames.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-11-28 13:17:16 +01:00
Karel Zak 8505ff35cf elvtune: use get_linux_version()
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-11-07 21:25:48 +01:00
Stefan Krah 3738a48e08 lib: add blkdev.{c,h}
Now we duplicate BLK* ioctls on many places... This patch also
fix BLKGETSIZE64 usage in dependence on kernel version.

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Stefan Krah <stefan@bytereef.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-11-07 12:37:30 +01:00
Stefan Krah 5d2c98e1df lib: add linux_version.{c,h}
Signed-off-by: Stefan Krah <stefan@bytereef.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-11-06 02:40:13 +01:00
Karel Zak c5f671113b build-sys: remove errs.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-10-18 15:00:17 +02:00
Mike Frysinger 8b7f16fc37 build-sys: nls/locale handling in util-linux-ng general
On Monday 03 September 2007, Karel Zak wrote:
> http://thread.gmane.org/gmane.linux.utilities.util-linux-ng/590/focus=592
>
>  I agree that we need a better support for compilation without
>  locales, but from my point of view NLS != all locales stuff. The NLS
>  support is subset only.

thinking about the input from everyone, i'd propose the attached ...

Only pull in locale.h as needed and move it to the common nls.h.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2007-09-19 23:15:21 +02:00
Gabriel Barazer 392f76cf9a build-sys: missing header when NLS is disabled
Compiling utils fail when disable NLS with the --disable-nls switch.
"mkfs.c:46: error: 'LC_ALL' undeclared (first use in this function)"
It is due to a missing locale.h header : When enabling NLS, nls.h
includes libintl.h, which in turn includes locale.h. When disabling NLS,
libintl.h isn't anymore included nor locale.h, which is needed for the
setlocale() calls.

Signed-off-by: Gabriel Barazer <gabriel@oxeva.fr>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-07-23 14:03:13 +02:00
Stepan Kasal 7f97ecc938 build-sys: use dist_noinst_HEADERS in include/Makefile.am
It is slightly more appropriate.

Signed-off-by: Stepan Kasal <skasal@redhat.com>
2007-05-16 11:43:31 +02:00
Karel Zak 66a9411eb0 newgrp: add support for /etc/gshadow
The original newgrp command doesn't expect group pasword in /etc/gshadow
although almost all distributions use this file (and the gpasswd command).

The newgrp from util-linux is deprecated and better is use shadow-utils only.
Unfortunately, shadow-utils are broken too (see RH version where is bugfix).
In this case it's better fix util-linux version at least...

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-03-21 23:07:25 +01:00
Karel Zak 06b04b23cd build-sys: fix ifdef ENABLE_WIDECHAR usage
There has been unexpected mix of HAVE_WIDECHAR and ENABLE_WIDECHAR macros. The
ENABLE_WIDECHAR is old version and has to be replaced everywhere otherwise we
will see bugs with multibyte stuff.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-01-30 13:49:50 +01:00
Karel Zak 48d7b13a1e Imported from util-linux-2.13-pre1 tarball. 2006-12-07 00:26:54 +01:00