diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-03-05 22:26:10 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-03-06 04:00:41 +0100 |
commit | e48fdd84432bbf9c2ecc339183258c7c33116032 (patch) | |
tree | f4726a824d9a497accf80489a3df50b09ece0af0 /src/shared | |
parent | 848e3e24b00a61130f20226ef5f051433d478c69 (diff) |
generators: rework mount generators
- Add support for finding and mounting /srv based on GPT data, similar
to how we already handly /home.
- Share the fsck logic between GPT, EFI and fstab generators
- Make sure we never run the EFI generator inside containers
- Drop DefaultDependencies=no from EFI mount units
- Other fixes
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/generator.c | 84 | ||||
-rw-r--r-- | src/shared/generator.h | 26 | ||||
-rw-r--r-- | src/shared/gpt.h | 28 |
3 files changed, 138 insertions, 0 deletions
diff --git a/src/shared/generator.c b/src/shared/generator.c new file mode 100644 index 0000000000..49647c1ab6 --- /dev/null +++ b/src/shared/generator.c @@ -0,0 +1,84 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/*** + This file is part of systemd. + + Copyright 2014 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see <http://www.gnu.org/licenses/>. +***/ + +#include <unistd.h> + +#include "util.h" +#include "special.h" +#include "mkdir.h" +#include "unit-name.h" +#include "generator.h" + +int generator_write_fsck_deps( + FILE *f, + const char *dest, + const char *what, + const char *where, + const char *type) { + + assert(f); + + if (!is_device_path(what)) { + log_warning("Checking was requested for \"%s\", but it is not a device.", what); + return 0; + } + + if (type && !streq(type, "auto")) { + const char *checker; + int r; + + checker = strappenda("/sbin/fsck.", type); + r = access(checker, X_OK); + if (r < 0) { + log_warning("Checking was requested for %s, but %s cannot be used: %m", what, checker); + + /* treat missing check as essentially OK */ + return errno == ENOENT ? 0 : -errno; + } + } + + if (streq(where, "/")) { + char *lnk; + + lnk = strappenda(dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/systemd-fsck-root.service"); + + mkdir_parents(lnk, 0755); + if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-fsck-root.service", lnk) < 0) { + log_error("Failed to create symlink %s: %m", lnk); + return -errno; + } + + } else { + _cleanup_free_ char *fsck = NULL; + + fsck = unit_name_from_path_instance("systemd-fsck", what, ".service"); + if (!fsck) + return log_oom(); + + fprintf(f, + "RequiresOverridable=%s\n" + "After=%s\n", + fsck, + fsck); + } + + return 0; +} diff --git a/src/shared/generator.h b/src/shared/generator.h new file mode 100644 index 0000000000..0140aa943f --- /dev/null +++ b/src/shared/generator.h @@ -0,0 +1,26 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +#pragma once + +/*** + This file is part of systemd. + + Copyright 2014 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see <http://www.gnu.org/licenses/>. +***/ + +#include <stdio.h> + +int generator_write_fsck_deps(FILE *f, const char *dest, const char *what, const char *where, const char *type); diff --git a/src/shared/gpt.h b/src/shared/gpt.h new file mode 100644 index 0000000000..2956377b48 --- /dev/null +++ b/src/shared/gpt.h @@ -0,0 +1,28 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/*** + This file is part of systemd. + + Copyright 2014 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see <http://www.gnu.org/licenses/>. +***/ + +#include "sd-id128.h" + +#define GPT_ESP SD_ID128_MAKE(c1,2a,73,28,f8,1f,11,d2,ba,4b,00,a0,c9,3e,c9,3b) +#define GPT_ROOT SD_ID128_MAKE(4f,68,bc,e3,e8,cd,4d,b1,96,e7,fb,ca,f9,84,b7,09) +#define GPT_SWAP SD_ID128_MAKE(06,57,fd,6d,a4,ab,43,c4,84,e5,09,33,c8,4b,4f,4f) +#define GPT_HOME SD_ID128_MAKE(93,3a,c7,e1,2e,b4,4f,13,b8,44,0e,14,e2,ae,f9,15) +#define GPT_SRV SD_ID128_MAKE(3b,8f,84,25,20,e0,4f,3b,90,7f,1a,25,a7,6f,98,e8) |