diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-01-06 17:04:28 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-01-06 17:04:28 +0200 |
commit | 1bfa33ac7c167cd863b88a5cac7690d511851e6e (patch) | |
tree | a892e281cba3ea127af5faf5da81ff2cc0c3aae9 /src/pies.h | |
parent | 4f7c28158308563dcad912d87a0031d095d4690a (diff) | |
download | pies-1bfa33ac7c167cd863b88a5cac7690d511851e6e.tar.gz pies-1bfa33ac7c167cd863b88a5cac7690d511851e6e.tar.bz2 |
Fix runlevel transition algorithm, implement SysV-style fifo interface.
* src/prog.h: New file.
* src/Makefile.am: Add new file.
* src/cmdline.opt: New option --telinit (-T).
* src/diag.c (vlogmsg): In sysvin it mode, write
directly to the console. Close it when finished.
* src/pies.c (_cb_initdefault, _cb_runlevels): Use is_valid_runlevel
to check if the specified runlevels are ok.
(main): In sysvinit mode, reset action to ACTION_CONT.
* src/pies.h (progman_filter): New proto.
(progman_accept,register_socket): Change signature.
(deregister_socket): New proto.
(register_program_socket): New proto.
* src/progman.c: Move constant and adatatype definitions to
prog.h
(prog_stop): Remove static qualifier.
(console_open): Likewise.
(progman_accept): Use new socket API.
(progman_stop): Correctly handle timeouts.
(progman_foreach): New function.
* src/socket.c: Register all sockets along with their handlers
in a doubly-linked list.
(sockinst): New struct.
(register_socket,deregister_socket): New functions.
(register_program_socket): New function.
(pies_pause): Traverse the list to find which fd has changed.
Use its registered handler to handle the event.
* src/sysvinit.c: Include prog.h
(is_valid_runlevel): New function.
(sysvinit_fifo_handler,check_fifo): New static functions.
(inittrans): Fix transition algorithm.
(telinit): New function.
Diffstat (limited to 'src/pies.h')
-rw-r--r-- | src/pies.h | 36 |
1 files changed, 34 insertions, 2 deletions
@@ -282,17 +282,19 @@ void register_prog (struct component *comp); int progman_running_p (void); size_t progman_running_count (void); void progman_start (void); void progman_wake_sleeping (int); void progman_stop (void); void progman_cleanup (int expect_term); +void progman_filter (int (*filter) (struct component *, void *data), + void *data); void progman_stop_component (const char *name); void progman_dump_stats (const char *filename); void progman_dump_prereq (void); void progman_dump_depmap (void); -int progman_accept (int socket); +int progman_accept (int socket, void *data); int progman_build_depmap (void); void progman_create_sockets (void); struct component *progman_lookup_component (const char *tag); struct component *progman_lookup_tcpmux (const char *service, const char *master); @@ -359,13 +361,16 @@ struct pies_url int pies_url_create (struct pies_url **purl, const char *str); void pies_url_destroy (struct pies_url **purl); const char * pies_url_get_arg (struct pies_url *url, const char *argname); void pies_pause (void); -int register_socket (int socktype, int fd); +void *register_socket (int fd, int (*handler) (int, void *), void *data); +void deregister_socket (int fd); + +int register_program_socket (int socktype, int fd, void *data); int pass_fd (const char *socket, int fd, unsigned time_out); int create_socket (struct pies_url *url, int socket_type, const char *user, mode_t umask); void disable_socket (int fd); void enable_socket (int fd); @@ -453,12 +458,39 @@ struct inetd_builtin struct inetd_builtin *inetd_builtin_lookup (const char *service, int socktype); /* sysvinit.c */ void sysvinit_begin (void); int inittrans (void); int is_comp_wait (struct component *comp); +int is_valid_runlevel (int c); + +#ifndef INIT_FIFO +# 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 + +struct sysvinit_request { + int magic; /* Magic number */ + int cmd; /* What kind of request */ + int runlevel; /* Runlevel to change to */ + int sleeptime; /* Time between TERM and KILL */ + char pad[368]; +}; + + /* utmp.c */ #define SYSV_ACCT_BOOT 0 #define SYSV_ACCT_RUNLEVEL 1 #define SYSV_ACCT_PROC_START 2 #define SYSV_ACCT_PROC_STOP 3 |