]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/initreq.h
Merge pull request #9942 from lucaswerkmeister/9939
[thirdparty/systemd.git] / src / shared / initreq.h
1 /*
2 * initreq.h Interface to talk to init through /dev/initctl.
3 *
4 * Copyright (C) 1995-2004 Miquel van Smoorenburg
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * Version: @(#)initreq.h 1.28 31-Mar-2004 MvS
12 */
13
14 #pragma once
15
16 #include <sys/param.h>
17
18 #if defined(__FreeBSD_kernel__)
19 # define INIT_FIFO "/etc/.initctl"
20 #else
21 # define INIT_FIFO "/dev/initctl"
22 #endif
23
24 #define INIT_MAGIC 0x03091969
25 #define INIT_CMD_START 0
26 #define INIT_CMD_RUNLVL 1
27 #define INIT_CMD_POWERFAIL 2
28 #define INIT_CMD_POWERFAILNOW 3
29 #define INIT_CMD_POWEROK 4
30 #define INIT_CMD_BSD 5
31 #define INIT_CMD_SETENV 6
32 #define INIT_CMD_UNSETENV 7
33
34 #define INIT_CMD_CHANGECONS 12345
35
36 #ifdef MAXHOSTNAMELEN
37 # define INITRQ_HLEN MAXHOSTNAMELEN
38 #else
39 # define INITRQ_HLEN 64
40 #endif
41
42 /*
43 * This is what BSD 4.4 uses when talking to init.
44 * Linux doesn't use this right now.
45 */
46 struct init_request_bsd {
47 char gen_id[8]; /* Beats me.. telnetd uses "fe" */
48 char tty_id[16]; /* Tty name minus /dev/tty */
49 char host[INITRQ_HLEN]; /* Hostname */
50 char term_type[16]; /* Terminal type */
51 int signal; /* Signal to send */
52 int pid; /* Process to send to */
53 char exec_name[128]; /* Program to execute */
54 char reserved[128]; /* For future expansion. */
55 };
56
57 /*
58 * Because of legacy interfaces, "runlevel" and "sleeptime"
59 * aren't in a separate struct in the union.
60 *
61 * The weird sizes are because init expects the whole
62 * struct to be 384 bytes.
63 */
64 struct init_request {
65 int magic; /* Magic number */
66 int cmd; /* What kind of request */
67 int runlevel; /* Runlevel to change to */
68 int sleeptime; /* Time between TERM and KILL */
69 union {
70 struct init_request_bsd bsd;
71 char data[368];
72 } i;
73 };