aboutsummaryrefslogtreecommitdiff
path: root/src/openrc-shutdown/sysvinit.h
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2022-04-09 22:54:03 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2022-04-09 22:54:03 -0500
commit0b3f8750e7d307987eef9e63e327488a81c29a71 (patch)
treeee59203338cf34582e3d84a3382418aeef452e12 /src/openrc-shutdown/sysvinit.h
parent39eb3384f64afb02cbd09bbd17185344834fc801 (diff)
openrc-shutdown: remove rc- prefix from file names
Diffstat (limited to 'src/openrc-shutdown/sysvinit.h')
-rw-r--r--src/openrc-shutdown/sysvinit.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/openrc-shutdown/sysvinit.h b/src/openrc-shutdown/sysvinit.h
new file mode 100644
index 00000000..5e3077cf
--- /dev/null
+++ b/src/openrc-shutdown/sysvinit.h
@@ -0,0 +1,72 @@
+/*
+ * sysvinit.h - Interface to communicate with sysvinit via /run/initctl.
+ */
+
+/*
+ * Copyright (c) 2019 The OpenRC Authors.
+ * See the Authors file at the top-level directory of this distribution and
+ * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
+ *
+ * This file is part of OpenRC. It is subject to the license terms in
+ * the LICENSE file found in the top-level directory of this
+ * distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
+ * This file may not be copied, modified, propagated, or distributed
+ * except according to the terms contained in the LICENSE file.
+ */
+
+#ifndef _RC_SYSVINIT_H
+#define _RC_SYSVINIT_H
+
+/*
+ * The #defines and structures below are taken from initreq.h in
+ * sysvinit and must be used by any program wishing to communicate with
+ * it.
+ */
+
+#define INIT_MAGIC 0x03091969
+#define INIT_CMD_START 0
+#define INIT_CMD_RUNLVL 1
+#define INIT_CMD_POWERFAIL 2
+#define INIT_CMD_POWERFAILNOW 3
+#define INIT_CMD_POWEROK 4
+#define INIT_CMD_BSD 5
+#define INIT_CMD_SETENV 6
+#define INIT_CMD_UNSETENV 7
+
+/*
+ * This is what BSD 4.4 uses when talking to init.
+ * Linux doesn't use this right now.
+ */
+struct init_request_bsd {
+ char gen_id[8]; /* Beats me.. telnetd uses "fe" */
+ char tty_id[16]; /* Tty name minus /dev/tty */
+ char host[64]; /* Hostname */
+ char term_type[16]; /* Terminal type */
+ int signal; /* Signal to send */
+ int pid; /* Process to send to */
+ char exec_name[128]; /* Program to execute */
+ char reserved[128]; /* For future expansion. */
+};
+
+/*
+ * Because of legacy interfaces, "runlevel" and "sleeptime"
+ * aren't in a seperate struct in the union.
+ *
+ * The weird sizes are because init expects the whole
+ * struct to be 384 bytes.
+ */
+struct init_request {
+ int magic; /* Magic number */
+ int cmd; /* What kind of request */
+ int runlevel; /* Runlevel to change to */
+ int sleeptime; /* Time between TERM and KILL */
+ union {
+ struct init_request_bsd bsd;
+ char data[368];
+ } i;
+};
+
+void sysvinit_runlevel(char rl);
+void sysvinit_setenv(const char *name, const char *value);
+
+#endif