shared/mount-util: make sure utab is ignored in umount_recursive()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 Apr 2019 21:52:15 +0000 (23:52 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 Apr 2019 21:52:15 +0000 (23:52 +0200)
See https://github.com/systemd/systemd/pull/12218#pullrequestreview-226029985.

src/shared/libmount-util.h
src/shared/mount-util.c

index 6e8e61e..7c3b855 100644 (file)
@@ -29,10 +29,15 @@ static inline int libmount_parse(
         if (!table || !iter)
                 return -ENOMEM;
 
+        /* If source or path are specified, we use on the functions which ignore utab.
+         * Only if both are empty, we use mnt_table_parse_mtab(). */
+
         if (source)
                 r = mnt_table_parse_stream(table, source, path);
+        else if (path)
+                r = mnt_table_parse_file(table, path);
         else
-                r = mnt_table_parse_mtab(table, path);
+                r = mnt_table_parse_mtab(table, NULL);
         if (r < 0)
                 return r;
 
index 97cc7b4..d84f282 100644 (file)
@@ -38,7 +38,7 @@ int umount_recursive(const char *prefix, int flags) {
 
                 again = false;
 
-                r = libmount_parse(NULL, NULL, &table, &iter);
+                r = libmount_parse("/proc/self/mountinfo", NULL, &table, &iter);
                 if (r < 0)
                         return log_debug_errno(r, "Failed to parse /proc/self/mountinfo: %m");