mkfs-util: fix error reporting in the mkfs child

`r` at that point holds the return value of `pidref_safe_fork_full()`,
which is 0 in the child, so a failing `setenv()` was reported as
"Success".

Also, fix a stray "°".

(cherry picked from commit 6d51f6eb04)
(cherry picked from commit f2abf9c66e)
(cherry picked from commit c275a1affb)
(cherry picked from commit 52c033c3b1)
This commit is contained in:
Martin Pitt authored and Luca Boccassi committed 2026-09-11 17:28:39 +01:00
1 parent f3db59e543
commit f5ee066986
1 file changed
+2 -2
+2 -2
View File
@@ -704,14 +704,14 @@ int make_filesystem(
STRV_FOREACH_PAIR(k, v, env)
if (setenv(*k, *v, /* replace = */ true) < 0) {
log_error_errno(r, "Failed to set %s=%s environment variable: %m", *k, *v);
log_error_errno(errno, "Failed to set %s=%s environment variable: %m", *k, *v);
_exit(EXIT_FAILURE);
}
/* mkfs.btrfs refuses to operate on block devices with mounted partitions, even if operating
* on unformatted free space, so let's trick it and other mkfs tools into thinking no
* partitions are mounted. See https://github.com/kdave/btrfs-progs/issues/640 for more
° information. */
* information. */
if (fork_flags & FORK_NEW_MOUNTNS)
(void) mount_nofollow_verbose(LOG_DEBUG, "/dev/null", "/proc/self/mounts", NULL, MS_BIND, NULL);