|
|
803fb7 |
From e2353e7c13808e47efb844f8fb10b7aa2142e619 Mon Sep 17 00:00:00 2001
|
|
|
803fb7 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
803fb7 |
Date: Fri, 13 Mar 2015 21:10:13 -0500
|
|
|
803fb7 |
Subject: [PATCH] gpt-auto-generator: allow type check to fail
|
|
|
803fb7 |
|
|
|
803fb7 |
add_mount() is OK with unknow file type, but we have to initalize
|
|
|
803fb7 |
the variable to NULL not to pass garbage on error.
|
|
|
803fb7 |
|
|
|
803fb7 |
(cherry picked from commit a0b1209c4a59754f428894e0485413542da50014)
|
|
|
803fb7 |
---
|
|
|
803fb7 |
src/gpt-auto-generator/gpt-auto-generator.c | 13 +++++--------
|
|
|
803fb7 |
1 file changed, 5 insertions(+), 8 deletions(-)
|
|
|
803fb7 |
|
|
|
803fb7 |
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
|
|
|
803fb7 |
index cceeeb845..00a2141a5 100644
|
|
|
803fb7 |
--- a/src/gpt-auto-generator/gpt-auto-generator.c
|
|
|
803fb7 |
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
|
|
|
803fb7 |
@@ -291,7 +291,7 @@ static int probe_and_add_mount(
|
|
|
803fb7 |
const char *post) {
|
|
|
803fb7 |
|
|
|
803fb7 |
_cleanup_blkid_free_probe_ blkid_probe b = NULL;
|
|
|
803fb7 |
- const char *fstype;
|
|
|
803fb7 |
+ const char *fstype = NULL;
|
|
|
803fb7 |
int r;
|
|
|
803fb7 |
|
|
|
803fb7 |
assert(id);
|
|
|
803fb7 |
@@ -324,14 +324,11 @@ static int probe_and_add_mount(
|
|
|
803fb7 |
r = blkid_do_safeprobe(b);
|
|
|
803fb7 |
if (r == -2 || r == 1) /* no result or uncertain */
|
|
|
803fb7 |
return 0;
|
|
|
803fb7 |
- else if (r != 0) {
|
|
|
803fb7 |
- if (errno == 0)
|
|
|
803fb7 |
- errno = EIO;
|
|
|
803fb7 |
- log_error_errno(errno, "Failed to probe %s: %m", what);
|
|
|
803fb7 |
- return -errno;
|
|
|
803fb7 |
- }
|
|
|
803fb7 |
+ else if (r != 0)
|
|
|
803fb7 |
+ return log_error_errno(errno ?: EIO, "Failed to probe %s: %m", what);
|
|
|
803fb7 |
|
|
|
803fb7 |
- blkid_probe_lookup_value(b, "TYPE", &fstype, NULL);
|
|
|
803fb7 |
+ /* add_mount is OK with fstype being NULL. */
|
|
|
803fb7 |
+ (void) blkid_probe_lookup_value(b, "TYPE", &fstype, NULL);
|
|
|
803fb7 |
|
|
|
803fb7 |
return add_mount(
|
|
|
803fb7 |
id,
|