chiark / gitweb /
shared: switch our hash table implementation over to SipHash
[elogind.git] / src / remount-fs / remount-fs.c
index 35b71548a30d88a046424c779e495b58f504920f..847637a12ca3988e9f3970e2407e4a82bc54570a 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "log.h"
 #include "util.h"
+#include "path-util.h"
 #include "set.h"
 #include "mount-setup.h"
 #include "exit-status.h"
@@ -39,7 +40,7 @@
 
 int main(int argc, char *argv[]) {
         int ret = EXIT_FAILURE;
-        FILE *f = NULL;
+        _cleanup_endmntent_ FILE *f = NULL;
         struct mntent* me;
         Hashmap *pids = NULL;
 
@@ -56,13 +57,11 @@ int main(int argc, char *argv[]) {
 
         f = setmntent("/etc/fstab", "r");
         if (!f) {
-                if (errno == ENOENT) {
-                        ret = EXIT_SUCCESS;
-                        goto finish;
-                }
+                if (errno == ENOENT)
+                        return EXIT_SUCCESS;
 
                 log_error("Failed to open /etc/fstab: %m");
-                goto finish;
+                return EXIT_FAILURE;
         }
 
         pids = hashmap_new(trivial_hash_func, trivial_compare_func);
@@ -78,9 +77,10 @@ int main(int argc, char *argv[]) {
                 int k;
                 char *s;
 
-                /* Remount the root fs and all API VFS */
+                /* Remount the root fs, /usr and all API VFS */
                 if (!mount_point_is_api(me->mnt_dir) &&
-                    !path_equal(me->mnt_dir, "/"))
+                    !path_equal(me->mnt_dir, "/") &&
+                    !path_equal(me->mnt_dir, "/usr"))
                         continue;
 
                 log_debug("Remounting %s", me->mnt_dir);
@@ -112,7 +112,7 @@ int main(int argc, char *argv[]) {
 
                 s = strdup(me->mnt_dir);
                 if (!s) {
-                        log_error("Out of memory.");
+                        log_oom();
                         ret = EXIT_FAILURE;
                         continue;
                 }
@@ -127,10 +127,9 @@ int main(int argc, char *argv[]) {
         }
 
         while (!hashmap_isempty(pids)) {
-                siginfo_t si;
+                siginfo_t si = {};
                 char *s;
 
-                zero(si);
                 if (waitid(P_ALL, 0, &si, WEXITED) < 0) {
 
                         if (errno == EINTR)
@@ -143,7 +142,7 @@ int main(int argc, char *argv[]) {
 
                 s = hashmap_remove(pids, UINT_TO_PTR(si.si_pid));
                 if (s) {
-                        if (!is_clean_exit(si.si_code, si.si_status)) {
+                        if (!is_clean_exit(si.si_code, si.si_status, NULL)) {
                                 if (si.si_code == CLD_EXITED)
                                         log_error("/bin/mount for %s exited with exit status %i.", s, si.si_status);
                                 else
@@ -161,8 +160,5 @@ finish:
         if (pids)
                 hashmap_free_free(pids);
 
-        if (f)
-                endmntent(f);
-
         return ret;
 }