mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-25 11:30:37 -09:00
package/systemd: Backport fix for makefs
The systemd fstab option "x-systemd.makefs" will fail to work, and throw an error that it can't find a device named "" (an empty string). Backport this fix from systemd v245. Signed-off-by: Brandon Maier <brandon.maier@rockwellcollins.com> Reviewed-by: Yann E. MORIN <yann.morin.1998@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
committed by
Peter Korsgaard
parent
eb81345aa9
commit
81b7cfcbd9
48
package/systemd/0004-makefs-strdup-arguments-to-mkfs.patch
Normal file
48
package/systemd/0004-makefs-strdup-arguments-to-mkfs.patch
Normal file
@@ -0,0 +1,48 @@
|
||||
From c315b79fb43a4d921a533ba0c2cb303324887993 Mon Sep 17 00:00:00 2001
|
||||
From: Oliver Giles <ohw.giles@gmail.com>
|
||||
Date: Thu, 13 Feb 2020 08:55:57 +0200
|
||||
Subject: [PATCH] makefs: strdup arguments to mkfs
|
||||
|
||||
Don't pass values from argv[] directly to child process forked using
|
||||
safe_fork, because it clears argv[]. strdup them first.
|
||||
|
||||
[Brandon: backport from https://github.com/systemd/systemd/commit/c315b79fb43a4d921a533ba0c2cb303324887993]
|
||||
Signed-off-by: Brandon Maier <brandon.maier@rockwellcollins.com>
|
||||
---
|
||||
src/partition/makefs.c | 13 +++++++++----
|
||||
1 file changed, 9 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/partition/makefs.c b/src/partition/makefs.c
|
||||
index 951989cbb6..d73d67c4e8 100644
|
||||
--- a/src/partition/makefs.c
|
||||
+++ b/src/partition/makefs.c
|
||||
@@ -41,8 +41,7 @@ static int makefs(const char *type, const char *device) {
|
||||
}
|
||||
|
||||
static int run(int argc, char *argv[]) {
|
||||
- const char *device, *type;
|
||||
- _cleanup_free_ char *detected = NULL;
|
||||
+ _cleanup_free_ char *device = NULL, *type = NULL, *detected = NULL;
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
@@ -52,8 +51,14 @@ static int run(int argc, char *argv[]) {
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"This program expects two arguments.");
|
||||
|
||||
- type = argv[1];
|
||||
- device = argv[2];
|
||||
+ /* type and device must be copied because makefs calls safe_fork, which clears argv[] */
|
||||
+ type = strdup(argv[1]);
|
||||
+ if (!type)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ device = strdup(argv[2]);
|
||||
+ if (!device)
|
||||
+ return -ENOMEM;
|
||||
|
||||
if (stat(device, &st) < 0)
|
||||
return log_error_errno(errno, "Failed to stat \"%s\": %m", device);
|
||||
--
|
||||
2.23.0
|
||||
|
||||
Reference in New Issue
Block a user