summaryrefslogtreecommitdiffstats
path: root/src/shared/initreq.h
blob: c6a105080592a745afe108f9bb887267a91e4b2e (plain)
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
/* SPDX-License-Identifier: LGPL-2.0-or-later */
/*
 * Copyright (C) 1995-2004 Miquel van Smoorenburg
 * Version:     @(#)initreq.h  1.28  31-Mar-2004 MvS
 */

#pragma once

#include <sys/param.h>

#if defined(__FreeBSD_kernel__)
#  define INIT_FIFO  "/etc/.initctl"
#else
#  define INIT_FIFO  "/dev/initctl"
#endif

#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

#define INIT_CMD_CHANGECONS	12345

#ifdef MAXHOSTNAMELEN
#  define INITRQ_HLEN	MAXHOSTNAMELEN
#else
#  define INITRQ_HLEN	64
#endif

/*
 *	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[INITRQ_HLEN];	/* 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 separate 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;
};