chiark / gitweb /
Prep v229: Add missing fixes from upstream [2/6] src/core
[elogind.git] / src / core / mount-setup.c
index f48d8a0ab00128a423d99aca2b4f7a99e6846a22..0467fe210f9459c2278fb0e13e8e0b5bfb8c77fc 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 /***
   This file is part of systemd.
 
@@ -40,8 +38,8 @@
 #include "path-util.h"
 //#include "set.h"
 //#include "smack-util.h"
-//#include "strv.h"
 #include "string-util.h"
+//#include "strv.h"
 #include "user-util.h"
 //#include "util.h"
 #include "virt.h"
@@ -215,19 +213,14 @@ static int mount_one(const MountPoint *p, bool relabel) {
         return 1;
 }
 
-#if 0 /// UNNEEDED by elogind
-int mount_setup_early(void) {
+static int mount_points_setup(unsigned n, bool loaded_policy) {
         unsigned i;
         int r = 0;
 
-        assert_cc(N_EARLY_MOUNT <= ELEMENTSOF(mount_table));
-
-        /* Do a minimal mount of /proc and friends to enable the most
-         * basic stuff, such as SELinux */
-        for (i = 0; i < N_EARLY_MOUNT; i ++)  {
+        for (i = 0; i < n; i ++) {
                 int j;
 
-                j = mount_one(mount_table + i, false);
+                j = mount_one(mount_table + i, loaded_policy);
                 if (j != 0 && r >= 0)
                         r = j;
         }
@@ -235,6 +228,15 @@ int mount_setup_early(void) {
         return r;
 }
 
+#if 0 /// UNNEEDED by elogind
+int mount_setup_early(void) {
+        assert_cc(N_EARLY_MOUNT <= ELEMENTSOF(mount_table));
+
+        /* Do a minimal mount of /proc and friends to enable the most
+         * basic stuff, such as SELinux */
+        return mount_points_setup(N_EARLY_MOUNT, false);
+}
+
 int mount_cgroup_controllers(char ***join_controllers) {
         _cleanup_set_free_free_ Set *controllers = NULL;
         int r;
@@ -370,21 +372,13 @@ static int nftw_cb(
 #endif // 0
 
 int mount_setup(bool loaded_policy) {
-        unsigned i;
         int r = 0;
 
-        for (i = 0; i < ELEMENTSOF(mount_table); i ++) {
-                int j;
-
-                j = mount_one(mount_table + i, loaded_policy);
-                if (j != 0 && r >= 0)
-                        r = j;
-        }
+        r = mount_points_setup(ELEMENTSOF(mount_table), loaded_policy);
 
         if (r < 0)
                 return r;
 
-
 #if 0 /// elogind does not control /, /dev, /run and /run/systemd/* are setup elsewhere.
 #if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
         /* Nodes in devtmpfs and /run need to be manually updated for