1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
From: Andras Korn <korn-debbugs@elan.rulez.org>
Date: Thu, 6 Dec 2012 16:57:06 +0100
Forwarded: <no>
Subject: [PATCH] support /etc/runit/nosync file to make sync on
shutdown/reboot optional
https://bugs.debian.org/695281
---
runit-2.1.2/doc/runit.8.html | 2 ++
runit-2.1.2/man/runit.8 | 5 +++++
runit-2.1.2/src/runit.c | 15 ++++++++++-----
runit-2.1.2/src/runit.h | 1 +
4 files changed, 18 insertions(+), 5 deletions(-)
Index: runit/runit-2.1.2/doc/runit.8.html
===================================================================
--- runit.orig/runit-2.1.2/doc/runit.8.html
+++ runit/runit-2.1.2/doc/runit.8.html
@@ -34,6 +34,8 @@ stage 2 if it is running, and runs <i>/e
and possibly halt or reboot the system are done here. If stage 3 returns,
<b>runit</b> checks if the file <i>/etc/runit/reboot</i> exists and has the execute by
owner permission set. If so, the system is rebooted, it’s halted otherwise.
+If <i>/etc/runit/nosync</i> exists, <b>runit</b> doesn’t invoke
+sync(). This is useful in vservers.
<h2><a name='sect6'>Ctrl-alt-del</a></h2>
If <b>runit</b> receives the ctrl-alt-del keyboard request and the file
Index: runit/runit-2.1.2/man/runit.8
===================================================================
--- runit.orig/runit-2.1.2/man/runit.8
+++ runit/runit-2.1.2/man/runit.8
@@ -48,6 +48,11 @@ checks if the file
.I /etc/runit/reboot
exists and has the execute by owner permission set.
If so, the system is rebooted, it's halted otherwise.
+If
+.I /etc/runit/nosync
+exists,
+.B runit
+doesn't invoke sync(). This is useful in vservers.
.SH CTRL-ALT-DEL
If
.B runit
Index: runit/runit-2.1.2/src/runit.c
===================================================================
--- runit.orig/runit-2.1.2/src/runit.c
+++ runit/runit-2.1.2/src/runit.c
@@ -41,6 +41,11 @@ void sig_int_handler (void) {
}
void sig_child_handler (void) { write(selfpipe[1], "", 1); }
+void sync_if_needed() {
+ struct stat s;
+ if (stat(NOSYNC, &s) == -1) sync();
+}
+
int main (int argc, const char * const *argv, char * const *envp) {
const char * prog[2];
int pid, pid2;
@@ -305,28 +310,28 @@ int main (int argc, const char * const *
case -1:
if ((stat(REBOOT, &s) != -1) && (s.st_mode & S_IXUSR)) {
strerr_warn2(INFO, "system reboot.", 0);
- sync();
+ sync_if_needed();
reboot_system(RB_AUTOBOOT);
}
else {
#ifdef RB_POWER_OFF
strerr_warn2(INFO, "power off...", 0);
- sync();
+ sync_if_needed();
reboot_system(RB_POWER_OFF);
sleep(2);
#endif
#ifdef RB_HALT_SYSTEM
strerr_warn2(INFO, "system halt.", 0);
- sync();
+ sync_if_needed();
reboot_system(RB_HALT_SYSTEM);
#else
#ifdef RB_HALT
strerr_warn2(INFO, "system halt.", 0);
- sync();
+ sync_if_needed();
reboot_system(RB_HALT);
#else
strerr_warn2(INFO, "system reboot.", 0);
- sync();
+ sync_if_needed();
reboot_system(RB_AUTOBOOT);
#endif
#endif
Index: runit/runit-2.1.2/src/runit.h
===================================================================
--- runit.orig/runit-2.1.2/src/runit.h
+++ runit/runit-2.1.2/src/runit.h
@@ -1,4 +1,5 @@
#define RUNIT "/sbin/runit"
#define STOPIT "/etc/runit/stopit"
#define REBOOT "/etc/runit/reboot"
+#define NOSYNC "/etc/runit/nosync"
#define CTRLALTDEL "/etc/runit/ctrlaltdel"
|