2011-12-12 16:59:25 +01:00
|
|
|
From b9841589cf16950af7d123ecd128b84464d15a1d Mon Sep 17 00:00:00 2001
|
|
|
|
From: Frederic Crozat <fcrozat@suse.com>
|
|
|
|
Date: Mon, 7 Nov 2011 18:04:20 +0100
|
|
|
|
Subject: [PATCH] force lvm restart after cryptsetup target is reached
|
|
|
|
|
|
|
|
---
|
|
|
|
src/cryptsetup-generator.c | 80 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
1 files changed, 80 insertions(+), 0 deletions(-)
|
|
|
|
|
2012-11-02 17:30:32 +01:00
|
|
|
Index: systemd-194/src/cryptsetup/cryptsetup-generator.c
|
Accepting request 101505 from Base:System
- Update to version 39:
+ New systemd-cgtop tool to show control groups by their resource
usage.
+ Linking against libacl for ACLs is optional again.
+ If a group "adm" exists, journal files are automatically owned
by them, thus allow members of this group full access to the
system journal as well as all user journals.
+ The journal now stores the SELinux context of the logging
client for all entries.
+ Add C++ inclusion guards to all public headers.
+ New output mode "cat" in the journal to print only text
messages, without any meta data like date or time.
+ Include tiny X server wrapper as a temporary stop-gap to teach
XOrg udev display enumeration (until XOrg supports udev
hotplugging for display devices).
+ Add new systemd-cat tool for executing arbitrary programs with
STDERR/STDOUT connected to the journal. Can also act as BSD
logger replacement, and does so by default.
+ Optionally store all locally generated coredumps in the journal
along with meta data.
+ systemd-tmpfiles learnt four new commands: n, L, c, b, for
writing short strings to files (for usage for /sys), and for
creating symlinks, character and block device nodes.
+ New unit file option ControlGroupPersistent= to make cgroups
persistent.
+ Support multiple local RTCs in a sane way.
+ No longer monopolize IO when replaying readahead data on
rotating disks.
+ Don't show kernel threads in systemd-cgls anymore, unless
requested with new -k switch. (forwarded request 101496 from fcrozat)
OBS-URL: https://build.opensuse.org/request/show/101505
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=85
2012-01-26 16:00:42 +01:00
|
|
|
===================================================================
|
2012-11-02 17:30:32 +01:00
|
|
|
--- systemd-194.orig/src/cryptsetup/cryptsetup-generator.c
|
|
|
|
+++ systemd-194/src/cryptsetup/cryptsetup-generator.c
|
Accepting request 101505 from Base:System
- Update to version 39:
+ New systemd-cgtop tool to show control groups by their resource
usage.
+ Linking against libacl for ACLs is optional again.
+ If a group "adm" exists, journal files are automatically owned
by them, thus allow members of this group full access to the
system journal as well as all user journals.
+ The journal now stores the SELinux context of the logging
client for all entries.
+ Add C++ inclusion guards to all public headers.
+ New output mode "cat" in the journal to print only text
messages, without any meta data like date or time.
+ Include tiny X server wrapper as a temporary stop-gap to teach
XOrg udev display enumeration (until XOrg supports udev
hotplugging for display devices).
+ Add new systemd-cat tool for executing arbitrary programs with
STDERR/STDOUT connected to the journal. Can also act as BSD
logger replacement, and does so by default.
+ Optionally store all locally generated coredumps in the journal
along with meta data.
+ systemd-tmpfiles learnt four new commands: n, L, c, b, for
writing short strings to files (for usage for /sys), and for
creating symlinks, character and block device nodes.
+ New unit file option ControlGroupPersistent= to make cgroups
persistent.
+ Support multiple local RTCs in a sane way.
+ No longer monopolize IO when replaying readahead data on
rotating disks.
+ Don't show kernel threads in systemd-cgls anymore, unless
requested with new -k switch. (forwarded request 101496 from fcrozat)
OBS-URL: https://build.opensuse.org/request/show/101505
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=85
2012-01-26 16:00:42 +01:00
|
|
|
@@ -22,6 +22,7 @@
|
2011-12-12 16:59:25 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
#include "util.h"
|
2012-11-02 17:30:32 +01:00
|
|
|
@@ -64,6 +65,71 @@ static bool has_option(const char *hayst
|
2011-12-12 16:59:25 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static int create_storage_after_cryptsetup (void) {
|
|
|
|
+ int r;
|
|
|
|
+ char *to = NULL, *p = NULL;
|
|
|
|
+ FILE *f = NULL;
|
|
|
|
+
|
|
|
|
+ if (asprintf(&p, "%s/storage-after-cryptsetup.service", arg_dest) < 0) {
|
|
|
|
+ r = -ENOMEM;
|
|
|
|
+ log_error("Failed to allocate unit file name.");
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!(f = fopen(p, "wxe"))) {
|
|
|
|
+ r = -errno;
|
|
|
|
+ log_error("Failed to create unit file: %m");
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fprintf(f,
|
|
|
|
+ "[Unit]\n"
|
|
|
|
+ "Description=Restart storage after cryptsetup\n"
|
|
|
|
+ "DefaultDependencies=no\n"
|
|
|
|
+ "After=cryptsetup.target\n"
|
|
|
|
+ "Wants=cryptsetup.target\n"
|
Accepting request 101505 from Base:System
- Update to version 39:
+ New systemd-cgtop tool to show control groups by their resource
usage.
+ Linking against libacl for ACLs is optional again.
+ If a group "adm" exists, journal files are automatically owned
by them, thus allow members of this group full access to the
system journal as well as all user journals.
+ The journal now stores the SELinux context of the logging
client for all entries.
+ Add C++ inclusion guards to all public headers.
+ New output mode "cat" in the journal to print only text
messages, without any meta data like date or time.
+ Include tiny X server wrapper as a temporary stop-gap to teach
XOrg udev display enumeration (until XOrg supports udev
hotplugging for display devices).
+ Add new systemd-cat tool for executing arbitrary programs with
STDERR/STDOUT connected to the journal. Can also act as BSD
logger replacement, and does so by default.
+ Optionally store all locally generated coredumps in the journal
along with meta data.
+ systemd-tmpfiles learnt four new commands: n, L, c, b, for
writing short strings to files (for usage for /sys), and for
creating symlinks, character and block device nodes.
+ New unit file option ControlGroupPersistent= to make cgroups
persistent.
+ Support multiple local RTCs in a sane way.
+ No longer monopolize IO when replaying readahead data on
rotating disks.
+ Don't show kernel threads in systemd-cgls anymore, unless
requested with new -k switch. (forwarded request 101496 from fcrozat)
OBS-URL: https://build.opensuse.org/request/show/101505
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=85
2012-01-26 16:00:42 +01:00
|
|
|
+ "Before=local-fs.target\n"
|
2011-12-12 16:59:25 +01:00
|
|
|
+ "Before=shutdown.target\n");
|
|
|
|
+
|
|
|
|
+ fprintf(f,
|
|
|
|
+ "\n[Service]\n"
|
|
|
|
+ "RemainAfterExit=true\n"
|
|
|
|
+ "Type=oneshot\n"
|
|
|
|
+ "TimeoutSec=0\n"
|
2012-11-02 17:30:32 +01:00
|
|
|
+ "ExecStart=/usr/bin/systemctl restart lvm.service\n");
|
2011-12-12 16:59:25 +01:00
|
|
|
+
|
|
|
|
+ fflush(f);
|
|
|
|
+
|
|
|
|
+ if (ferror(f)) {
|
|
|
|
+ r = -errno;
|
|
|
|
+ log_error("Failed to write file: %m");
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (asprintf(&to, "%s/local-fs.target.wants/storage-after-cryptsetup.service", arg_dest) < 0) {
|
|
|
|
+ r = -ENOMEM;
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mkdir_parents(to, 0755);
|
|
|
|
+
|
|
|
|
+ if (symlink("../storage-after-cryptsetup.service", to) < 0) {
|
|
|
|
+ log_error("Failed to create symlink ../storage-after-cryptsetup.service to '%s': %m", to);
|
|
|
|
+ r = -errno;
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
|
|
|
+
|
Accepting request 101505 from Base:System
- Update to version 39:
+ New systemd-cgtop tool to show control groups by their resource
usage.
+ Linking against libacl for ACLs is optional again.
+ If a group "adm" exists, journal files are automatically owned
by them, thus allow members of this group full access to the
system journal as well as all user journals.
+ The journal now stores the SELinux context of the logging
client for all entries.
+ Add C++ inclusion guards to all public headers.
+ New output mode "cat" in the journal to print only text
messages, without any meta data like date or time.
+ Include tiny X server wrapper as a temporary stop-gap to teach
XOrg udev display enumeration (until XOrg supports udev
hotplugging for display devices).
+ Add new systemd-cat tool for executing arbitrary programs with
STDERR/STDOUT connected to the journal. Can also act as BSD
logger replacement, and does so by default.
+ Optionally store all locally generated coredumps in the journal
along with meta data.
+ systemd-tmpfiles learnt four new commands: n, L, c, b, for
writing short strings to files (for usage for /sys), and for
creating symlinks, character and block device nodes.
+ New unit file option ControlGroupPersistent= to make cgroups
persistent.
+ Support multiple local RTCs in a sane way.
+ No longer monopolize IO when replaying readahead data on
rotating disks.
+ Don't show kernel threads in systemd-cgls anymore, unless
requested with new -k switch. (forwarded request 101496 from fcrozat)
OBS-URL: https://build.opensuse.org/request/show/101505
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=85
2012-01-26 16:00:42 +01:00
|
|
|
+ r=0;
|
2011-12-12 16:59:25 +01:00
|
|
|
+fail:
|
|
|
|
+ free(p);
|
|
|
|
+ free(to);
|
|
|
|
+
|
|
|
|
+ if (f)
|
|
|
|
+ fclose(f);
|
|
|
|
+
|
|
|
|
+ return r;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static int create_disk(
|
|
|
|
const char *name,
|
|
|
|
const char *device,
|
2012-11-02 17:30:32 +01:00
|
|
|
@@ -439,6 +505,9 @@ int main(int argc, char *argv[]) {
|
2011-12-12 16:59:25 +01:00
|
|
|
free(options);
|
|
|
|
}
|
|
|
|
|
2012-11-02 17:30:32 +01:00
|
|
|
+ if ((r == EXIT_SUCCESS) && (create_storage_after_cryptsetup () < 0))
|
2011-12-12 16:59:25 +01:00
|
|
|
+ r = EXIT_FAILURE;
|
|
|
|
+
|
|
|
|
finish:
|
2012-11-02 17:30:32 +01:00
|
|
|
if (f)
|
|
|
|
fclose(f);
|