[systemd-commits] 3 commits - .gitignore Makefile.am TODO src/core src/remount-api-vfs src/remount-fs units/.gitignore units/quotacheck.service.in units/remount-rootfs.service units/systemd-remount-api-vfs.service.in units/systemd-remount-fs.service.in

Lennart Poettering lennart at kemper.freedesktop.org
Tue Apr 24 08:37:24 PDT 2012


 .gitignore                               |    1 
 Makefile.am                              |   19 +--
 TODO                                     |    4 
 src/core/shutdown.c                      |    3 
 src/core/special.h                       |    2 
 src/core/swap.c                          |    4 
 src/remount-api-vfs/Makefile             |    1 
 src/remount-api-vfs/remount-api-vfs.c    |  166 ------------------------------
 src/remount-fs/Makefile                  |    1 
 src/remount-fs/remount-fs.c              |  168 +++++++++++++++++++++++++++++++
 units/.gitignore                         |    2 
 units/quotacheck.service.in              |    2 
 units/remount-rootfs.service             |   20 ---
 units/systemd-remount-api-vfs.service.in |   20 ---
 units/systemd-remount-fs.service.in      |   20 +++
 15 files changed, 208 insertions(+), 225 deletions(-)

New commits:
commit b55d0651c0433aee6bbec0516a0c2eb001c3fc31
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 24 16:56:06 2012 +0200

    shutdown: don't complain if we cannot lock memory, to make container shutdowns clean

diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index 9631f92..2494bb8 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -347,8 +347,7 @@ int main(int argc, char *argv[]) {
         use_watchdog = !!getenv("WATCHDOG_USEC");
 
         /* lock us into memory */
-        if (mlockall(MCL_CURRENT|MCL_FUTURE) != 0)
-                log_warning("Cannot lock process memory: %m");
+        mlockall(MCL_CURRENT|MCL_FUTURE);
 
         log_info("Sending SIGTERM to remaining processes...");
         send_signal(SIGTERM);

commit 2b93b027d3a68b5d7ae26d0c2cd487eb5019d2a9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 24 16:42:42 2012 +0200

    remount: consolidate remount-api-vfs and remount-rootfs into one
    
    This has the advantage of removing a confusing warning by mount if the
    root directory is not listed in fstab.

diff --git a/.gitignore b/.gitignore
index ea031c4..a921c76 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/systemd-remount-fs
 /build-aux
 /test-watchdog
 /test-journal-send
diff --git a/Makefile.am b/Makefile.am
index ab7fca6..b503b01 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -225,7 +225,7 @@ rootlibexec_PROGRAMS = \
 	systemd-shutdownd \
 	systemd-shutdown \
 	systemd-modules-load \
-	systemd-remount-api-vfs \
+	systemd-remount-fs \
 	systemd-reply-password \
 	systemd-fsck \
 	systemd-timestamp \
@@ -287,7 +287,6 @@ dist_systemunit_DATA = \
 	units/sys-kernel-debug.mount \
 	units/sys-fs-fuse-connections.mount \
 	units/tmp.mount \
-	units/remount-rootfs.service \
 	units/printer.target \
 	units/sound.target \
 	units/bluetooth.target \
@@ -308,7 +307,7 @@ nodist_systemunit_DATA = \
 	units/systemd-initctl.service \
 	units/systemd-shutdownd.service \
 	units/systemd-modules-load.service \
-	units/systemd-remount-api-vfs.service \
+	units/systemd-remount-fs.service \
 	units/systemd-update-utmp-runlevel.service \
 	units/systemd-update-utmp-shutdown.service \
 	units/systemd-tmpfiles-setup.service \
@@ -345,7 +344,7 @@ EXTRA_DIST += \
 	units/systemd-initctl.service.in \
 	units/systemd-shutdownd.service.in \
 	units/systemd-modules-load.service.in \
-	units/systemd-remount-api-vfs.service.in \
+	units/systemd-remount-fs.service.in \
 	units/systemd-update-utmp-runlevel.service.in \
 	units/systemd-update-utmp-shutdown.service.in \
 	units/systemd-tmpfiles-setup.service.in \
@@ -1110,12 +1109,12 @@ systemd_rc_local_generator_LDADD = \
 	libsystemd-shared.la
 
 # ------------------------------------------------------------------------------
-systemd_remount_api_vfs_SOURCES = \
-	src/remount-api-vfs/remount-api-vfs.c \
+systemd_remount_fs_SOURCES = \
+	src/remount-fs/remount-fs.c \
 	src/core/mount-setup.c \
 	src/core/mount-setup.h
 
-systemd_remount_api_vfs_LDADD = \
+systemd_remount_fs_LDADD = \
 	libsystemd-shared.la
 
 # ------------------------------------------------------------------------------
@@ -3059,13 +3058,11 @@ systemd-install-data-hook:
 		rm -f systemd-update-utmp-shutdown.service && \
 		$(LN_S) ../systemd-update-utmp-shutdown.service systemd-update-utmp-shutdown.service )
 	( cd $(DESTDIR)$(systemunitdir)/local-fs.target.wants && \
-		rm -f systemd-remount-api-vfs.service \
+		rm -f systemd-remount-fs.service \
 			fsck-root.service \
-			remount-rootfs.service \
 			tmp.mount && \
-		$(LN_S) ../systemd-remount-api-vfs.service systemd-remount-api-vfs.service && \
+		$(LN_S) ../systemd-remount-fs.service systemd-remount-fs.service && \
 		$(LN_S) ../fsck-root.service fsck-root.service && \
-		$(LN_S) ../remount-rootfs.service remount-rootfs.service && \
 		$(LN_S) ../tmp.mount tmp.mount )
 	( cd $(DESTDIR)$(userunitdir) && \
 		rm -f shutdown.target sockets.target bluetooth.target printer.target sound.target && \
diff --git a/src/core/special.h b/src/core/special.h
index f1ff1b9..2db4711 100644
--- a/src/core/special.h
+++ b/src/core/special.h
@@ -65,7 +65,7 @@
 #define SPECIAL_FSCK_SERVICE "fsck at .service"
 #define SPECIAL_QUOTACHECK_SERVICE "quotacheck.service"
 #define SPECIAL_QUOTAON_SERVICE "quotaon.service"
-#define SPECIAL_REMOUNT_ROOTFS_SERVICE "remount-rootfs.service"
+#define SPECIAL_REMOUNT_FS_SERVICE "systemd-remount-fs.service"
 
 /* Services systemd relies on */
 #define SPECIAL_DBUS_SERVICE "dbus.service"
diff --git a/src/core/swap.c b/src/core/swap.c
index fea3f68..d2f9491 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -211,9 +211,9 @@ static int swap_add_device_links(Swap *s) {
                                           UNIT(s)->manager->running_as == MANAGER_SYSTEM);
         else
                 /* File based swap devices need to be ordered after
-                 * remount-rootfs.service, since they might need a
+                 * systemd-remount-fs.service, since they might need a
                  * writable file system. */
-                return unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_REMOUNT_ROOTFS_SERVICE, NULL, true);
+                return unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_REMOUNT_FS_SERVICE, NULL, true);
 }
 
 static int swap_add_default_dependencies(Swap *s) {
diff --git a/src/remount-api-vfs/Makefile b/src/remount-api-vfs/Makefile
deleted file mode 120000
index d0b0e8e..0000000
--- a/src/remount-api-vfs/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../Makefile
\ No newline at end of file
diff --git a/src/remount-api-vfs/remount-api-vfs.c b/src/remount-api-vfs/remount-api-vfs.c
deleted file mode 100644
index 373ae25..0000000
--- a/src/remount-api-vfs/remount-api-vfs.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <mntent.h>
-
-#include "log.h"
-#include "util.h"
-#include "set.h"
-#include "mount-setup.h"
-#include "exit-status.h"
-
-/* Goes through /etc/fstab and remounts all API file systems, applying
- * options that are in /etc/fstab that systemd might not have
- * respected */
-
-int main(int argc, char *argv[]) {
-        int ret = EXIT_FAILURE;
-        FILE *f = NULL;
-        struct mntent* me;
-        Hashmap *pids = NULL;
-
-        if (argc > 1) {
-                log_error("This program takes no argument.");
-                return EXIT_FAILURE;
-        }
-
-        log_set_target(LOG_TARGET_AUTO);
-        log_parse_environment();
-        log_open();
-
-        umask(0022);
-
-        f = setmntent("/etc/fstab", "r");
-        if (!f) {
-                if (errno == ENOENT) {
-                        ret = EXIT_SUCCESS;
-                        goto finish;
-                }
-
-                log_error("Failed to open /etc/fstab: %m");
-                goto finish;
-        }
-
-        pids = hashmap_new(trivial_hash_func, trivial_compare_func);
-        if (!pids) {
-                log_error("Failed to allocate set");
-                goto finish;
-        }
-
-        ret = EXIT_SUCCESS;
-
-        while ((me = getmntent(f))) {
-                pid_t pid;
-                int k;
-                char *s;
-
-                if (!mount_point_is_api(me->mnt_dir))
-                        continue;
-
-                log_debug("Remounting %s", me->mnt_dir);
-
-                pid = fork();
-                if (pid < 0) {
-                        log_error("Failed to fork: %m");
-                        ret = EXIT_FAILURE;
-                        continue;
-                }
-
-                if (pid == 0) {
-                        const char *arguments[5];
-                        /* Child */
-
-                        arguments[0] = "/bin/mount";
-                        arguments[1] = me->mnt_dir;
-                        arguments[2] = "-o";
-                        arguments[3] = "remount";
-                        arguments[4] = NULL;
-
-                        execv("/bin/mount", (char **) arguments);
-
-                        log_error("Failed to execute /bin/mount: %m");
-                        _exit(EXIT_FAILURE);
-                }
-
-                /* Parent */
-
-                s = strdup(me->mnt_dir);
-                if (!s) {
-                        log_error("Out of memory.");
-                        ret = EXIT_FAILURE;
-                        continue;
-                }
-
-
-                k = hashmap_put(pids, UINT_TO_PTR(pid), s);
-                if (k < 0) {
-                        log_error("Failed to add PID to set: %s", strerror(-k));
-                        ret = EXIT_FAILURE;
-                        continue;
-                }
-        }
-
-        while (!hashmap_isempty(pids)) {
-                siginfo_t si;
-                char *s;
-
-                zero(si);
-                if (waitid(P_ALL, 0, &si, WEXITED) < 0) {
-
-                        if (errno == EINTR)
-                                continue;
-
-                        log_error("waitid() failed: %m");
-                        ret = EXIT_FAILURE;
-                        break;
-                }
-
-                s = hashmap_remove(pids, UINT_TO_PTR(si.si_pid));
-                if (s) {
-                        if (!is_clean_exit(si.si_code, si.si_status)) {
-                                if (si.si_code == CLD_EXITED)
-                                        log_error("/bin/mount for %s exited with exit status %i.", s, si.si_status);
-                                else
-                                        log_error("/bin/mount for %s terminated by signal %s.", s, signal_to_string(si.si_status));
-
-                                ret = EXIT_FAILURE;
-                        }
-
-                        free(s);
-                }
-        }
-
-finish:
-
-        if (pids)
-                hashmap_free_free(pids);
-
-        if (f)
-                endmntent(f);
-
-        return ret;
-}
diff --git a/src/remount-fs/Makefile b/src/remount-fs/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/src/remount-fs/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file
diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c
new file mode 100644
index 0000000..35b7154
--- /dev/null
+++ b/src/remount-fs/remount-fs.c
@@ -0,0 +1,168 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <mntent.h>
+
+#include "log.h"
+#include "util.h"
+#include "set.h"
+#include "mount-setup.h"
+#include "exit-status.h"
+
+/* Goes through /etc/fstab and remounts all API file systems, applying
+ * options that are in /etc/fstab that systemd might not have
+ * respected */
+
+int main(int argc, char *argv[]) {
+        int ret = EXIT_FAILURE;
+        FILE *f = NULL;
+        struct mntent* me;
+        Hashmap *pids = NULL;
+
+        if (argc > 1) {
+                log_error("This program takes no argument.");
+                return EXIT_FAILURE;
+        }
+
+        log_set_target(LOG_TARGET_AUTO);
+        log_parse_environment();
+        log_open();
+
+        umask(0022);
+
+        f = setmntent("/etc/fstab", "r");
+        if (!f) {
+                if (errno == ENOENT) {
+                        ret = EXIT_SUCCESS;
+                        goto finish;
+                }
+
+                log_error("Failed to open /etc/fstab: %m");
+                goto finish;
+        }
+
+        pids = hashmap_new(trivial_hash_func, trivial_compare_func);
+        if (!pids) {
+                log_error("Failed to allocate set");
+                goto finish;
+        }
+
+        ret = EXIT_SUCCESS;
+
+        while ((me = getmntent(f))) {
+                pid_t pid;
+                int k;
+                char *s;
+
+                /* Remount the root fs and all API VFS */
+                if (!mount_point_is_api(me->mnt_dir) &&
+                    !path_equal(me->mnt_dir, "/"))
+                        continue;
+
+                log_debug("Remounting %s", me->mnt_dir);
+
+                pid = fork();
+                if (pid < 0) {
+                        log_error("Failed to fork: %m");
+                        ret = EXIT_FAILURE;
+                        continue;
+                }
+
+                if (pid == 0) {
+                        const char *arguments[5];
+                        /* Child */
+
+                        arguments[0] = "/bin/mount";
+                        arguments[1] = me->mnt_dir;
+                        arguments[2] = "-o";
+                        arguments[3] = "remount";
+                        arguments[4] = NULL;
+
+                        execv("/bin/mount", (char **) arguments);
+
+                        log_error("Failed to execute /bin/mount: %m");
+                        _exit(EXIT_FAILURE);
+                }
+
+                /* Parent */
+
+                s = strdup(me->mnt_dir);
+                if (!s) {
+                        log_error("Out of memory.");
+                        ret = EXIT_FAILURE;
+                        continue;
+                }
+
+
+                k = hashmap_put(pids, UINT_TO_PTR(pid), s);
+                if (k < 0) {
+                        log_error("Failed to add PID to set: %s", strerror(-k));
+                        ret = EXIT_FAILURE;
+                        continue;
+                }
+        }
+
+        while (!hashmap_isempty(pids)) {
+                siginfo_t si;
+                char *s;
+
+                zero(si);
+                if (waitid(P_ALL, 0, &si, WEXITED) < 0) {
+
+                        if (errno == EINTR)
+                                continue;
+
+                        log_error("waitid() failed: %m");
+                        ret = EXIT_FAILURE;
+                        break;
+                }
+
+                s = hashmap_remove(pids, UINT_TO_PTR(si.si_pid));
+                if (s) {
+                        if (!is_clean_exit(si.si_code, si.si_status)) {
+                                if (si.si_code == CLD_EXITED)
+                                        log_error("/bin/mount for %s exited with exit status %i.", s, si.si_status);
+                                else
+                                        log_error("/bin/mount for %s terminated by signal %s.", s, signal_to_string(si.si_status));
+
+                                ret = EXIT_FAILURE;
+                        }
+
+                        free(s);
+                }
+        }
+
+finish:
+
+        if (pids)
+                hashmap_free_free(pids);
+
+        if (f)
+                endmntent(f);
+
+        return ret;
+}
diff --git a/units/.gitignore b/units/.gitignore
index 16cbf2d..68c174f 100644
--- a/units/.gitignore
+++ b/units/.gitignore
@@ -28,7 +28,7 @@ systemd-readahead-replay.service
 serial-getty at .service
 systemd-kmsg-syslogd.service
 systemd-modules-load.service
-systemd-remount-api-vfs.service
+/systemd-remount-fs.service
 systemd-vconsole-setup.service
 systemd-auto-serial-getty.service
 systemd-shutdownd.service
diff --git a/units/quotacheck.service.in b/units/quotacheck.service.in
index d28b533..d3343df 100644
--- a/units/quotacheck.service.in
+++ b/units/quotacheck.service.in
@@ -8,7 +8,7 @@
 [Unit]
 Description=File System Quota Check
 DefaultDependencies=no
-After=systemd-readahead-collect.service systemd-readahead-replay.service remount-rootfs.service
+After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-remount-fs.service
 Before=local-fs.target shutdown.target
 ConditionPathExists=/sbin/quotacheck
 
diff --git a/units/remount-rootfs.service b/units/remount-rootfs.service
deleted file mode 100644
index 52a7074..0000000
--- a/units/remount-rootfs.service
+++ /dev/null
@@ -1,20 +0,0 @@
-#  This file is part of systemd.
-#
-#  systemd is free software; you can redistribute it and/or modify it
-#  under the terms of the GNU Lesser General Public License as published by
-#  the Free Software Foundation; either version 2.1 of the License, or
-#  (at your option) any later version.
-
-[Unit]
-Description=Remount Root FS
-DefaultDependencies=no
-Conflicts=shutdown.target
-After=systemd-readahead-collect.service systemd-readahead-replay.service fsck-root.service
-Before=local-fs-pre.target local-fs.target shutdown.target
-Wants=local-fs-pre.target
-ConditionPathExists=/etc/fstab
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStart=/bin/mount / -o remount
diff --git a/units/systemd-remount-api-vfs.service.in b/units/systemd-remount-api-vfs.service.in
deleted file mode 100644
index 60ff9c3..0000000
--- a/units/systemd-remount-api-vfs.service.in
+++ /dev/null
@@ -1,20 +0,0 @@
-#  This file is part of systemd.
-#
-#  systemd is free software; you can redistribute it and/or modify it
-#  under the terms of the GNU Lesser General Public License as published by
-#  the Free Software Foundation; either version 2.1 of the License, or
-#  (at your option) any later version.
-
-[Unit]
-Description=Remount API VFS
-DefaultDependencies=no
-Conflicts=shutdown.target
-After=systemd-readahead-collect.service systemd-readahead-replay.service
-Before=local-fs-pre.target local-fs.target shutdown.target
-Wants=local-fs-pre.target
-ConditionPathExists=/etc/fstab
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStart=@rootlibexecdir@/systemd-remount-api-vfs
diff --git a/units/systemd-remount-fs.service.in b/units/systemd-remount-fs.service.in
new file mode 100644
index 0000000..5074ab5
--- /dev/null
+++ b/units/systemd-remount-fs.service.in
@@ -0,0 +1,20 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Remount Root and Kernel File Systems
+DefaultDependencies=no
+Conflicts=shutdown.target
+After=systemd-readahead-collect.service systemd-readahead-replay.service fsck-root.service
+Before=local-fs-pre.target local-fs.target shutdown.target
+Wants=local-fs-pre.target
+ConditionPathExists=/etc/fstab
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@rootlibexecdir@/systemd-remount-fs

commit a888b352eb53b07daa24fa859ceeb254336b293d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 24 14:59:49 2012 +0200

    update TODO

diff --git a/TODO b/TODO
index 3683e6a..b3bbc99 100644
--- a/TODO
+++ b/TODO
@@ -21,6 +21,10 @@ Bugfixes:
 
 Features:
 
+* merge remount-api-vfs and remount-root-fs
+
+* add --read-only to nspawn
+
 * fedora: make sshd and pam_loginuid work in nspawn containers
 
 * fix utmp for console logins in containers



More information about the systemd-commits mailing list