44a72b9
From 3e8acdaf07d4f32b9df199d47b08f1ce67d27435 Mon Sep 17 00:00:00 2001
44a72b9
From: Yu Watanabe <watanabe.yu+github@gmail.com>
44a72b9
Date: Mon, 4 Sep 2017 10:55:51 +0900
44a72b9
Subject: [PATCH] systemd-mount: allow to specify an arbitrary string for
44a72b9
 arg_mount_what when vfs is used
44a72b9
44a72b9
Fixes #6591.
44a72b9
44a72b9
(cherry picked from commit e2be442e791fa1150aa835c684acc6d7189de3e1)
44a72b9
---
44a72b9
 src/basic/mount-util.c | 26 ++++++++++++++++++++++++++
44a72b9
 src/basic/mount-util.h |  1 +
44a72b9
 src/mount/mount-tool.c |  8 +++++++-
44a72b9
 3 files changed, 34 insertions(+), 1 deletion(-)
44a72b9
44a72b9
diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c
44a72b9
index 7b9400b47c..cff44116c8 100644
44a72b9
--- a/src/basic/mount-util.c
44a72b9
+++ b/src/basic/mount-util.c
44a72b9
@@ -552,6 +552,32 @@ bool fstype_is_network(const char *fstype) {
44a72b9
         return nulstr_contains(table, fstype);
44a72b9
 }
44a72b9
 
44a72b9
+bool fstype_is_api_vfs(const char *fstype) {
44a72b9
+        static const char table[] =
44a72b9
+                "autofs\0"
44a72b9
+                "bpf\0"
44a72b9
+                "cgroup\0"
44a72b9
+                "cgroup2\0"
44a72b9
+                "configfs\0"
44a72b9
+                "cpuset\0"
44a72b9
+                "debugfs\0"
44a72b9
+                "devpts\0"
44a72b9
+                "devtmpfs\0"
44a72b9
+                "efivarfs\0"
44a72b9
+                "hugetlbfs\0"
44a72b9
+                "mqueue\0"
44a72b9
+                "proc\0"
44a72b9
+                "pstore\0"
44a72b9
+                "ramfs\0"
44a72b9
+                "securityfs\0"
44a72b9
+                "sysfs\0"
44a72b9
+                "tmpfs\0"
44a72b9
+                "tracefs\0"
44a72b9
+                ;
44a72b9
+
44a72b9
+        return nulstr_contains(table, fstype);
44a72b9
+}
44a72b9
+
44a72b9
 int repeat_unmount(const char *path, int flags) {
44a72b9
         bool done = false;
44a72b9
 
44a72b9
diff --git a/src/basic/mount-util.h b/src/basic/mount-util.h
44a72b9
index 2e24a184c5..70af11c2ff 100644
44a72b9
--- a/src/basic/mount-util.h
44a72b9
+++ b/src/basic/mount-util.h
44a72b9
@@ -44,6 +44,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent);
44a72b9
 #define _cleanup_endmntent_ _cleanup_(endmntentp)
44a72b9
 
44a72b9
 bool fstype_is_network(const char *fstype);
44a72b9
+bool fstype_is_api_vfs(const char *fstype);
44a72b9
 
44a72b9
 union file_handle_union {
44a72b9
         struct file_handle handle;
44a72b9
diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c
44a72b9
index 10bb5dda63..3c974addda 100644
44a72b9
--- a/src/mount/mount-tool.c
44a72b9
+++ b/src/mount/mount-tool.c
44a72b9
@@ -30,6 +30,7 @@
44a72b9
 #include "fd-util.h"
44a72b9
 #include "fileio.h"
44a72b9
 #include "fstab-util.h"
44a72b9
+#include "mount-util.h"
44a72b9
 #include "pager.h"
44a72b9
 #include "parse-util.h"
44a72b9
 #include "path-util.h"
44a72b9
@@ -330,7 +331,12 @@ static int parse_argv(int argc, char *argv[]) {
44a72b9
                         return -EINVAL;
44a72b9
                 }
44a72b9
 
44a72b9
-                if (arg_transport == BUS_TRANSPORT_LOCAL) {
44a72b9
+                if (arg_mount_type && (fstype_is_api_vfs(arg_mount_type) || fstype_is_network(arg_mount_type))) {
44a72b9
+                        arg_mount_what = strdup(argv[optind]);
44a72b9
+                        if (!arg_mount_what)
44a72b9
+                                return log_oom();
44a72b9
+
44a72b9
+                } else if (arg_transport == BUS_TRANSPORT_LOCAL) {
44a72b9
                         _cleanup_free_ char *u = NULL, *p = NULL;
44a72b9
 
44a72b9
                         u = fstab_node_to_udev_node(argv[optind]);