Commit Graph

270 Commits

Author SHA1 Message Date
Karel Zak 922e6775e0 build-sys: move tests to check_PROGRAMS
Thanks to Mike Frysinger.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-30 17:59:16 +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
Karel Zak 1369e06cdb lib/match: fix compiler warning [-Wmissing-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-16 18:29:22 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola 510a1a3450 lib/loopdev: minor bug fix: add missing semicolon
Missing semicolon made test_loop_info() to return function
loopcxt_enable_debug() return value, which happen to be void.  I
suspect the loopcxt_enable_debug() was usually not executed, while it
should be.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:21 +02:00
Sami Kerola 3b1d28792d lib/pager: minor compiler warning fixes
Add missing function prototype, and declare structure before use of it.

lib/pager.c:162:6: warning: no previous prototype for function 'setup_pager' [-Wmissing-prototypes]
lib/pager.c:20:29: warning: tentative definition of variable with internal linkage has incomplete non-array type 'struct child_process' [-Wtentative-definition-incomplete-type]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:21 +02:00
Karel Zak 657d9adb71 fix buffer overrun in some calls to sscanf
Reported-by: Sergei Antonov <saproj@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-09 22:26:27 +02:00
Karel Zak f38e5ff355 build-sys: cleanup .gitignore files
- move all binaries to top-level .gitignore
 - remove unnecessary */.gitignore files

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:50:54 +02:00
Karel Zak d77ab74af7 build-sys: convert lib/ to libcommon.la
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:50:53 +02:00
Karel Zak 8d34d92bcd build-sys: define per-test -DTEST_PROGRAM in lib/
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 17:21:39 +02:00
Karel Zak e0ef609e89 build-sys: convert lib/ to module
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 17:13:08 +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
Cong Wang a0b25068ab lib/mangle: fix a memory leak in the test case
Marek reported there is a memory leak in lib/mangle.c

  CC       mangle.o
mangle.c:160:9: warning: Memory is never released; potential leak of memory pointed to by 'ss'

This patch fixes it.

Reported-by: Marek Otahal <markotahal@gmail.com>
Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-06-21 08:21:43 +02:00
Cong Wang cffee0de0c lib/sysfs: check if cxt->dir_path is NULL in sysfs_readlink()
cxt->dir_path could be NULL, for example, when sysfs_init() fails,
check this before calling readlink()/readlink_at().

Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-06-21 08:21:23 +02:00
Sami Kerola ce7b11a98e lib/mbsalign: abort() when non-expected case is encountered
Fixes the following compiler warning (9 occurrences), and makes program
to crash if mbsaligh() is called with unexpected align value (which
would be programming error).

../lib/mbsalign.c:260:7: warning: switch missing default case [-Wswitch-default]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +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 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 9d72cbc1e2 sysfs: fix printf format warnings
sysfs.c:93:3: warning: format '%u' expects argument of type 'unsigned
	int *', but argument 3 has type 'int *' [-Wformat]
sysfs.c:93:3: warning: format '%u' expects argument of type 'unsigned
	int *', but argument 4 has type 'int *' [-Wformat]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Sami Kerola 838c5f6bb8 build: fix unused parameter warnings
pager.c:203:14: warning: unused parameter 'argc' [-Wunused-parameter]
pager.c:203:26: warning: unused parameter 'argv' [-Wunused-parameter]

randutils.c:108:14: warning: unused parameter 'argc' [-Wunused-parameter]
randutils.c:108:26: warning: unused parameter 'argv' [-Wunused-parameter]

optstr.c:774:37: warning: unused parameter 'optstr' [-Wunused-parameter]
optstr.c:774:51: warning: unused parameter 'value' [-Wunused-parameter]
optstr.c:774:65: warning: unused parameter 'valsz' [-Wunused-parameter]
optstr.c:774:79: warning: unused parameter 'next' [-Wunused-parameter]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Sami Kerola 0e9b73d3fb build: fix redundant redeclaration warnings
env.c:24:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]
su.c:81:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]

fstab.c:581:14: warning: redundant redeclaration of 'strsignal' [-Wredundant-decls]

kill.h:1:13: note: previous declaration of 'get_pids' was here
kill.c:152:13: warning: redundant redeclaration of 'get_pids' [-Wredundant-decls]

kill.c:142:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]
getopt.c:89:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]

agetty.c:536:15: warning: redundant redeclaration of 'optarg' [-Wredundant-decls]
agetty.c:537:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
script.c:161:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
wall.c:96:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]

libmount.h:362:26: note: previous declaration of 'mnt_update_get_fs' was here
libmount.h:454:26: note: previous declaration of 'mnt_context_get_fs' was here
mountP.h:383:26: warning: redundant redeclaration of 'mnt_context_get_fs' [-Wredundant-decls]
mountP.h:398:26: warning: redundant redeclaration of 'mnt_update_get_fs' [-Wredundant-decls]

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
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
Thomas Schwinge 7e36b0b47b lib/pager: repair build for non-Linux.
Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
2012-05-29 09:32:57 +02:00
Karel Zak 82756a747e libmount: add MNT_ERR_LOOPDEV
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-28 12:26:36 +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
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 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
Dave Reisner ea178007eb lib/mangle: check for end of string on every iteration
Checking for the null byte at the end of the string only conditionally
leads to segfaults, evidenced by mount helpers crashing on writes to
/run/mount/utab. Simply check for the null on each iteration, and append
a null byte to the mangled string before breaking.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-15 11:32:24 +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
Karel Zak f6efe5024c lib/tt: check for non-printable chars for raw/export format
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-26 09:28:44 +02:00
Karel Zak f8bb6246fd lib/tt: encode data for RAW and EXPORT format
* all tt based utils will properly encode blank chars for raw output
   format and quotes for export output format

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-26 09:22:19 +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
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
Bernhard Voelker 455fe9a075 Fix typos found by misspellings
The tool misspellings (https://github.com/lyda/misspell-check)
detected several typos. Command used:

  $ git ls-files | grep -v ^po/ | misspellings -f -

* isosize: Fix typo in usage string.
* configure.ac: Fix typo in help string of --enable-most-builds option.
* fdisk: Fix typo in man page.
* libblkid, blkid, mount: Likewise.
* Fix various typos in docs and in source code comments.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-04-23 13:16:35 +02:00
Karel Zak 505abd8434 lib/pager: fix compiler warnings
pager.c: In function ‘start_command’:
pager.c:82:7: warning: unused variable ‘err’ [-Wunused-variable]
pager.c:49:25: warning: unused variable ‘fderr’ [-Wunused-variable]
pager.c:49:15: warning: unused variable ‘fdout’ [-Wunused-variable]
pager.c:48:25: warning: unused variable ‘need_err’ [-Wunused-variable]
pager.c:48:15: warning: unused variable ‘need_out’ [-Wunused-variable]

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-23 11:57:50 +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
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
Karel Zak c344350948 lib/blkdev: fix compiler warning [-Wreturn-type]
../lib/blkdev.c: In function ‘blkdev_get_geometry’:
../lib/blkdev.c:287:1: warning: control reaches end of non-void function [-Wreturn-type]

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-10 12:29:10 +02:00
Davidlohr Bueso 958d2b712a strutils: return success on test program
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-10 12:21:30 +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
Karel Zak 6219c25ecb lib/loopdev: more robust initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-02 17:33:41 +02:00