summaryrefslogtreecommitdiff
path: root/src/shared/mount-util.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: various code-formatting improvementsFrantisek Sumsal2019-09-221-1/+1
| | | | Reported/found by Coccinelle
* mount-util: bind_remount: avoid calling statvfsJakob Unterwurzacher2019-07-171-4/+27
| | | | | | | | | | | | | | | | | | | | | | | The commit "util: Do not clear parent mount flags when setting up namespaces" introduced a statvfs call read the flags of the original mount and have them applied to the bind mount. This has two problems: (1) The mount flags returned by statvfs(2) do not match the flags accepted by mount(2). For example, the value 4096 means ST_RELATIME when returned by statvfs(2), but means MS_BIND when passed to mount(2). (2) A call to statvfs blocks indefinitely when ran against a disconnected network drive ( https://github.com/systemd/systemd/issues/12667 ). We already use libmount to parse `/proc/self/mountinfo` but did not use the mount flag information from there. This patch changes that to use the mount flags parsed by libmount instead of calling statvfs. Only if getting the flags through libmount fails we call statvfs. Fixes https://github.com/systemd/systemd/issues/12667
* Rename EXTRACT_QUOTES to EXTRACT_UNQUOTEZbigniew Jędrzejewski-Szmek2019-06-281-1/+1
| | | | | | Whenever I see EXTRACT_QUOTES, I'm always confused whether it means to leave the quotes in or to take them out. Let's say "unquote", like we say "cunescape".
* Merge pull request #12218 from keszybz/use-libmount-moreLennart Poettering2019-04-301-76/+47
|\ | | | | Use libmount more
| * shared/mount-util: make sure utab is ignored in umount_recursive()Zbigniew Jędrzejewski-Szmek2019-04-231-1/+1
| | | | | | | | See https://github.com/systemd/systemd/pull/12218#pullrequestreview-226029985.
| * Add helper function for mnt_table_parse_{stream,mtab}Zbigniew Jędrzejewski-Szmek2019-04-231-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This wraps a few common steps. It is defined as inline function instead of in a .c file to avoid having a .c file. With a .c file, we would have three choices: - either link it into libshared, but then then libshared would have to be linked to libmount. - or compile the .c file into each target separately. This has the disdvantage that configuration of every target has to be updated and stuff will be compiled multiple times anyway, which is not too different from keeping this in the header file. - or create a new convenience library just for this. This also has the disadvantage that the every target would have to be updated, and a separate library for a 10 line function seems overkill. By keeping everything in a header file, we compile this a few times, but otherwise it's the least painful option. The compiler can optimize most of the function away, because it knows if 'source' is set or not.
| * shared/mount-util: convert to libmountZbigniew Jędrzejewski-Szmek2019-04-231-76/+57
| | | | | | | | | | | | | | It seems better to use just a single parsing algorithm for /proc/self/mountinfo. Also, unify the naming of variables in all places that use mnt_table_next_fs(). It makes it easier to compare the different call sites.
* | codespell: fix spelling errorsBen Boeckel2019-04-291-1/+1
|/
* Make fopen_temporary and fopen_temporary_label unlockedZbigniew Jędrzejewski-Szmek2019-04-121-1/+0
| | | | | | | | This is partially a refactoring, but also makes many more places use unlocked operations implicitly, i.e. all users of fopen_temporary(). AFAICT, the uses are always for short-lived files which are not shared externally, and are just used within the same context. Locking is not necessary.
* Add fopen_unlocked() wrapperZbigniew Jędrzejewski-Szmek2019-04-121-11/+7
|
* util-lib: fix sentence in commentZbigniew Jędrzejewski-Szmek2019-03-261-1/+1
|
* mount-util: beef up bind_remount_recursive() to be able to toggle more than ↵Lennart Poettering2019-03-251-8/+13
| | | | | | | | MS_RDONLY The function is otherwise generic enough to toggle other bind mount flags beyond MS_RDONLY (for example: MS_NOSUID or MS_NODEV), hence let's beef it up slightly to support that too.
* mount-util: use set_put_strdup() where appropriateLennart Poettering2019-03-251-5/+1
|
* mount-util: don't clobber return value in umount_recursive()Lennart Poettering2019-03-251-5/+5
| | | | | We shouldn't override 'r' with the result of cunescape(), since we use it to return the last error of umount().
* Move mount-util.c to shared/Zbigniew Jędrzejewski-Szmek2018-11-291-0/+570
libmount dep is moved from libbasic to libshared, potentially removing libmount from some build products.