summaryrefslogtreecommitdiff
path: root/src/core/mount.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-03-14 11:32:30 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-03-16 10:09:46 +0100
commit95b862b0540ac24999fdfbd670e8744bb626729a (patch)
tree94a627853bf4030552a3fe2991f51539d84f7489 /src/core/mount.c
parentb93618644bf24bc0cd87adb1346955d783f6f9b8 (diff)
downloadsystemd-95b862b0540ac24999fdfbd670e8744bb626729a.tar.gz
shutdown: use libmount to enumerate /proc/self/mountinfo
This is analogous to 8d3ae2bd4c9bf9fc2e57f7b3776325a1c750ca30, except that now src/core/umount.c not src/core/mount.c is converted. Might help with https://bugzilla.redhat.com/show_bug.cgi?id=1554943, or not. In the patch, mnt_free_tablep and mnt_free_iterp are declared twice. It'd be nicer to define them just once in mount-setup.h, but then libmount.h would have to be included there. libmount.h seems to be buggy, and declares some defines which break other headers, and working around this is more pain than the two duplicate lines. So let's live with the duplication for now. This fixes memleak of MountPoint in mount_points_list_get() on error, not that it matters any.
Diffstat (limited to 'src/core/mount.c')
-rw-r--r--src/core/mount.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/core/mount.c b/src/core/mount.c
index cfe8ec9044..0e755da5c0 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1608,11 +1608,8 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
assert(m);
t = mnt_new_table();
- if (!t)
- return log_oom();
-
i = mnt_new_iter(MNT_ITER_FORWARD);
- if (!i)
+ if (!t || !i)
return log_oom();
r = mnt_table_parse_mtab(t, NULL);
@@ -1621,9 +1618,9 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
r = 0;
for (;;) {
+ struct libmnt_fs *fs;
const char *device, *path, *options, *fstype;
_cleanup_free_ char *d = NULL, *p = NULL;
- struct libmnt_fs *fs;
int k;
k = mnt_table_next_fs(t, i, &fs);