]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
remount-fs: minor coding style cleanups
authorMike Yuan <me@yhndnzj.com>
Sun, 14 Sep 2025 19:03:15 +0000 (21:03 +0200)
committerMike Yuan <me@yhndnzj.com>
Thu, 18 Sep 2025 18:25:15 +0000 (20:25 +0200)
src/remount-fs/remount-fs.c

index 36bc6b7ef20823dafa1239c5929fe8e7054d6c08..8dd65637b25fb501dd783b87df060d297e7ea15d 100644 (file)
@@ -35,10 +35,8 @@ static int track_pid(Hashmap **h, const char *path, pid_t pid) {
                 return log_oom();
 
         r = hashmap_ensure_put(h, &trivial_hash_ops_value_free, PID_TO_PTR(pid), c);
-        if (r == -ENOMEM)
-                return log_oom();
         if (r < 0)
-                return log_error_errno(r, "Failed to store pid " PID_FMT, pid);
+                return log_error_errno(r, "Failed to store pid " PID_FMT " for mount '%s': %m", pid, path);
 
         TAKE_PTR(c);
         return 0;
@@ -48,6 +46,8 @@ static int do_remount(const char *path, bool force_rw, Hashmap **pids) {
         pid_t pid;
         int r;
 
+        assert(path);
+
         log_debug("Remounting %s...", path);
 
         r = safe_fork(force_rw ? "(remount-rw)" : "(remount)",
@@ -98,7 +98,7 @@ static int remount_by_fstab(Hashmap **ret_pids) {
                 if (path_equal(me->mnt_dir, "/"))
                         has_root = true;
 
-                r = do_remount(me->mnt_dir, false, &pids);
+                r = do_remount(me->mnt_dir, /* force_rw = */ false, &pids);
                 if (r < 0)
                         return r;
         }
@@ -132,7 +132,7 @@ static int run(int argc, char *argv[]) {
                         log_warning_errno(r, "Failed to parse $SYSTEMD_REMOUNT_ROOT_RW, ignoring: %m");
 
                 if (r > 0) {
-                        r = do_remount("/", true, &pids);
+                        r = do_remount("/", /* force_rw = */ true, &pids);
                         if (r < 0)
                                 return r;
                 }