summaryrefslogtreecommitdiff
path: root/libmount/src
AgeCommit message (Collapse)AuthorFilesLines
2014-01-24include/c.h: prefer nanosleep() over usleep()Karel Zak1-2/+2
Let's use nanosleep() although if usleep() exists. The nanosleep function does no interact with signals and other timers. The patch introduces xusleep() as replacement to libc (or our fallback) usleep(). Yes, we don't want to use struct timespec + nanosleep() everywhere in code as nano-time resolution is useless for us. The patch also enlarges delays in some busy wait loops. It seems enough to try read/write 4x per second. Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-14libmount: fix scanf format string [coverity scan]Karel Zak1-4/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-12-11libmount: add mnt_table_uniq_fs()Karel Zak3-14/+157
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-12-10libmount: add efivarfs to the list of pseudo filesystemsKarel Zak1-1/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-19libmount: add mnt_tag_is_valid()Karel Zak3-0/+22
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-12libmount: cleanup fix_optstr() regards to selinux and smackKarel Zak1-19/+47
It's better (more robust) to make the code based on datetypes rather than on if(strcmp(...)). Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-12libmount: fix typo in smack pathKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-12libmount: remove smackfs* option when SMACK not enabledKarel Zak1-0/+22
If there is no /sys/fs/smackfs then libmount removes smackfs*= mount options when compiled --with-smack. Note that we do the same for SELinux. References: http://www.mail-archive.com/systemd-devel@lists.freedesktop.org/msg13740.html Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-08strutils: add skip_space() functionOndrej Oprala1-13/+4
[kzak@redhat.com: - add also skip_blank(), - remove duplicate implementation from libmount] Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-04libmount: update utab after successful extern helper mountKarel Zak3-10/+84
This patch allows to maintain private utab libmount file also for external mount/umount helpers that are not linked with libmount. The libmount check if utab has been updated after successful extern helper execution (status=0). If not then the file is updated. This patch affects only 'user' fstab mount option. So, for example with suid mount.cifs you can use: //server/foo /mnt cifs username=foo,noauto,user Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-04libmount: allow to use -s (sloppy) for all external helpersKarel Zak1-6/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-11libmount: fix mnt_context_is_child() commentKarel Zak1-1/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-11libmount: Fix typo in commentNamhyung Kim1-2/+2
s/MNT_OMASK_/MNT_OMODE_/ Signed-off-by: Namhyung Kim <namhyung@gmail.com>
2013-10-01libmount: remove dead code [coverity scan]Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-01libmount: make mnt_table_replace_file() more robust [coverity scan]Karel Zak1-1/+13
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-30libmount: Save errno if mkostemp() failedNamhyung Kim1-1/+3
After mkostemp() failed, umask() and free() might alter the errno to another value. Not sure those calls really changes the errno or not. But let's be more conservative. Signed-off-by: Namhyung Kim <namhyung@gmail.com>
2013-09-27libmount: update docsKarel Zak3-4/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-27libmount: small cleanup in umount codeKarel Zak2-3/+6
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-26libmount: compose mount.<type> helpers paths more carefullyKarel Zak1-0/+1
The [u]mount helper path is "/sbin/mount.<type>", the <type> should not be possible to interpret like a path, for example: # mkdir /sbin/mount.fake # mount -t fake/../../../home/user/foo.sh Anyway, this is *not mount(8) security issue*, because: - non-root users don't have permissions to specify -t on mount(8) command line - /sbin is not writable for regular users This patch makes libmount more robust for situations when the library is used by incompetent developers who don't sanitize user's input. Reported-by: "Horsfall, Matthew" <mhorsfal@akamai.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-26libmount: make mnt_fs_{ap,pre}pend_options() more robustKarel Zak1-0/+6
We should not use the results from mnt_split_optstr() if the function failed. Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-26libmount: Remove stale comment on mnt_context_mount()Namhyung Kim1-5/+0
The commit f9906424 ("libmount: add post-mount checks to detect ro/rw") added necessary check so the comment is not valid anymore. Signed-off-by: Namhyung Kim <namhyung@gmail.com>
2013-09-26libmount: Set each optstr's to NULL if failedNamhyung Kim1-3/+9
When mnt_split_optstr() failed in the middle, vfs, fs, user optstr's are freed but not reset. It can lead to double frees at the end of mnt_fs_{ap,pre}pend_options(). Signed-off-by: Namhyung Kim <namhyung@gmail.com>
2013-09-26libmount: Free splitted optstr's when error occurredNamhyung Kim1-1/+5
When strdup() failed, u, v and f optstr's should be freed. Signed-off-by: Namhyung Kim <namhyung@gmail.com>
2013-09-26libmount: Get rid of an unnecessary checkNamhyung Kim1-1/+1
libmount_debug_mask was OR'ed to MNT_DEBUG_INIT so it should be non-null. Thus the check is pointless. Signed-off-by: Namhyung Kim <namhyung@gmail.com>
2013-09-20libmount: free username after checkDave Reisner1-0/+2
Leak reported by valgrind: ==14226== 7 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==14226== at 0x4C2757B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==14226== by 0x5534839: strdup (in /usr/lib/libc-2.18.so) ==14226== by 0x4E53FE0: mnt_get_username (utils.c:560) ==14226== by 0x4E456A5: mnt_context_prepare_umount (context_umount.c:413) ==14226== by 0x4E464F7: mnt_context_umount (context_umount.c:851) ==14226== by 0x403476: umount_one (umount.c:299) ==14226== by 0x402B34: main (umount.c:629) Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2013-09-20libmount: use memmove when overlap possibleDave Reisner1-1/+1
When unmounting some mountpoints as an unprivileged user (via the 'user' option in fstab), the umount fails. Debug output of 'umount /opt' reveals: 17760: libmount: CXT: [0x22890e0]: do umount 17760: libmount: UTILS: moving to /opt parent 17760: libmount: CXT: current directory moved to / [last_component='opt'] 17760: libmount: CXT: [0x22890e0]: umount(2) [target='pt', flags=0x00000000] valgrind shows the problem: ==23544== Source and destination overlap in memcpy(0x58d1370, 0x58d1371, 4) ==23544== at 0x4C2BBC3: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==23544== by 0x4E537C3: mnt_chdir_to_parent (utils.c:168) ==23544== by 0x4E45E4C: mnt_context_do_umount (context_umount.c:601) ==23544== by 0x4E46513: mnt_context_umount (context_umount.c:855) ==23544== by 0x403476: umount_one (umount.c:299) ==23544== by 0x402B34: main (umount.c:629) ==23544== ref: https://bugs.archlinux.org/task/36968 Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2013-09-10lib: rename time-util.c to timeutils.c, fix headersKarel Zak1-0/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-29lib/strutils: move *swith() functions to private librarySami Kerola4-36/+2
Avoid code dublication in libmount and time-util. Proposed-by: Karel Zak <kzak@redhat.com> Reference: http://markmail.org/message/h7zexvqsieqngtmx Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-27build-sys: add CFLAGS and LDFLAGS for daemons and shared libsKarel Zak1-0/+2
This is necessary for paranoid security guys who believe that things like "-Wl,-z,relro" or "-Wl,-z,bind_now" is a way how to make the world a safer place... Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-22libmount: cleanup libmnt_fs list after mnt_table_remove_fs()Karel Zak2-1/+13
.. otherwise mnt_free_fs() will try to remove FS from non-existing list. Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21libmount: add reference counter to libmnt_tableKarel Zak9-50/+98
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21libmount: add reference counting to libmnt_cacheKarel Zak5-30/+68
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21libmount: add reference counting to libmount_fsKarel Zak9-41/+113
* 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>
2013-08-21libmount: add function for context userdataKarel Zak3-0/+43
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-20libmount: add mnt_table_is_empty(), improve table list usageKarel Zak4-9/+30
Currently you have to use mnt_table_remove_fs() + mnt_free_fs() to destroy the list in the table. This is complicated in same situations. This patch allows to use mnt_free_fs() only. Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-20libmount: add mnt_table_{first,last}_fs()Karel Zak3-0/+44
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-20libmount: add mnt_table_{set,get}_userdata()Karel Zak3-0/+36
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-20libmount: add mnt_table_with_comments()Karel Zak3-0/+14
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-05libmount: be robust when work with loopdev backing file pathsKarel Zak2-18/+17
It's usually unnecessary as we compare devno and ino, but let's use absolute paths for situations when it's necessary to compare paths as strings. Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-05libmount: canonicalize for conversion from loopdev backing fileKarel Zak1-1/+6
# mount foo.img /mnt # umount foo.img umount: foo.img: not mounted The loopdev code (and sysfs backing_file) uses absolute paths, but libmount does not canonicalize the path before lookup for the backing file. References: https://bugzilla.redhat.com/show_bug.cgi?id=950497 Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-05libmount: fix typosOndrej Oprala19-353/+354
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-08-01libmount: add missing declarations to libmount.h.in and documentationOndrej Oprala3-0/+6
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-08-01libmount: change tailing to trailing in *_tailing_comments functionsOndrej Oprala5-21/+21
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-07-09libmount: fix memory leak [clang-analyzer]Karel Zak1-1/+2
Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-08lsblk: use devno to check if the filesystem is mountedKarel Zak1-1/+15
The device (for example LVM logical volume) could be renamed and then the device name from /proc/self/mountinfo does not match with reality. So, we also need to check devno. Unfortunately we cannot completely rely on devno, because for example btrfs uses psudo device numbers. References: https://bugzilla.redhat.com/show_bug.cgi?id=980463 Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-03libmount: add functions to safely replace a fs tableOndrej Oprala3-0/+112
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-07-03libmount: add functions to handle comments in fs tablesOndrej Oprala7-9/+356
Co-Author: Karel Zak <kzak@redhat.com> Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-02libmount: add a generic append_string() functionKarel Zak2-0/+39
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-02libmount: be more restrictive about valid tag namesKarel Zak5-32/+40
# 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>
2013-06-17libmount: be robust for empty target/source stringsKarel Zak2-14/+27
* lib/canonicalize.c: don't interpret empty strings as relative paths * libmount: more robust libmnt_table find function and debug messages References: https://bugzilla.novell.com/show_bug.cgi?id=825150 Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>