From: Franck Bui Date: Mon, 26 Jun 2017 13:23:35 +0000 (+0200) Subject: gpt-auto-generator: disable gpt auto logic for swaps if at least one is defined in... X-Git-Tag: v234~79^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc5bc384c7691bc9aacf05bfa79a2a02c3d8d45d;p=platform%2Fupstream%2Fsystemd.git gpt-auto-generator: disable gpt auto logic for swaps if at least one is defined in fstab If a swap partition is created on a disk using GPT then the unit generated by the gpt-generator can shadow the one generated by the fstab-generator. This can be an issue if the fstab entry for the swap has options since they are simply ignored if PID1 decides to use the unit created by the gpt-generator since this unit carries no information about the swap options. This patch simply disables the GPT auto logic for swaps if at least one entry for swap is defined in /etc/fstab. Fixes: #6192 --- diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index a6cd8af..c531916 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -305,6 +305,15 @@ static int add_swap(const char *path) { assert(path); + /* Disable the swap auto logic if at least one swap is defined in /etc/fstab, see #6192. */ + r = fstab_has_fstype("swap"); + if (r < 0) + return log_error_errno(r, "Failed to parse fstab: %m"); + if (r == 0) { + log_debug("swap specified in fstab, ignoring."); + return 0; + } + log_debug("Adding swap: %s", path); r = unit_name_from_path(path, ".swap", &name);