summaryrefslogtreecommitdiffstats
path: root/libmount/src/fs.c
Commit message (Collapse)AuthorAgeFilesLines
* libmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs()Kevin Hao2019-08-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | The "umount -f -a -r" get stuck in a endless loop when run with a mountinfo like below: 15 0 179:2 / / ro,relatime - ext4 /dev/root ro 16 15 0:6 / /dev rw,relatime - devtmpfs devtmpfs rw,size=242896k,nr_inodes=60724,mode=755 17 15 0:4 / /proc rw,relatime - proc proc rw 18 15 0:15 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k 19 15 0:16 / /sys rw,relatime - sysfs sysfs rw 20 19 0:7 / /sys/kernel/debug rw,relatime - debugfs debugfs rw 21 15 0:17 / /run rw,nosuid,nodev - tmpfs tmpfs rw,mode=755 22 15 0:18 / /var/volatile rw,relatime - tmpfs tmpfs rw 23 15 179:1 / /boot rw,relatime - vfat /dev/mmcblk0p1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 24 16 0:19 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000 25 18 0:20 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k The reason is that the two same mnt entry "/mnt/.psplash" will cause the dst->tab set to NULL when umount this mnt entry the second time. This will trigger an endless loop in mnt_reset_table() because that mnt entry is linked on the libmnt_table but its .tab is set to NULL. Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
* libmount: (docs) add reference to v2.33 and v2.34Karel Zak2019-06-071-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve fs referencing in tablesTim Hildering2019-03-081-0/+17
| | | | | | | | | | | | | | | * Added member 'struct libmnt_table *tab' to libmnt_fs structure. * Added 'mnt_fs_get_table()'. * Removed overhead from 'mnt_table_{insert,move,remove}_fs(). * Added check to 'mnt_table_set_iter()' that entry is member of table. [kzak@redhat.com: - add to libmount.sys - add to docs - cleanup commit message - set fs->tab = NULL before mnt_unref_fs() in mnt_table_remove_fs()] Signed-off-by: Tim Hildering <hilderingt@posteo.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: cleanup licenses sections in the filesKarel Zak2018-08-161-3/+8
| | | | | | | | | * add SPDX-License-Identifier (see https://spdx.org/licenses/) * add "This file part of libmount from util-linux project." * use proper text for LGPL-2.1-or-later * use the same texts everywhere Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix compiler warning [-Wcast-qual]Karel Zak2018-07-231-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix typos using codespellRuediger Meier2018-02-161-4/+4
| | | | | | Some more funny typos, please review carefully. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libmount: fix debug messageKarel Zak2018-02-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: remove %p from debug messagesKarel Zak2018-02-011-7/+1Star
| | | | | | From libs where suid program may be executed by non-root user. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: (docs) add missing 'since' tagsKarel Zak2017-05-231-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: Fix word repetitionsYuri Chornoivan2017-02-131-1/+1
|
* docs: some random fixesKarel Zak2016-09-271-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: ignore redundant slashesKarel Zak2016-08-081-6/+8
| | | | | | | | | | | | | | | ///aaa/bbb and /aaa/bbb/ are the same paths. This is important especially with NFS where number of slashes are not the same in the /proc/self/mountinfo and fstab or utab. The regular URI is euler://tmp but /proc contains euler:/tmp Reported-by: Ales Novak <alnovak@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-5/+4Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* libmount: remove duplicate codeKarel Zak2016-04-221-68/+10Star
| | | | | | | | For petty long time we have strdup_to_struct_member() macro to avoid duplicate code when strdup() strings in setter functions. Let's use it for libmount. Signed-off-by: Karel Zak <kzak@redhat.com>
* Revert "include sysmacros.h where used"Karel Zak2016-03-081-1/+0Star
| | | | This reverts commit 46a40c018438b7b2b25083a5e5a4a21055a0c1e9.
* include sysmacros.h where usedMike Frysinger2016-03-081-0/+1
| | | | | | | | BSD/Linux systems stick major/minor/makedev in sysmacros.h. Newer Linux libraries have been moving away from including sysmacros.h implicitly via sys/types.h, so include it directly. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libblkid,libmount: Do not use void* in calculations [cppcheck]Boris Egorov2016-01-191-2/+2
| | | | | | | | [libblkid/src/superblocks/zfs.c:179]: (portability) 'label' is of type 'const void *'. When using void pointers in calculations, the behaviour is undefined. [libblkid/src/superblocks/zfs.c:237]: (portability) 'label' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [libblkid/src/topology/topology.c:221]: (portability) 'chn.data' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [libmount/src/fs.c:153]: (portability) 'old' is of type 'const void *'. When using void pointers in calculations, the behaviour is undefined. [libmount/src/fs.c:154]: (portability) 'new' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.
* libmount: remove assert(arg) from public functionsKarel Zak2015-02-161-57/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: improve mnt_reset_fs()Karel Zak2014-11-191-17/+20
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: always use mnt_resolve_target() in mnt_fs_match_target()Karel Zak2014-07-011-4/+8
| | | | | | | The requested path is also target mountpoint, so let's optimize realpath() usage as well. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: mnt_resolve_target: tiptoe around active mount pointsEric Rannaud2014-07-011-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Current code in mnt_fs_match_target() and mnt_table_find_target() already does not canonicalize active mount points (when read from mountinfo), because they are already canonicalized by the kernel. Calling realpath(fs->target) on a mount point can hang -- e.g. if the NFS server is unreachable. This patch optionally extends this strategy to the general case, that is when @fs does not directly come from the kernel through mountinfo (for instance, it may have been parsed from /etc/fstab). Given @mtab parsed from mountinfo, and if mnt_cache_set_targets(cache, mtab) is used, then mnt_fs_match_target() and mnt_table_find_target() check whether @fs->target is a known mount point in the cached mountinfo, before attempting to canonicalize @fs->target, no matter where @fs itself comes from. If found in the cached mountinfo, @fs->target is not canonicalized. [kzak@redhat.com: - don't allocate libmnt_iter, - add docs for mnt_cache_set_targets(), - fallback to mnt_resolve_path() if no cache->mtab specified, - use streq_except_trailing_slash() to compare paths] Signed-off-by: Eric Rannaud <e@nanocritical.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: mnt_resolve_path: don't canonicalize fs->target for swapEric Rannaud2014-07-011-1/+1
| | | | | | | | This is how mnt_table_find_target() does it. It makes sense because @fs->target is "none" for swap and is never a sensible match for a user-specified target. Signed-off-by: Eric Rannaud <e@nanocritical.com>
* libmount: mnt_resolve_path: use strcmp() only if both are canonicalEric Rannaud2014-07-011-1/+1
| | | | Signed-off-by: Eric Rannaud <e@nanocritical.com>
* libmount: use new debug functionsKarel Zak2014-03-211-9/+7Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: update docsKarel Zak2013-09-271-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: make mnt_fs_{ap,pre}pend_options() more robustKarel Zak2013-09-261-0/+6
| | | | | | | We should not use the results from mnt_split_optstr() if the function failed. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: Free splitted optstr's when error occurredNamhyung Kim2013-09-261-1/+5
| | | | | | When strdup() failed, u, v and f optstr's should be freed. Signed-off-by: Namhyung Kim <namhyung@gmail.com>
* libmount: cleanup libmnt_fs list after mnt_table_remove_fs()Karel Zak2013-08-221-1/+10
| | | | | | | .. otherwise mnt_free_fs() will try to remove FS from non-existing list. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add reference counting to libmount_fsKarel Zak2013-08-211-4/+48
| | | | | | | | | | | | | | | | | | | | * mnt_new_fs() returns object with refcount=1 * mnt_free_fs() does not care about reference counter * new functions mnt_ref_fs() and mnt_unref_fs() * mnt_table_add_fs() and mnt_table_rem_fs() uses reference counter * libmmnt_context uses reference counter for internal FS (as it could be shared outside the context) * backwardly incompatible change: - FS could be deallocated after mnt_table_remove_fs() * it's recommended to use mnt_unref_fs() after mnt_table_add_fs() Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix typosOndrej Oprala2013-08-051-38/+38
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* libmount: add missing declarations to libmount.h.in and documentationOndrej Oprala2013-08-011-0/+1
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* libmount: add functions to safely replace a fs tableOndrej Oprala2013-07-031-0/+6
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* libmount: add functions to handle comments in fs tablesOndrej Oprala2013-07-031-0/+57
| | | | | | Co-Author: Karel Zak <kzak@redhat.com> Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: be more restrictive about valid tag namesKarel Zak2013-07-021-3/+6
| | | | | | | | | | # mount DUMMY=filename.img /mnt The 'DUMMY=filename.img' is a filename and should not be interpreted as tag name. The valid tag names are LABEL, UUID, PARTLABEL and PARTUUID only. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix mount.nfs segfault, rely on assert() rather than on nonnullKarel Zak2013-04-121-8/+26
| | | | | | | | | | | | | | | | | We use mnt_optstr_append_option(&o, mnt_fs_get_vfs_options(fs), NULL); in mount.nfs, unfortunately mnt_optstr_append_option() has been marked ass nonnull(1, 2). That's wrong because append and prepend should robust enough to accept NULL as option name. The patch also removes almost all __attribute__((nonnull). It seems better to rely on assert() to have usable feedback. In many cases (nonnull) is premature optimization for the library. This attribute makes sense for things like strlen() or so... Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=948274 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: umount crashes when trying to umount a non-mountpointKarel Zak2013-03-251-0/+3
| | | | | Reported-by: Mantas Mikulėnas <grawity@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: clean up header fileKarel Zak2013-03-151-1/+1
| | | | | | | | | | | * don't teach people C by header files, so use warn_unused_result attribute only on places where we return allocated memory (to avoid leaks in applications). * merge multiple function attributes to the one list to make it usable with gtk-doc Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fix a mem leakKarel Zak2013-02-181-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: tags does not start with '/'Karel Zak2013-02-111-1/+1
| | | | | References: https://bugzilla.redhat.com/show_bug.cgi?id=909866 Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add mnt_fs_get_propagation()Karel Zak2013-01-101-0/+35
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: read optional mountinfo fieldsOndrej Oprala2013-01-101-0/+14
| | | | | | | | | | [kzak@redhat.com: - rename struct member and functions from "propagation" to "optional fields" - split the original patch - fix parser] Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: clean nonnull attribute usageKarel Zak2012-12-041-0/+2
| | | | | | | | | | - use __attribute__((nonnull) for functions where we not able to return an return code ("is", "has" and some "get" functions). - use __attribute__((nonnull) for small functions where we always modify any of the function argument (some mnt_optstr_* functions) Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: fixed comment about paramRaul Gutierrez Segales2012-10-151-1/+1
| | | | Signed-off-by: Raul Gutierrez Segales <rgs@itevenworks.net>
* docs: fix typos found by misspellingsBernhard Voelker2012-07-091-1/+1
| | | | | | | | | | | | | | | | | | The tool misspellings (https://github.com/lyda/misspell-check) detected several typos. Command used: $ git ls-files | grep -v ^po/ | misspellings -f - * Documentation/releases/v2.18-ReleaseNotes: Fix typo in news entry. * NEWS: Likewise. * config/texinfo.tex: Fix typo in comments. * libmount/src/context.c: Fix typo in comment. * libmount/src/fs.c: Likewise. * login-utils/login.c: Likewise. * login-utils.su.1: Fix typo in man page. * sys-utils/chcpu.c: Fix typo in error message. Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
* libmount: save task ID for mountinfo tilesKarel Zak2012-06-281-1/+17
| | | | | | Add new function mnt_fs_get_tid() to get task ID for the given filesystem. Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: don't canonicalize targetKarel Zak2012-05-171-2/+3
| | | | | | | | | | | | | | 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: add support to parse /proc/swapsKarel Zak2012-04-031-0/+79
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add mnt_fs_streq_target() and export all mnt_fs_streq_*Karel Zak2012-03-021-9/+35
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add mnt_fs_streq_srcpath()Karel Zak2012-03-021-10/+23
| | | | | | | | | | 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>