Commit graph

6464 commits

Author SHA1 Message Date
Karel Zak
e0688353db tests: add umount --all-targets tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-26 14:59:07 +01:00
Karel Zak
4eb49f6392 umount: add --all-targets
The same source (whole filesystem or filesystems subvolume) could be
mounted on more targets (mountpoints). For example bind mounts or
btrfs sub-volumes.

If you want to detach the source device from the system then you need
to unmount all the mountpoints.

 umount --all-targets <device|mountpoint>

provides this functionality. This option could be used together with
--recursive. Then all nested mountpoints within the filesystem are
unmounted too. For example:

 umount --recursive --all-targets /dev/sdb1

should be a way how to make the device unmounted at all.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-26 14:50:26 +01:00
Karel Zak
6506a86601 libmount: export umount mountpoint look up code
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-26 14:19:05 +01:00
Karel Zak
2b90c471de libmount: don't prepare update for empty mtab/utab on umount
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-26 14:17:42 +01:00
Karel Zak
dad88cb357 libmount: optimize tab files parsing
- ignore empty files
 - ignore empty tables

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-26 14:16:53 +01:00
Karel Zak
fd2b0ce5d7 umount: improve --recursive docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-25 11:17:27 +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
William Pitcock
51924a4ef0 add missing rpmatch.h everywhere it needs to be
Signed-off-by: William Pitcock <nenolod@dereferenced.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-20 13:04:02 +01:00
Karel Zak
a4dc853a4d libblkid: add debug messages for "idmag" stuff and btrfs
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-20 10:43:30 +01:00
Karel Zak
6c4581b695 libblkid: make backup superblock visible for wipefs(8) only
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-19 15:51:51 +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
Karel Zak
9148b9bb47 libblkid: add blkid_probe_step_back to documentation
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-19 13:12:31 +01:00
Karel Zak
583120378d libblkid: return disk ID/UUID by PT binary interface
Add blkid_parttable_get_id() function.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-19 13:09:48 +01:00
Karel Zak
e346233ea2 findmnt: allow to read (PART)UUID/LABEL from udev DB
Currently findmnt uses libmount to get filesystem properties (and
libmount uses libblkid). This works as expected, but root permissions
are required to read the tags from the devices.

It seems better to read the information from udev db and use libblkid
as fallback solution only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 15:00:57 +01:00
Karel Zak
d44e3391b7 lsblk: resuse udev handler
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 13:37:00 +01:00
Karel Zak
36fb10074c docs: add missing information about -o +<list>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 13:30:00 +01:00
Karel Zak
e68948e146 lslocks: support -o +<list> convention
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 13:21:42 +01:00
Karel Zak
7badb909e2 lslocks: add BLOCKER column
BLOCKER -  PID of the process blocking the lock

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 13:12:01 +01:00
Karel Zak
45b6445fe1 libmount: fix a mem leak
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 12:59:33 +01:00
Karel Zak
6bf463c54c fsck.cramfs: add dummy -a -y for compatibility
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 12:18:29 +01:00
Karel Zak
55c0d16bab lslocks: detect blocked locks, fix /proc/locks parser
$ flock foo -c "sleep 100" & flock foo -c "sleep 100"

old version:
  $ lslocks
  lslocks: failed to parse pid: 'WRITE'

new version:

COMMAND           PID  TYPE  SIZE MODE   M      START        END PATH
[...]
flock            1318 FLOCK    0B WRITE* 0          0          0 /home/projects/
flock            1319 FLOCK    0B WRITE  0          0          0 /home/projects/

 The asterisk (e.g. WRITE*) is used for blocked processes.

Reported-by: Mantas Mikulenas <grawity@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 16:29:51 +01:00
Karel Zak
07c916cfdd lslocks: use libmount to parse mountinfo
old version:
	$ strace -e open lslocks 2>&1 | grep mountinfo | wc -l
	118

new version:
	strace -e open ./lslocks 2>&1 | grep mountinfo | wc -l
	1

Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 15:59:28 +01:00
Karel Zak
39edf68139 mountpoint: don't hardcode paths
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 15:46:06 +01:00
Karel Zak
eff79ceb0b lscpu: don't read cpuid on non-live systems
Reported-by: Luis Aranguren <pizzaman@hotmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 15:38:08 +01:00
Zbigniew Jędrzejewski-Szmek
1e3832bfd1 nsenter: fix errors in manpage
- spell abbreviations with capital letters
- fix the names of a few options and files

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2013-02-14 14:43:49 +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
Karel Zak
4127f053ba libblkid: read whole buffer for iso_volume_descriptor
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 13:56:34 +01:00
Zeeshan Ali (Khattak)
8053b51c76 libblkid: Probe UDF volumes for ISO9660 info as well
I have seen blkid failing to report any meaningful data on some of UDF
volumes I have (Windows installer media):

$ ./blkid -p -o udev en_windows_7_professional_with_sp1_x64_dvd_u_676939.iso
ID_FS_LABEL=UDF_Volume
ID_FS_LABEL_ENC=UDF\x20Volume
ID_FS_TYPE=udf

Also, once my patches to expose more of ISO9660 info get merged, we'd
also need the same info to be exposed for UDF volumes.

This patch adds ISO9660 probing to UDF volumes and here is the result I
see on my example UDF volume (together with my pending patch to expose
more ISO9660 information):

$ ./blkid -p -o udev en_windows_7_professional_with_sp1_x64_dvd_u_676939.iso
ID_FS_PUBLISHER_ID=MICROSOFT CORPORATION
ID_FS_APPLICATION_ID=CDIMAGE 2.54 (01/01/2005 TM)
ID_FS_UUID=2011-04-12-02-38-58-00
ID_FS_UUID_ENC=2011-04-12-02-38-58-00
ID_FS_BOOT_SYSTEM_ID=EL TORITO SPECIFICATION
ID_FS_LABEL=GSP1RMCPRXFRER_EN_DVD
ID_FS_LABEL_ENC=GSP1RMCPRXFRER_EN_DVD
ID_FS_TYPE=iso9660

$ ./blkid -p -o udev en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso
ID_FS_PUBLISHER_ID=MICROSOFT CORPORATION
ID_FS_APPLICATION_ID=CDIMAGE 2.52 (03/09/2004 TM)
ID_FS_UUID=2008-04-14-12-00-00-00
ID_FS_UUID_ENC=2008-04-14-12-00-00-00
ID_FS_BOOT_SYSTEM_ID=EL TORITO SPECIFICATION
ID_FS_LABEL=GRTMPFPP_EN
ID_FS_LABEL_ENC=GRTMPFPP_EN
ID_FS_TYPE=iso9660

Before anyone asks, Yes! The UDF media I have is all legal and downloaded
directly from MSDN. :)

[kzak@redhat.com: - read LABEL from UDF only if not found anything
                    useful in ISO9660]

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 13:38:37 +01:00
Zeeshan Ali (Khattak)
fafe46bc26 libblkid: Expose more ISO9660 headers
In order to kill libosinfo's infamous udev rule[1], we need to make blkid
report the following information as udev properties on IS09660 media so
that libosinfo can make use of that for detection:

1. Volume ID (already exposed as label).
2. System ID.
3. Publisher ID.
4. Application ID.
5. Boot record's boot system ID, (almost always 'EL TORITO
   SPECIFICATION' if boot record is present).

Example use:

$ blkid -p -o udev Fedora-17-x86_64-DVD.iso
ID_FS_SYSTEM_ID=LINUX
ID_FS_APPLICATION_ID=GENISOIMAGE ISO 9660/HFS FILESYSTEM CREATOR (C)
1993 E.YOUNGDALE
ID_FS_UUID=2012-05-22-20-55-32-00
ID_FS_UUID_ENC=2012-05-22-20-55-32-00
ID_FS_BOOT_SYSTEM_ID=EL TORITO SPECIFICATION
ID_FS_LABEL=Fedora_17_x86_64
ID_FS_LABEL_ENC=Fedora\x2017\x20x86_64
ID_FS_TYPE=iso9660
ID_PART_TABLE_TYPE=dos

[1] https://fedorahosted.org/libosinfo/ticket/1

[kzak@redhat.com: - add blkid_ltrim_whitespace() and use it together
                    with blkid_rtrim_whitespace() to trim white spaces
                  - enlarge blkid values to 128 bytes
                  - add generic blkid_probe_set_id_label() function
                  - always terminate all _ID with \0
                  - don't export the _IDs to blkid cache]

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 12:11:34 +01:00
Zeeshan Ali (Khattak)
fbafb98c50 libblkid: Don't keep reading same sector of ISO
We were reading the same sector over and over again when parsing ISO9660.
This patches fixes it.
2013-02-14 10:54:27 +01:00
Sami Kerola
5564a8c77f build-sys: add package url to AC_INIT
See last line from './configure --help'.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-14 10:11:21 +01:00
Sami Kerola
eaf701984d build-sys: use AC_USE_SYSTEM_EXTENSIONS
The AC_GNU_SOURCE is obsolete.

Addresses: http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Obsolete-Macros.html#index-AC_005fGNU_005fSOURCE-2058
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-14 10:11:17 +01:00
Sami Kerola
d6abf1685d build-sys: use AC_COMPILE_IFELSE
The AC_TRY_COMPILE is obsolete.

Addresses: http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Obsolete-Macros.html#index-AC_005fTRY_005fCOMPILE-2203
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-14 10:11:13 +01:00
Karel Zak
190b5ee3d2 libmount: add missing MNT_ERR_AMBIFS
Sorry, the last commit into libmount has been incomplete.

Reported-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 09:20:30 +01:00
Richard Weinberger
07de470e43 switch_root: Add a sanity check
As switch_root basically does rm -Rf / we should make sure
that / is really an initramfs.

Signed-off-by: Richard Weinberger <richard@nod.at>
2013-02-13 14:55:30 +01:00
Karel Zak
456857a49a build-sys: add config-gen.d stuff for chsh-chfn
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-13 13:49:05 +01:00
Karel Zak
d86918b6eb chsh-chfn: fix bugs, improve compilation
* rename --disable-require-password to --disable-chsh-chfn-password

 * is_local() is really unnecessary when linked with libuser

 * fix set_value_libuser() returns codes

 * fix chfn.c, there is no 'pw', but oldf.pw

 * don't link with PAM when--disable-chsh-chfn-password

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-13 13:44:34 +01:00
Karel Zak
82a2c1600d libmount: correctly propagate ambivalent blkid probing results
libmount ignores "ambivalent probing result" from libblkid and tries
filesystems /etc/filesystems. This is incorrect behavior.

Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-13 12:36:10 +01:00
Cody Maloney
8c24b6aa2c chfn: Add libuser support
Signed-off-by: Cody Maloney <cmaloney@theoreticalchaos.com>
2013-02-13 09:39:12 +01:00
Cody Maloney
6adb1ef279 chsh: Add libuser support
This is based directly on lchsh which is a part of libuser. libuser.{c,h}
exist because exactly the same code is needed for both chsh and chfn.

[kzak@redhat.com: cleanup err() usage]

Signed-off-by: Cody Maloney <cmaloney@theoreticalchaos.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-13 09:37:15 +01:00
Cody Maloney
d91ad6ab3c chsh-chfn: Move pam auth to its own function, factoring out common code
This makes it easier to add support for libuser, which needs the same PAM
authentication. Also removes duplicate code between chsh and chfn.

Signed-off-by: Cody Maloney <cmaloney@theoreticalchaos.com>
2013-02-13 09:28:33 +01:00
Cody Maloney
7e4714f22b build-sys: Add flag for enabling/disabling libuser support.
Signed-off-by: Cody Maloney <cmaloney@theoreticalchaos.com>
2013-02-13 09:17:34 +01:00
Karel Zak
b8f2d06ed7 libmount: tags does not start with '/'
References: https://bugzilla.redhat.com/show_bug.cgi?id=909866
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-11 16:53:11 +01:00
Karel Zak
de78b56461 libblkid: add missing le16_to_cpu to sil raid prober
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-07 10:47:32 +01:00
Karel Zak
165bea4b10 libblkid: improve Silicon RAID prober
* count checksum from superblock
 * new (correct) superblock definition from dmraid

Reported-by: Frank Hirtz <fhirtz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-07 10:34:49 +01:00
Karel Zak
6e650f8895 libblkid: make blkid_new_probe_from_filename() usable on whole-disk
This is stupid bug, when libblkid probe for partition table on
whole-disk device with old 0.90 Linux RAID then it creates clone of
the struct blkid_probe to avoid collisions with the original probing
setting.

If the cloned prober is unnecessary then it's deallocated by
blkid_free_probe() ... and this function also closes the file
descriptor if the device has been opened by blkid_new_probe_from_filename().

Fortunately we usually use open() + blkid_probe_set_device(), ...
except wipefs(1).

Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-06 17:39:28 +01:00
Andy Lutomirski
db663995bd setpriv: Fix an error message typo
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
2013-02-06 12:32:17 +01:00
Alejandro Martinez Ruiz
d8036a902e tests: add f2fs image test
Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
2013-02-06 12:12:12 +01:00
Alejandro Martinez Ruiz
7dcfc89e30 libblkid: add Flash-Friendly File System (f2fs) support
This adds support for detecting Flash-Friendly File System (f2fs) to libblkid.
Based on work by Sven-Göran Bergh at http://www.mail-archive.com/busybox@busybox.net/msg17874.html

Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-06 12:08:14 +01:00
Cristian Rodríguez
075f4bfd34 build-sys: test for secure_getenv() too.
In current glibc versions, internal __secure_getenv
no longer exists and was replaced by secure_getenv()

Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
2013-02-06 12:03:22 +01:00