Commit Graph

762 Commits

Author SHA1 Message Date
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
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
Sami Kerola 7cebf0bb4f docs: corrections to FSF license files, and postal address
The COPYING and Documentation/licenses/COPYING* files are being
replaced by files from GNU web site.

http://www.gnu.org/licenses/gpl-2.0.txt
http://www.gnu.org/licenses/lgpl-2.1.txt

Postal addresses to FSF in other files are updated to match with the
address in license files.

Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-24 14:13:35 +01:00
Karel Zak 94b0c44fb7 mount: distinguish between MS_COMMENT flags (netdev, nofail, ...)
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>
2012-02-23 15:16:17 +01:00
Karel Zak cad39614a6 libmount: clean up context docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-23 12:31:56 +01:00
Karel Zak 3fcf5e1b79 docs: update copyright years
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-22 13:07:14 +01:00
Karel Zak ee3140752f libmount: cleanup docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-22 13:02:17 +01:00
Dave Reisner a33df88c45 libmount: remove teaser proto for mnt_table_get_name
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>
2012-02-22 11:52:44 +01:00
Karel Zak 178537eda9 libmount: use #ifdef fr selinux specific variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-03 12:35:36 +01:00
Karel Zak a9ddf316c8 libmount: don't ignore chmod/own errors
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-02 14:39:02 +01:00
Karel Zak 383e7a2720 libmount: remove dead assigment
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-02 14:27:48 +01:00
Karel Zak 2af0a8390d libmount: consolidate sysconf() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-31 14:31:09 +01:00
Karel Zak 0113a20e93 libmount: make iter reset more robust [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-30 23:55:26 +01:00
Karel Zak 801401447b libmount: fix resource leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-30 23:38:18 +01:00
Karel Zak 4f69189fe7 libmount: fix resource leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-30 23:27:23 +01:00
Karel Zak ff7eba4d5e libmount: fix possible null dereferencing [coverity scan]
... let's keep Coverity analyzer happy.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-30 23:22:53 +01:00
Karel Zak b47b7b3afb libmount: fix negative returns [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-30 23:17:53 +01:00
Karel Zak 314f252226 libmount: fix checked-return [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-30 23:17:47 +01:00
Karel Zak d89670b515 libmount: fix context test logic
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-26 15:01:01 +01:00
Karel Zak 9bf51834fd libmount: fix leak in tabdiff test
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-26 14:47:48 +01:00
Karel Zak 53d911347d libmount: fix leak in tab parsing error code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-26 14:42:35 +01:00
Karel Zak 8dece03615 libmount: fix leak in tab_update.c test 2012-01-26 14:28:08 +01:00
Karel Zak 258ca2b241 libmount: fix buffer overflow and leaks in tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-26 14:17:28 +01:00
Karel Zak 5810d87097 libmount: don't pass comments=/x-* to mount.<type> helpers
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>
2012-01-25 17:14:24 +01:00
Karel Zak b82590ad46 blkid: move cache to /run on new systems
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>
2012-01-25 13:20:37 +01:00
Karel Zak 9354fea342 libmount: remove fstab.d support
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>
2012-01-24 11:16:53 +01:00
Karel Zak 52f8362841 libmount: support dirs for mnt_table_parse_fstab(), add mnt_table_parse_dir()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-23 20:20:36 +01:00
Masatake YAMATO b28890b041 libmount: fix a potential memory leak at mnt_table_parse_dir
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>
2012-01-23 13:54:03 +01:00
Masatake YAMATO 9deeef8e47 libmount: Use filter arg of scandir* to pickup /etc/fstab.d/*.fstab files
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>
2012-01-23 13:53:40 +01:00
Masatake YAMATO 485a8bfa98 libmount: scandirat based mnt_table_parse_dir implementation
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>
2012-01-23 13:52:51 +01:00
Karel Zak df51de6b37 libmount: export info about library features
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-23 12:27:01 +01:00
Karel Zak 0208ae2e0c libmount: fix bugs detected by [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-17 17:16:57 +01:00
Karel Zak b2ddfb59c1 libmount: fix compiler warnings [-Wuninitialized -Wformat]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-17 16:33:19 +01:00
Karel Zak 94283c9a77 libmount: fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-17 16:31:45 +01:00
Karel Zak c1f3576e0a libmount: ignore "defaults" mount option
... thanks to regression test!

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-17 16:12:04 +01:00
Karel Zak 374fd21add libmount: add MNT_OMODE_NOTAB
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-16 14:35:10 +01:00
Karel Zak 98b1302ecf libmount: cleanup post-umount operations
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-16 13:15:01 +01:00
Karel Zak 07a67e6805 libmount: fix MS_BIND|MS_REC usage, improve some bitwise operations
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-16 12:29:27 +01:00
Karel Zak f9906424d4 libmount: add post-mount checks to detect ro/rw
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-16 12:09:36 +01:00
Karel Zak 8b470b20d7 libmount: avoid duplicate loopdevs
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-16 11:28:05 +01:00
Karel Zak dc4dbbf188 libmount: allow to toggle ro/rw and mount again
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-13 16:27:50 +01:00
Karel Zak be3df3838a libmount: allow to use UUID and LABEL for owner/group mount options in fstab
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-13 14:37:09 +01:00
Karel Zak 8ab6accf01 libmount: add functions to export syscall/helpers status
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-13 13:01:18 +01:00
Karel Zak c851223602 libmount: fix auto-loopdev
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-12 21:51:00 +01:00
Karel Zak a10d6ad6f4 libmount: support umount /path/file.img
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-12 21:30:58 +01:00
Karel Zak 1e8c936978 libmount: make options in fstab optional
.. to be compatible with old mount(8).

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-12 16:52:32 +01:00
Karel Zak ecdba5ddfc build-sys: add --enable-new-mount
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>
2012-01-11 17:05:08 +01:00
Karel Zak dbae36fe40 libmount: add --pass-fd to samples/mount
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-11 16:17:06 +01:00
Karel Zak 1a7a421ed7 libmount: add support for encrypted loopdevs
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-11 16:16:00 +01:00
s.p@orbitalfox.com b631e4d801 libmount: fixed a small typo 2012-01-04 11:37:49 +01:00
Dave Reisner b928ab01e0 libmount: fix typo in function name
Build broken in c70d9d7.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-01-02 16:56:12 +01:00
Karel Zak c70d9d768b libmount: consolidate MNT_FS_* code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-02 15:00:27 +01:00
Dave Reisner ee83edede1 libmount: avoid resolving pseudofs source on update
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>
2012-01-02 14:27:09 +01:00
Karel Zak 16b8db49fe libmount; fix possible mem-leak
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-02 14:16:15 +01:00
Dave Reisner 14f66ad69a libmount: always trust the source of a pseudofs
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>
2012-01-02 13:59:35 +01:00
Karel Zak 937266598f libmount: don't use "new" in header file
Reported-by: ben <benscott@nwlink.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-19 22:51:38 +01:00
Karel Zak d2c97887fe libmount: add support for mount -a --fork
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-02 18:20:34 +01:00
Karel Zak ede8a60e05 libmount: add "+" prefix for options pattern (e.g findmnt -O)
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>
2011-12-01 18:28:42 +01:00
Karel Zak 190c342a83 libmount: add -a to umount(8) sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-01 16:47:26 +01:00
Karel Zak 085f163b52 libmount: add mnt_context_umount_next()
This is "umount -a" backend.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-01 16:45:53 +01:00
Karel Zak b3f7a0ec3e libmount: improve verbose message
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-01 16:42:42 +01:00
Karel Zak db216e68fa libmount: add new exprimental umount(8)
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-29 19:02:27 +01:00
Karel Zak 732a631126 include,optutils: add option_to_longopt()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-29 18:21:49 +01:00
Karel Zak e4c92d0617 libmount: use USAGE_* from mount(8) sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-29 18:06:21 +01:00
Karel Zak 6189ace369 libmount: add sanitize_env() to mount(8) sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-29 17:36:39 +01:00
Karel Zak 2492f71341 libmount: remove magic constatnt from mount(8)
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-29 16:58:44 +01:00
Karel Zak b483debb64 libmount: fix compiler warning [-Wimplicit-function-declaration]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-28 10:19:32 +01:00
Karel Zak 1208915521 lib,match: split match_fstype() from libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-15 15:17:19 +01:00
Petr Uzel 26e42d8123 libmount: fix trivial typos in debugging output
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-11-09 10:23:59 +01:00
Karel Zak 6107377322 libmount: fix chdir to parent for restricted (user) umounts
Reported-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-08 21:47:23 +01:00
Petr Uzel b106d05238 libmount: ignore tailing slash in netfs source paths
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=728480
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-08 16:25:01 +01:00
Karel Zak ff4c00f94a libmount: unable to umount nfs shares using the force option
Reported-by: Federico Simoncelli <fsimonce@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=745746
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-17 13:27:21 +02:00
Karel Zak 640fc1b819 build-sys: check scanf %ms modifier
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>
2011-10-10 14:42:40 +02:00
Karel Zak f0d3ff0a6f libmount: support -o loop=<devname>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-30 01:38:38 +02:00
Karel Zak 365e5a7c54 libmount: use loopdev debug facility
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-29 23:29:46 +02:00
Karel Zak b9fd334035 libmount: support {offset,sizelimit}= foor loopdevs
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-29 20:50:08 +02:00
Karel Zak fd1eb7a729 libmount: add function to parse offsets/sizes 2011-09-29 17:48:03 +02:00
Petr Uzel 960cf5737e misc: use %m in format string instead of %s and strerror(errno)
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:46:07 +02:00
Francesco Cosoleto a03fd94b57 libmount: fix use of logical '&&' with constant operand
Found by clang.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-09-27 15:04:23 +02:00
Karel Zak 96bc8588b2 libmount: previously assumed null pointer [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 16:01:42 +02:00
Karel Zak 8726371fb8 libmount: variable dereferenced before check [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 15:33:04 +02:00
Karel Zak ad84aaaa6c libmount: redundant null check on calling free() [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 15:32:35 +02:00
Karel Zak 88d7d36ff2 libmount: use unsigned int for bitfields [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 15:28:56 +02:00
Karel Zak da9629917d docs: use .LGPL extension for file with GNU Lesser License
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-31 11:12:17 +02:00
Karel Zak fa25f2289c Merge branch 'docs-dir' of https://github.com/kerolasa/lelux-utiliteetit
* '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
2011-08-31 11:04:15 +02:00
Sami Kerola ce0efc40a1 docs: remove duplicated text
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>
2011-08-30 19:50:34 +02:00
Karel Zak 581a4ad92a libmount: fix debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-26 10:49:38 +02:00
Benno Schulenberg eaca47f7c6 libmount: cut up mount's help text into manageable chunks
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-16 10:16:35 +02:00
Davidlohr Bueso 19f411cbc6 grammar fixes
Correct grammar from "cannot found" to "cannot find".

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-08-15 14:28:21 +02:00
Sami Kerola f98d4f766e docs: Documentation directory added
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>
2011-08-12 20:19:52 +02:00
Davidlohr Bueso ad2d0d8587 lib: [loopdev.c] correct trivial typo
Should say "failed to find" instead of "failed to found".

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-08-08 13:53:59 +02:00
Davidlohr Bueso ff62fc46b4 libmount: fix undefined sources
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>
2011-08-08 13:53:46 +02:00
Karel Zak 854fa6d99f libmount: update list of pseudo-filesystems
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-08 13:10:34 +02:00
Karel Zak 7fc6d2b8f8 libmount: fix compiler warnings [-Wunused-parameter -Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-02 11:21:16 +02:00
Karel Zak 58ca4ed1b4 build-sys: remove and ignore generated files
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-28 13:47:56 +02:00
Karel Zak 3fe1b06aba build-sys: fix gtk-doc distclean
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27 14:22:36 +02:00
Karel Zak de60d08e93 libmount: remove 'seclabel' on remount, improve for 2.6.39
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-25 15:54:16 +02:00
Karel Zak 9267c0991d libmount: improve apply_fstab debugging
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-25 15:36:44 +02:00
Karel Zak 799b96d957 libmount: add MOUNT_2.20 version to the API
The API is officially stable since 2.20.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-25 12:23:58 +02:00
Karel Zak 486d397297 libmount: remove unnecessary includes, mask API as stable
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-25 11:57:28 +02:00
Karel Zak e6ecd606ae libmount: clean up docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-25 10:42:08 +02:00
Karel Zak 63de90d44f libmount: cleanup docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-23 01:27:39 +02:00
Karel Zak b5962110d2 libmount: fix mtab update for "none" source
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>
2011-07-20 21:24:20 +02:00
Karel Zak 5af0769de6 libmount: cleanup code for "none" source and fstype, fix mem leak
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-20 21:15:43 +02:00
Karel Zak 5dfc984392 libmount: minor fixes
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-27 13:31:48 +02:00
Karel Zak 2576b4e782 libmount: allow to convert /dev/loopN to backing filename
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-23 16:06:27 +02:00
Karel Zak 117545721a libmount: cleanup return codes in mount sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-23 15:19:37 +02:00
Karel Zak 9f7472b0b8 libmount: add support for mount -a
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-23 15:07:55 +02:00
Karel Zak 679f59dde2 libmount: fix fstype caching
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-23 12:29:00 +02:00
Karel Zak 171b0fb491 libmount: rename in cache.c
* don't use mnt_ prefix for static functions

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-23 12:24:02 +02:00
Karel Zak 8eef6df790 libmount: clean up cache.c
* rename fields in the cache entry to be more readable...

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-23 12:19:30 +02:00
Karel Zak e5c5abaee3 libmount: add generic function to read table for context
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-22 13:34:47 +02:00
Karel Zak d84508cfbd libmount: allow to set parser callback to context
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-21 14:58:37 +02:00
Karel Zak 0164c24595 mountpoint: add new command
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>
2011-06-21 11:46:36 +02:00
Karel Zak 7f8b2bf3be libmount: add mount support for loopdevs
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-10 15:39:56 +02:00
Karel Zak a9ae3955fe libmount: minor changes in sample program
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-09 22:43:51 +02:00
Karel Zak 2aefc0a8f2 build-sys: use top-level directory for libmount rather than shlibs/mount
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-09 21:59:52 +02:00