Commit Graph

4429 Commits

Author SHA1 Message Date
Dave Reisner bf91904c24 libmount: avoid infinite loop in child fs iteration
In early userspace, the rootfs is mounted with itself as its parent.
Example /proc/self/mountinfo:

1 1 0:1 / / rw - rootfs rootfs rw
14 1 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
15 1 0:13 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sys rw
16 1 0:5 / /dev rw,nosuid,relatime - devtmpfs dev rw,size=506956k
17 1 0:14 / /run rw,nosuid,nodev,relatime - tmpfs run rw,mode=755

This causes an infinite loop in mnt_table_next_child_fs, and is
evidenced by a crash via infinite recursion in findmnt. Simply catch the
condition where the ID of the parent is the ID of the current fs we're
examining and skip over it to the next mount in the table.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-08 16:06:02 +01:00
Karel Zak 7c9c872c2b lsblk: escape unsafe chars in parsable output
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-08 16:04:45 +01:00
Karel Zak a17f32645d script: play well with csh when invoked from within /etc/csh.login
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=797888
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-08 16:02:28 +01:00
Christian Wiese 90e57677a5 fdisk: fix to build for IA32
Tested architectures:
- i486 using gcc -march=i486
- i586 using gcc -march=pentium-mmx
- i686 using gcc -march={pentiumpro,pentium2,pentium3,pentium-m,pentium4}

Without this fix building fdisk fails for for all tested arch/cpu types
emiting following error:
------------------------------------------------------------------------------
In file included from fdiskbsdlabel.c:62:0:
fdiskbsdlabel.h:61:2: error: #error unknown architecture
fdiskbsdlabel.c: In function 'bselect':
fdiskbsdlabel.c:180:44: error: 'BSD_LABELSECTOR' undeclared (first use in this function)
fdiskbsdlabel.c:180:44: note: each undeclared identifier is reported only once for each function it appears in
fdiskbsdlabel.c: In function 'xbsd_write_bootstrap':
fdiskbsdlabel.c:539:24: error: 'BSD_LABELSECTOR' undeclared (first use in this function)
fdiskbsdlabel.c: In function 'xbsd_readlabel':
fdiskbsdlabel.c:744:28: error: 'BSD_LABELSECTOR' undeclared (first use in this function)
fdiskbsdlabel.c:744:60: error: 'BSD_LABELOFFSET' undeclared (first use in this function)
fdiskbsdlabel.c: In function 'xbsd_writelabel':
fdiskbsdlabel.c:769:32: error: 'BSD_LABELSECTOR' undeclared (first use in this function)
fdiskbsdlabel.c:780:61: error: 'BSD_LABELOFFSET' undeclared (first use in this function)
make[2]: *** [fdisk-fdiskbsdlabel.o] Error 1
------------------------------------------------------------------------------

This fix was tested with following major toolchain components:

binutils 2.21.53.0.2
gcc 4.6.2
glibc 2.14.1
2012-03-07 20:33:24 +01:00
Karel Zak 540d506f71 lsblk: use readlink_at from at.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-07 14:28:52 +01:00
Peter Rajnoha 09a71aa1d5 lsblk: add inverse tree support (-s)
$ lsblk --inverse -o NAME /dev/dm-0
NAME
luks-10d813de-fa82-4f67-a86c-23d5d0e7c30e (dm-0)
└─sda6
  └─sda

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-07 13:54:11 +01:00
Karel Zak 205eb00283 lsblk: remove (dm-N) from NAME for raw/pair output format
$ lsblk -P -o NAME /dev/dm-0
 NAME="luks-10d813de-fa82-4f67-a86c-23d5d0e7c30e (dm-0)"

the (dm-0) sucks in the parsable output...

Reported-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-07 13:11:54 +01:00
Karel Zak 379e84390a libmount: cleanup flags usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-07 10:45:48 +01:00
Davidlohr Bueso 74fa8244de lslocks: add TYPE column
By knowing the lock's type (flock or posix), the user can have more
information about the lock and how it was created.

[kzak@redhat.com: - rename PERSONALITY to TYPE,
                  - rename ACCESS to MODE]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-06 17:07:40 +01:00
Karel Zak c6fd71b6bb tests: add lslocks to build-sys tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-06 12:17:05 +01:00
Karel Zak a807750932 login: minor spelling fixes
Reported-by: Elan Ruusamäe <glen@delfi.ee>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-06 11:38:51 +01:00
Elan Ruusamäe 466a826729 login: minor spelling fixes
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-06 11:32:37 +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
Karel Zak 2f595c001b login: fix LOGIN_CHOWN_VCS code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-05 16:48:38 +01:00
Karel Zak e9c2b9c5ee tests: search for "none" by findmnt
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-02 15:59:10 +01:00
Karel Zak 6699e742f2 libmount: add mnt_fs_streq_target() and export all mnt_fs_streq_*
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-02 15:53:55 +01:00
Karel Zak dab3357387 blkid: add DEVNAME= to export output format
Reported-by: Balamurugan Arumugam <barumuga@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-02 14:05:26 +01:00
Karel Zak fc6b879105 tests: wait a moment between mount and umount
It seems that without sleep between mount and umount are the test
unstable, because kernel is not able to provide updated
/proc/self/mountinfo so quickly (really?).

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-02 13:33:46 +01:00
Karel Zak ab8c6e0569 libmount: add mnt_fs_streq_srcpath()
We have to be careful with "none" or another dummy sources for pseudo
filesystems. These strings should be canonicalized or compared as a
paths.

The function is not exported by library API.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-02 13:29:39 +01:00
Karel Zak 41d6af28c3 libmount: cosmetic changes around "none"
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-02 11:23:34 +01:00
Karel Zak 14ee7c0cb1 tests: update libmount tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-02 09:57:49 +01:00
Dave Reisner d0ce7c07e6 libmount: don't treat "none" differently
This causes more problems than it solves. In the latest edition:

  # mount -t proc none foo
  mount: foo: mount failed: Invalid argument

A check for source and target fails in mnt_context_apply_fstab()
because, even though they were indeed specified on the cmdline,
__mnt_fs_set_source_ptr() altered this and NULL'd out the source.

If you're able to mount this device via other means, other tools start
reporting oddities, such as mount's output:

  (null) on /foo type proc (rw,relatime)

or findmnt:

  TARGET      SOURCE FSTYPE OPTIONS
  /foo               proc   rw,relatime

Simply treat "none" like any other source when passed in.

[kzak@redhat.com: - don't translate NULL to "none" in mnt_fs_set_source()]

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-02 09:48:23 +01:00
Dave Reisner eac83fbcf6 mountpoint: account for error from in mnt_fs_get_target
commit 04f087ec didn't take into consideration that mnt_fs_get_target()
could return an error, and would therefore show false positives, such
as:

$ mkdir foo; mountpoint foo
foo is a mountpoint

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-02 09:42:18 +01:00
Karel Zak 86ace3f407 wipefs: always print devname
It seems too smart to print devname according to number of devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-01 15:44:04 +01:00
Milan Broz c10695f8a4 wipefs: support more device arguments for wipefs
[kzak@redhat.com: - print devname only if more devices specified]

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-01 15:36:45 +01:00
Milan Broz 0fd93af697 wipefs: add quiet flag (-q)
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-01 15:24:05 +01:00
Karel Zak 89d39d2217 libblkid: properly reset chain in probe_do_wipe()
The command wipefs is not able to remove all signatures from the
device if the first detected signature is linux raid. The another
superblock signatures are ignored. For example:

  # pvcreate /dev/sdb1
  # mdadm --create md8 --metadata=0.90 --chunk=64 --level=0 \
        --raid-devices=2 /dev/sdb1 /dev/sdb2

  # wipefs -a /dev/sdb1

will delete the linux raid signature only.

Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-01 14:24:04 +01:00
Karel Zak ee99c9cb37 tests: add tests for mount --make-* stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-01 12:30:14 +01:00
Zhi Li 04f087eced mountpoint: fix a minor bug with 0:0 devno
zhi@debian-lizhi:~$ mountpoint /sys
/sys is not a mountpoint
zhi@debian-lizhi:~$

The problem is in mountpoint.c, function dir_to_device(), which uses 0 as an
error return value, but for sysfs 0 is its device number:

zhi@debian-lizhi:~$ cat /proc/self/mountinfo
14 19 0:0 / /sys rw,nosuid,nodev,noexec,relatime - sysfs none rw
15 19 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc none rw

My change is on dir_to_device, seperating device number from return value.

Signed-off-by: Zhi Li <lizhi1215@gmail.com>
2012-02-29 14:53:31 +01:00
Karel Zak c4137d397c lslocks: add --notruncate, minor fixes in man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-29 14:26:46 +01:00
Davidlohr Bueso 4473c8dc8a lslocks: add lslocks.8 man page
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-29 14:15:01 +01:00
Davidlohr Bueso 3dc02ef408 lslocks: new command
The new lslocks(8) program is meant to replace the deprecated lslk(8). It is
designed for simplicity and removes unnecessary Unix legacy outputs and
options:

- Don't output inode number, whence and maj:min device numbers.
- Don't provide nonblocking syscall options stat(2) and readlink(2)
- Remove lslk's alternate default kernel name list file path (-k)

The option to use nonblocking calls was previously intended for NFS partitions;
however this should be transparent to utility programs considering that
timeouts can occur generically (fuse - sshfs, NFS, netdevs, etc).

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-29 14:08:11 +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
Karel Zak dda92fe093 build-sys: s/ruman/ruman1/
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-28 18:11:23 +01:00
Sami Kerola 7aa8bdb50e docs: do not overwrite ddate.1 manual
The following warning meant either english manual page overwrote ru
version, or otherway around.  Neither way that not intented.  This
patch will change ru version of the manual page to be installed to
<prefix><mandir>/ru/man1 directory.

man/ru/Makefile.am:4: warning: mandir was already defined in condition TRUE, which includes condition BUILD_DDATE ...
configure.ac:1: ... `mandir' previously defined here

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-28 15:41:32 +01:00
Raghavendra D Prabhu 50d0ad9875 mount: (new) add 'internal-only(i)' to non-root allowed options
Commit ce433404 introduced the change, which causes something like mount -i
<user-mount-path> to break which worked well before util-linux-2.21, now it
gives message 'mount: only root can use "--internal-only" option' when that
shouldn't be the case when it is already in fstab.

Signed-off-by: Raghavendra D Prabhu <rprabhu@wnohang.net>
2012-02-28 15:37:29 +01:00
Sebastian Andrzej Siewior b420e27969 build-sys: add a crosscompile path for scanf_cv_alloc_modifier
This allows to building the package cross again. Since the return value
is not used I guess there is little loss.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
2012-02-28 15:03:04 +01:00
Karel Zak 4210c47adc tests: make output and diff dirs usage more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-28 14:37:45 +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
Sami Kerola 9fbc2dffb0 build-sys: remove unused function and header checks
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-28 13:21:11 +01:00
Karel Zak 607e6b7ce8 login: support crazy shadow-utils syntax in login.defs
standard syntax for FOO=data:

	ENV_FOO   data

additional syntax:

	ENV_FOO  FOO=data

Reported-by: Colin Guthrie colin@mageia.org
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-28 11:16:16 +01:00
Karel Zak 7dc2009633 test: test 'none' source for mount(8)
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-28 00:21:48 +01:00
Karel Zak 772cce373f libmount: allow empty source for mount(2) syscall
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=797438
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-28 00:02:30 +01:00
Karel Zak 9bf9690114 libmount: use mount.<type> -s for NFS only
Unfortunately, it seems that for example mount.cifs don't care about
the API, so we need exception like the original mount(8).

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-27 16:44:38 +01:00
Karel Zak 16b73aae8c mount: (new) cleanup mount -a return codes
New return codes:

  0 : all mounted (or all ignored)
 64 : some mounted, some failed
 32 : all failed

Note that already mounted or ignored (filtered out by -t or -O)
filesystems don't affect the final return code.

The original mount(8) returns 0 instead of 64, so the situation
"some mounted, some failed" cannot be detected.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-24 23:17:06 +01:00
Karel Zak 6eba938376 libmount: canonicalize targets from fstab on mount -a
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-24 22:52:45 +01:00
Karel Zak ea371ea30e libmount: optimize for paths with tailing slash
mnt_table_find_target() canonicalizes paths by libmnt cache, but it's
overkill if the difference between paths is tailing slash only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-24 21:30:22 +01:00
Karel Zak 28074a0952 lib/canonicalize: always remove tailing slash
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-24 21:26:11 +01:00
Karel Zak 8a0f727bf2 tests: test non-canonical paths in fstab
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-24 21:13:44 +01:00
Karel Zak 59e32a1f24 libmount: canonicalize all paths from (fs)tab
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=797216
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-24 20:25:43 +01:00