|
|
1ff636 |
From e819659256d139cd5faebb5c0ca3ad4ad95ccb27 Mon Sep 17 00:00:00 2001
|
|
|
1ff636 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
1ff636 |
Date: Sat, 21 Mar 2015 11:31:16 -0400
|
|
|
1ff636 |
Subject: [PATCH] fstab-generator: ignore invalid swap priority
|
|
|
1ff636 |
|
|
|
1ff636 |
A failed priority is not something worth stopping boot over. Most people
|
|
|
1ff636 |
have only one swap device, in which case priority is irrelevant, and even
|
|
|
1ff636 |
if there is more than one swap device, they are all usable, and ignoring the
|
|
|
1ff636 |
priority field should only result in some loss of performance.
|
|
|
1ff636 |
|
|
|
1ff636 |
The kernel will report the priority as -1 if not set, so it's easy for
|
|
|
1ff636 |
people to make this mistake.
|
|
|
1ff636 |
|
|
|
1ff636 |
https://bugzilla.redhat.com/show_bug.cgi?id=1204336
|
|
|
1ff636 |
(cherry picked from commit e0952d9d021234e79f3a70f33a9e5d201872a417)
|
|
|
1ff636 |
---
|
|
|
1ff636 |
src/fstab-generator/fstab-generator.c | 23 ++++++++++++++++-------
|
|
|
1ff636 |
1 file changed, 16 insertions(+), 7 deletions(-)
|
|
|
1ff636 |
|
|
|
1ff636 |
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
|
|
Pablo Greco |
48fc63 |
index 5662b5fde1..8e2f522bd0 100644
|
|
|
1ff636 |
--- a/src/fstab-generator/fstab-generator.c
|
|
|
1ff636 |
+++ b/src/fstab-generator/fstab-generator.c
|
|
|
1ff636 |
@@ -54,9 +54,10 @@ static int add_swap(
|
|
|
1ff636 |
bool noauto,
|
|
|
1ff636 |
bool nofail) {
|
|
|
1ff636 |
|
|
|
1ff636 |
- _cleanup_free_ char *name = NULL, *unit = NULL, *lnk = NULL;
|
|
|
1ff636 |
+ _cleanup_free_ char *name = NULL, *unit = NULL, *lnk = NULL, *filtered = NULL;
|
|
|
1ff636 |
_cleanup_fclose_ FILE *f = NULL;
|
|
|
1ff636 |
int r, pri = -1;
|
|
|
1ff636 |
+ const char *opts;
|
|
|
1ff636 |
|
|
|
1ff636 |
assert(what);
|
|
|
1ff636 |
assert(me);
|
|
|
1ff636 |
@@ -71,9 +72,17 @@ static int add_swap(
|
|
|
1ff636 |
return 0;
|
|
|
1ff636 |
}
|
|
|
1ff636 |
|
|
|
1ff636 |
- r = fstab_find_pri(me->mnt_opts, &pri);
|
|
|
1ff636 |
- if (r < 0)
|
|
|
1ff636 |
- return log_error_errno(r, "Failed to parse priority: %m");
|
|
|
1ff636 |
+ opts = me->mnt_opts;
|
|
|
1ff636 |
+ r = fstab_find_pri(opts, &pri);
|
|
|
1ff636 |
+ if (r < 0) {
|
|
|
1ff636 |
+ log_error_errno(r, "Failed to parse priority, ignoring: %m");
|
|
|
1ff636 |
+
|
|
|
1ff636 |
+ /* Remove invalid pri field */
|
|
|
1ff636 |
+ r = fstab_filter_options(opts, "pri\0", NULL, NULL, &filtered);
|
|
|
1ff636 |
+ if (r < 0)
|
|
|
1ff636 |
+ return log_error_errno(r, "Failed to parse options: %m");
|
|
|
1ff636 |
+ opts = filtered;
|
|
|
1ff636 |
+ }
|
|
|
1ff636 |
|
|
|
1ff636 |
name = unit_name_from_path(what, ".swap");
|
|
|
1ff636 |
if (!name)
|
|
|
1ff636 |
@@ -106,15 +115,15 @@ static int add_swap(
|
|
|
1ff636 |
if (pri >= 0)
|
|
|
1ff636 |
fprintf(f, "Priority=%i\n", pri);
|
|
|
1ff636 |
|
|
|
1ff636 |
- if (!isempty(me->mnt_opts) && !streq(me->mnt_opts, "defaults"))
|
|
|
1ff636 |
- fprintf(f, "Options=%s\n", me->mnt_opts);
|
|
|
1ff636 |
+ if (!isempty(opts) && !streq(opts, "defaults"))
|
|
|
1ff636 |
+ fprintf(f, "Options=%s\n", opts);
|
|
|
1ff636 |
|
|
|
1ff636 |
r = fflush_and_check(f);
|
|
|
1ff636 |
if (r < 0)
|
|
|
1ff636 |
return log_error_errno(r, "Failed to write unit file %s: %m", unit);
|
|
|
1ff636 |
|
|
|
1ff636 |
/* use what as where, to have a nicer error message */
|
|
|
1ff636 |
- r = generator_write_timeouts(arg_dest, what, what, me->mnt_opts, NULL);
|
|
|
1ff636 |
+ r = generator_write_timeouts(arg_dest, what, what, opts, NULL);
|
|
|
1ff636 |
if (r < 0)
|
|
|
1ff636 |
return r;
|
|
|
1ff636 |
|