* '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]
valgrind --leak-check=full ./sys-utils/mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
....
==21359== Invalid read of size 1
==21359== at 0x415AC6: mnt_optstr_remove_option_at (optstr.c:310)
==21359== by 0x416358: mnt_optstr_apply_flags (optstr.c:716)
==21359== by 0x40DFBF: mnt_context_prepare_mount (context_mount.c:86)
==21359== by 0x40EB5A: mnt_context_mount (context_mount.c:782)
==21359== by 0x4058B0: main (mount.c:918)
==21359== Address 0x51cd5bf is 1 bytes before a block of size 10 alloc'd
==21359== at 0x4C297CD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359== by 0x4C29957: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359== by 0x415780: __mnt_optstr_append_option (optstr.c:188)
==21359== by 0x412822: mnt_fs_append_options (fs.c:764)
==21359== by 0x409288: mnt_context_append_options (context.c:733)
==21359== by 0x4053F0: main (mount.c:776)
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
valgrind --leak-check=full ./sys-utils/mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
....
==21359== 28 bytes in 1 blocks are definitely lost in loss record 1 of 1
==21359== at 0x4C298B2: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359== by 0x415780: __mnt_optstr_append_option (optstr.c:188)
==21359== by 0x415CB5: mnt_optstr_set_option (optstr.c:387)
==21359== by 0x40D778: do_mount (context_mount.c:192)
==21359== by 0x40E6A9: mnt_context_do_mount (context_mount.c:685)
==21359== by 0x40EB7B: mnt_context_mount (context_mount.c:786)
==21359== by 0x4058B0: main (mount.c:918)
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
is incorrectly translated to
mount.cifs -o noexec,nosuid,nodev,user=root,password=linux ...
The command mount(8) should be sensitive to "user" (without "=<name>")
only. The correct cifs command line is:
mount.cifs -o user=root,password=linux
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=766157
Signed-off-by: Karel Zak <kzak@redhat.com>
mount -t foo something /mnt/test -o user=root,password=linux
generates
"rw,noexec,nosuid,nodev,password=linux,,user=root"
options string for /sbin/mount.foo, the ",," is incorrect.
Signed-off-by: Karel Zak <kzak@redhat.com>
Fixes a bug in option string parsing wherein a line such as:
ro,relatime,,nosuid,nodev
Will be seen as only the tokens "ro" and "relatime" after the parser
encounters a zero length (and erroneously declared NULL) option.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
It's the responsibility of anyone adding to this list in the future to
ensure that the list remains sorted.
While we're at it, expand this list of known pseudofs types.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Note that mountpoint (target_ paths in /proc/mounts and /proc/self/mountinfo
are always canonicalized by kernel.
* for umount we don't have to canonicalize target
by default if the mountpoint is found in /proc/self/mountinfo
* in mnt_table_find_target() is unnecessary to canonicalize target paths
if the table of the filesystems is read from /proc/self/mountinfo
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=820707
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
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>
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>
Provide the recursive flag of propagation mounting. Recursive flag could
be used together with propagation flag.
[kzak@redhat.com: - add MS_SILENT to acceptable propagation flags,
- fix new code in libmount too]
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Dong Hao <haodong@linux.vnet.ibm.com>
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>
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>
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>
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>
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>
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>
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>
Since util-linux 2.12h (year 2004) there is only one flag for all
dummy options like _netdev or nofail. Unfortunately it means that when
mount(8) composes the final mount options string for mtab (or for
mount.<type> helpers) the string is generated incorrectly.
Reported-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
This function was never implemented, but the proto has existed since the
inception of the library. As the libmnt_table struct doesn't include a
member necessary to carry the name of the table, simply discard this
prototype. If ever a need to break ABI comes up, perhaps this could be
revisited.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
This patch add a new flag MNT_NOHLPS for mount options map, options
with this flag will not be passed to /sbin/mount.<type> helpers.
Signed-off-by: Karel Zak <kzak@redhat.com>
Why?
* read-only root
* /etc is pretty bad place for caches
* all is usually cached by udev in /dev/disk/by-* and libblkid
is able to use these symlinks
* boot persistent cache is attractive for very small subset of
Linux machines (and they already need extra udev tunning otherwise
udev will probe all block devices during boot)
* the default is possible to override in /etc/blkid.conf
The systems without /run directory will not be affected by this
change.
Signed-off-by: Karel Zak <kzak@redhat.com>
If you really need to store your configuration to a alternative files
then you have to explicitly specify the files or directories on
mount(8) command line by --fstab option.
Signed-off-by: Karel Zak <kzak@redhat.com>
mnt_table_parse_dir in libmount/src/tab_parse.c calls
scandir, and then opendir. When the latter one, opendir is failed,
buffers allocated in scandir are not released.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This patch is based on my last patch:
[PATCH 1/2] scandirat based mnt_table_parse_dir implementation
scandir* used in `mnt_table_parse_dir in libmount/src/tab_parse.c
can take filter function as an argument.
`mnt_table_parse_dir' picks up fstab files from namelist returned from
scandir* for itself. However, some parts of picking-up job can be done
in the filter function.
This patch introduces a new function `mnt_table_parse_dir_filter' to
share the code for picking-up job between two implementations of
`mnt_table_parse_dir_filter', scandir based and scandirat based.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
In comment of `mnt_table_parse_dir' of libmount/src/tab_parse.c:
/* TODO: it would be nice to have a scandir() implementation that
* is able to use already opened directory */
Nowadays glibc provides `scandirat'. This patch implements `scandirat'
based `mnt_table_parse_dir'.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Now we have three versions of the mount(8) utility
* old mount(8)
--enable-mount [default]
* old mount(8) linked with libmount
This is this is necessary for systems without mtab file.
--enable-libmount-mount
- new mount(8)
This is completely new pure-libmount based mount(8).
--enable-new-mount
Signed-off-by: Karel Zak <kzak@redhat.com>
Similar to the previous commit, when mounting a pseudofs, trust the
source of the fs, as it cannot be matched to backing device on the
filesystem.
Similar situation, but slightly different bug:
# mkdir /foo /root/foo
# echo 'foo /foo tmpfs defaults 0 0' >> /etc/fstab
# cd /root
# mount -a
# mount | grep /foo
/root/foo on /foo type tmpfs (rw,relatime)
This fixes the pure libmount based mount utility, but the legacy mount
tool will still fail to handle this properly.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
Since nodev FSs have no backing block device, it's unreasonable to try
and resolve the source back to a path on the filesystem. Always trust
the source of the FS given in /etc/fstab to avoid remounting the device
when a directory of the same name exists in the current working
directory.
Example reproduction:
# mkdir /foo
# echo 'foo /foo tmpfs defaults 0 0' >> /etc/fstab
# mount -a
# cd /root; mkdir foo
# mount -a
# mount | grep /foo
foo on /foo type tmpfs (rw,relatime)
/root/foo on /foo type tmpfs (rw,relatime)
[kzak@redhat.com: - use fs->flags to detect pseudo FS]
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
Examples:
* findmnt --fstab -O noauto
Returns all entries where is not "auto" option (including entries
with "noauto" option.
* findmnt --fstab -O +noauto
Returns all entries where is literally "noauto" option.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=758457
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
* 'docs-dir' of https://github.com/kerolasa/lelux-utiliteetit:
docs: remove duplicated text
docs: require kernel support before accepting use of it
docs: note about independent super block structs
docs: add libmount & libblkid debug instructions
Documentation: add debugging doc
arch: start using arch as a usage() example
docs: new file Documentation/release-schedule.txt
docs: move setuid information from reame to hwclock.8
docs: clean up old readme files
docs: copy contributors from legacy files to AUTHORS
docs: new file Documentation/howto-man-page.txt
docs: new file Documentation/source-code-management.txt
docs: new file Documentation/howto-contribute.txt
docs: new file Documentation/howto-compilation.txt
docs: tell what the Documentation/ is about
docs: add usage() howto for contributors
docs: Documentation directory added
docs: remove README.clear
Duplicate text is dealt by referring to license files. The `pg'
command does not need separated license file because the source
file has same text at top of it.
http://www.spinics.net/lists/util-linux-ng/msg05069.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Move readme, licence, change log, relese notes and other
supplementary files to a Documentation directory. This commit
does not change contents of any other but few Makefile.am files.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The path resolving function breaks when handling undefined sources
("none") used by pseudo-filesystems. The assertion is causing the
samples/mount program to abort:
dave@offbook:~/projects/util-linux-good/libmount/samples$ ./mount
/dev/sda3 on / type ext4 (rw,errors=remount-ro,commit=0)
proc on /proc type proc (rw,noexec,nosuid,nodev)
lt-mount: cache.c:464: mnt_resolve_path: Assertion `path' failed.
Aborted
/etc/mtab:
/dev/sda3 / ext4 rw,errors=remount-ro,commit=0 0 0
proc /proc proc rw,noexec,nosuid,nodev 0 0
none /sys sysfs rw,noexec,nosuid,nodev 0 0
fusectl /sys/fs/fuse/connections fusectl rw 0 0
none /sys/kernel/debug debugfs rw 0 0
...
Instead of this assert on NULL we can simply return NULL and let mnt_pretty_path do the work.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
tab_parse.c:mnt_parse_mountinfo_line parses "none" in src as NULL,
tab_update.c:fprintf_mtab_fs sets m1 to NULL instead of "none" and
returns -ENOMEM
tab_update.c:update_table says "write entry failed: Success", as errno
hasn't been set, and gotos to leave, leaving mtab not updated.
Addresses-debian-bug: 634871
Reported-by: Tomas Janousek <tomi@nomi.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
This is libmount based re-implementation of the mountpoint(1) command.
The original implementation is maintained in sysvinit suite.
The mountpoint(1) in util-linux is not enabled by default (for now) --
use --enable-mountpoint to enable the util.
Signed-off-by: Karel Zak <kzak@redhat.com>