Commit Graph

166 Commits

Author SHA1 Message Date
Karel Zak f7f29b5640 libmount: save task ID for mountinfo tiles
Add new function mnt_fs_get_tid() to get task ID for the given filesystem.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-28 15:40:16 +02:00
Karel Zak 31a938ac38 build-sys: enable libmount and libblkid docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:50:54 +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 bc94024d08 build-sys: convert libmount/ to module
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 17:49:37 +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 23966912fb libmount: improve ifdef HAVE_LIBSELINUX stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-19 16:19:18 +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 9d670a2ab4 libmount: make some string operations more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 12:26:05 +02:00
Petr Uzel 3cbc5a9559 libmount: fix trivial typos
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-06-15 11:52:13 +02:00
Petr Uzel bf15afd1e7 libmount: fix read before allocated buffer
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>
2012-06-15 11:52:10 +02:00
Petr Uzel 31821efc29 libmount: plug a memory leak in exec_helper()
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>
2012-06-15 11:52:05 +02:00
Karel Zak e90e7401d0 libmount: don't use nosuid,noexec,nodev for cifs user=foo
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>
2012-06-14 14:19:26 +02:00
Karel Zak 6b741564d8 libmount: don't generate empty option strings
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>
2012-06-14 11:38:53 +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
Dave Reisner 5e7b834002 libmount: trim leading commas from each options string
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>
2012-06-05 15:40:11 +02:00
Bernhard Voelker 871ffd0960 Fix typos in comments and wall's man page
Culprits identified again by (newer) misspellings:

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

* wall: Fix typo in man page.
* Fix typos in source code comments.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-06-05 14:37:26 +02:00
Karel Zak 61f5ff6cb4 libmount: add MNT_ERR_MOUNTOPT
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-28 12:49:55 +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 dffdc98958 libmount: use stderr for initial debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-23 11:05:37 +02:00
Dave Reisner 7383ebceec libmount: Use binary search to compare pseudofs
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>
2012-05-23 09:56:51 +02:00
Karel Zak fa705b5441 libmount: don't canonicalize target
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>
2012-05-17 12:10:43 +02:00
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 cd3d6c5bd0 libmount: expose mnt_get_mountpoint as external API 2012-04-26 09:38:02 +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 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
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 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 5d451abbbf libmount: add mnt_context_get_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 10:06:35 +02:00
Karel Zak e01c731992 libmount: add mnt_context_fstab_applied()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-17 11:36:32 +02:00
Karel Zak ce4dd666f4 libmount: add support to parse /proc/swaps
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-03 13:20:32 +02:00
Karel Zak 7104bedb78 libmount: clean up MNT_FMT_* usage in parser
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-03 11:32:12 +02:00
Dong Hao c7b0af96bc mount: fix recursively propagation mounting
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>
2012-03-21 12:35:54 +01:00
Karel Zak ce22ccd08c libmount: improve mnt_tables_is_mounted
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-20 11:22:09 +01:00
Karel Zak 1e1df43ca2 libmount: add configfs to pseudofs list
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-20 10:42:47 +01:00
Karel Zak 7293e97a42 libmount: fix "already mounted" detection on systems with mtab
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>
2012-03-09 13:11:24 +01:00
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 379e84390a libmount: cleanup flags usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-07 10:45:48 +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 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
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
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
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 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