mount-util: bind_remount: avoid calling statvfs
authorJakob Unterwurzacher <jakobunt@gmail.com>
Tue, 16 Jul 2019 21:09:07 +0000 (23:09 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Jul 2019 09:37:09 +0000 (11:37 +0200)
commitd34a40082db3ffca8de66bfa4df50951101bdae5
tree152d3ae3a3bfd01bace2ec880bd868c0b16619ea
parent31cd5f63ce86a0784c4ef869c4d323a11ff14adc
mount-util: bind_remount: avoid calling statvfs

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
src/shared/mount-util.c