Commit Graph

4719 Commits

Author SHA1 Message Date
Karel Zak 6257e44582 libmount: close device fd (to avoid mount(2) EBUSY)
libmount uses libblkid to detect filesystem type. Unfortunately, the
blkid probe struct is not freed before mount(2), it means that the
device is still open and mount(2) may return EBUSY.

We don't need persistent blkid stuff in libmount, so let's close
all immediately after device probing.

Reported-by: David Zeuthen <zeuthen@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-27 10:30:08 +02:00
Dave Reisner b215d8e9a7 findmnt: add match_by_file to do within-device matching
Use the newly exported mnt_get_mountpoint to determine the device that a
given file resides on, in case the supplied source or target is not
explicitly a mount point.

http://www.spinics.net/lists/util-linux-ng/msg06081.html

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-26 09:38:07 +02:00
Dave Reisner cd3d6c5bd0 libmount: expose mnt_get_mountpoint as external API 2012-04-26 09:38:02 +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 d324270eee lsblk: remove private \x<hex> coding, decode data from udev
* remove private encoding code (all encoding will be in lib/tt.c)
 * decode LABELs from udev

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-26 09:20:47 +02:00
Karel Zak 4644638fe8 findmnt: add note about \x<hex> to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-26 09:19:07 +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 cd49218679 findmnt: add support for maj:min source
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-25 09:51:26 +02:00
Karel Zak 677ff053f6 libmount: add mnt_table_find_devno()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-25 09:49:50 +02:00
Karel Zak 54a3d5eeec libmount: fix mnt_context_guess_fstype()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-25 09:05:24 +02:00
Karel Zak ba24923e97 mount: (new) use MNT_ERR_ for error messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-24 11:59:18 +02:00
Karel Zak 47dea49b4c libmount: add special MNT_ERR_ codes
... to detect some situations where standard -errno is too generic.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-24 11:57:32 +02:00
Karel Zak ae5afe071f libmount: fix mount by pattern
mount /foo /bar

without entry in /etc/fstab the mount command tries all filesystems
from /{etc,proc}/filesystems. We should NOT call mount(2) more then
once if the syscall returns for example ENOENT, acceptable is only
EINVAL.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-24 11:52:04 +02:00
Petr Uzel 14e8be8ab3 lscpu: fix possibly undefined operation
With -Wall -Werror, compilation of lscpu.c fails with:

  Making all in sys-utils
  make[2]: Entering directory `/home/petr/upstream/util-linux/sys-utils'
  gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..  -include ../config.h -I../include -DLOCALEDIR=\"/usr/share/locale\"  -fsigned-char -Wall -Werror -MT lscpu.o -MD -MP -MF .deps/lscpu.Tpo -c -o lscpu.o lscpu.c
  lscpu.c: In function ‘print_parsable’:
  lscpu.c:971:7: error: operation on ‘p’ may be undefined [-Werror=sequence-point]
  cc1: all warnings being treated as errors

Fix by splitting the pointer increment to separate statement.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-04-23 14:05:29 +02:00
Petr Uzel 4f83dcceba libblkid: befs: declare functions static
Since commit 0b0c231f64
(swapon: move generic code to swapon-common.c), if util-linux is
configured with --enable-static --disable-shared --enable-libmount-mount
options, the build fails with the following error:

  ...
  libtool: link: gcc -std=gnu99 -fsigned-char -ggdb -O1 -Wall -D_FORTIFY_SOURCE=2 -o switch_root switch_root.o
  /home/petr/upstream/util-linux/libblkid/src/.libs/libblkid.a(befs.o): In function `get_uuid':
  /home/petr/upstream/util-linux/libblkid/src/superblocks/befs.c:333: multiple definition of `get_uuid'
  swapon-swapon-common.o:/home/petr/upstream/util-linux/sys-utils/swapon-common.c:99: first defined here
  collect2: ld returned 1 exit status
  /bin/sh ../libtool  --tag=CC   --mode=link gcc -std=gnu99 -fsigned-char -ggdb -O1 -Wall -D_FORTIFY_SOURCE=2   -o flock flock.o strutils.o
  libtool: link: gcc -std=gnu99 -fsigned-char -ggdb -O1 -Wall -D_FORTIFY_SOURCE=2 -o pivot_root pivot_root.o
  make[2]: *** [swapon] Error 1
  make[2]: *** Waiting for unfinished jobs....
  /home/petr/upstream/util-linux/libblkid/src/.libs/libblkid.a(befs.o): In function `get_uuid':
  /home/petr/upstream/util-linux/libblkid/src/superblocks/befs.c:333: multiple definition of `get_uuid'
  swapoff-swapon-common.o:/home/petr/upstream/util-linux/sys-utils/swapon-common.c:99: first defined here

Fix by declaring befs funcitons static.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-04-23 14:05:25 +02:00
Dave Reisner 82815995f0 sys-utils: avoid duplicate reference to fstab.5
This is no longer in sys-utils/ anyways, and its unconditionally
distributed by an earlier dist_man_MANS declare in the Makefile.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-23 14:03:12 +02:00
Karel Zak 5759de0c3c login: use get_fd_tabsize()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-23 14:00:29 +02:00
Karel Zak 94988fc902 libuuid: use get_fd_tabsize()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-23 14:00:18 +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
chas williams - CONTRACTOR 1061081619 login: use getdtablesize() correctly in login.c
getdtablesize() is the number of descriptors and since decriptors start
at 0, its value isnt the largest descriptors possible.  One should use
getdtablesize() - 1 instead.

Signed-off-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
2012-04-23 13:33:00 +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
Davidlohr Bueso 8d95e4ee61 fdisk: simplify device opening
This patch makes fdisk open(2) the device in only one place (get_boot), instead
of having to depend on user input (ie: listing -l).

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 13:07:16 +02:00
Davidlohr Bueso f45121dd46 fdisk: remove action enum
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 13:00:00 +02:00
Davidlohr Bueso 3813eb5ead fdisk: do not call sgi and sun code when creating a new dos label
When creating a new DOS label, SGI and SUN pt logic have no business being
there. Remove sun/sgi_nolabel(), since the default amount of partitions are
previously set to 4 and the sun/sgi magic nums are not used in this context.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 12:55:52 +02:00
Bernhard Voelker 13716cf306 sfdisk: improve F_MEGABYTE header
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-04-23 12:45:25 +02:00
Davidlohr Bueso 68c5a7ea7f fdisk: remove dead code
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 12:40:20 +02:00
Davidlohr Bueso c867a8e3b3 fdisk: kernel/bios sectors and heads need not be global
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 12:38:22 +02:00
Davidlohr Bueso a2482eb3d9 fdisk: standarize version output
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 12:15:15 +02:00
Davidlohr Bueso 9912f01b68 fdisk: make CHS user values more robust
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 12:12:32 +02:00
Davidlohr Bueso 3f1789ce5d prlimit: remove bogus instructions
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 12:05:25 +02:00
Sami Kerola 9146de0266 eject: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-23 12:02:07 +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
Karel Zak 89394013f6 namei: fix relative symlinks evaluation
Fedora 17 (/bin is symlink to /usr/bin):

	[root@intel ~]# /bin/namei /bin/namei
	f: /bin/namei
	 d /
	 l bin -> usr/bin
	usr - No such file or directory

Reported-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-20 15:06:57 +02:00
Karel Zak 3e90c89f95 docs: move fstab.5 to sys-utils (mount/ dir is deprecated)
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:48:40 +02:00
Karel Zak 9f9d0f21c4 swapon: add support for PARTUUID= and PARTLABEL=
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:40:22 +02:00
Karel Zak eb0eb262cb mount: (new) add support for PARTUUID= and PARTLABEL=
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:40:06 +02:00
Karel Zak aa0903e06b lsblk: add support for PARTUUID= and PARTLABEL=
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:39:44 +02:00
Karel Zak 090b5e84b2 findmnt: add support for PARTUUID= and PARTLABEL=
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:38:53 +02:00
Karel Zak 10b4d34dc0 blkid: add docs about PARTUUID= and PARTLABEL=
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:34:29 +02:00
Karel Zak cff632afc9 libmount: add support for PARTUUID= and PARTLABEL=
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:33:59 +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 21d1fa53f1 tests: tiny change in output header
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 13:14:43 +02:00
Karel Zak f947ae75b6 tests: remove LD_LIBRARY_PATH from swapon tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 13:05:55 +02:00
Karel Zak d335c9bd54 swapon: minor coding style changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 12:58:15 +02:00
Karel Zak 8b0d534155 swapon: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 12:52:13 +02:00
Karel Zak d9f07b100d swapon: cleanup main()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 12:44:14 +02:00
Karel Zak 7cf6a65476 swapoff: cleanup usage() and includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 12:38:03 +02:00
Karel Zak d5360e9250 mount: fix man page typo s/reatime/relatime/
Reported-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 12:25:28 +02:00