xref: /minix/minix/servers/rs/proto.h (revision d2532d3d)
1 /* Function prototypes. */
2 
3 /* Structs used in prototypes must be declared as such first. */
4 struct rproc;
5 struct rprocupd;
6 
7 /* exec.c */
8 int srv_execve(int proc_e, char *exec, size_t exec_len, char *progname,
9 	char *argv[], char **env);
10 
11 /* main.c */
12 int main(void);
13 
14 /* request.c */
15 int do_up(message *m);
16 int do_down(message *m);
17 int do_refresh(message *m);
18 int do_restart(message *m);
19 int do_clone(message *m);
20 int do_unclone(message *m);
21 int do_edit(message *m);
22 int do_shutdown(message *m);
23 void do_period(message *m);
24 int do_init_ready(message *m);
25 int do_update(message *m);
26 int do_upd_ready(message *m);
27 void do_sigchld(void);
28 int do_getsysinfo(message *m);
29 int do_lookup(message *m);
30 int do_sysctl(message *m);
31 int do_fi(message *m);
32 
33 /* manager.c */
34 int check_call_permission(endpoint_t caller, int call, struct rproc
35 	*rp);
36 int copy_rs_start(endpoint_t src_e, char *src_rs_start, struct rs_start
37 	*rs_start);
38 int copy_label(endpoint_t src_e, char *src_label, size_t src_len, char
39 	*dst_label, size_t dst_len);
40 int init_state_data(endpoint_t src_e, int prepare_state,
41 	struct rs_state_data *src_rs_state_data,
42 	struct rs_state_data *dst_rs_state_data);
43 void build_cmd_dep(struct rproc *rp);
44 #define kill_service(rp, errstr, err) \
45 	kill_service_debug(__FILE__, __LINE__, rp, errstr, err)
46 int kill_service_debug(char *file, int line, struct rproc *rp, char
47 	*errstr, int err);
48 #define crash_service(rp) \
49 	crash_service_debug(__FILE__, __LINE__, rp)
50 int crash_service_debug(char *file, int line, struct rproc *rp);
51 #define cleanup_service(rp) \
52 	cleanup_service_debug(__FILE__, __LINE__, rp)
53 #define cleanup_service_now(rp) \
54 	do { struct rproc *rpt = rp; cleanup_service(rpt); cleanup_service(rpt); } while(0)
55 void cleanup_service_debug(char *file, int line,
56 	struct rproc *rp);
57 #define detach_service(rp) \
58 	detach_service_debug(__FILE__, __LINE__, rp)
59 void detach_service_debug(char *file, int line,
60 	struct rproc *rp);
61 int create_service(struct rproc *rp);
62 int clone_service(struct rproc *rp, int instance_flag, int init_flags);
63 int publish_service(struct rproc *rp);
64 int unpublish_service(struct rproc *rp);
65 int run_service(struct rproc *rp, int init_type, int init_flags);
66 int start_service(struct rproc *rp, int init_flags);
67 void stop_service(struct rproc *rp,int how);
68 void activate_service(struct rproc *rp, struct rproc *ex_rp);
69 void terminate_service(struct rproc *rp);
70 void restart_service(struct rproc *rp);
71 void inherit_service_defaults(struct rproc *def_rp,
72 	struct rproc *rp);
73 void get_service_instances(struct rproc *rp, struct rproc ***rps,
74 	int *length);
75 int read_exec(struct rproc *rp);
76 void share_exec(struct rproc *rp_src, struct rproc *rp_dst);
77 void free_exec(struct rproc *rp);
78 int init_slot(struct rproc *rp, struct rs_start *rs_start,
79 	endpoint_t source);
80 int edit_slot(struct rproc *rp, struct rs_start *rs_start,
81 	endpoint_t source);
82 int clone_slot(struct rproc *rp, struct rproc **clone_rpp);
83 void swap_slot(struct rproc **src_rpp, struct rproc **dst_rpp);
84 struct rproc* lookup_slot_by_label(char *label);
85 struct rproc* lookup_slot_by_pid(pid_t pid);
86 struct rproc* lookup_slot_by_dev_nr(dev_t dev_nr);
87 struct rproc* lookup_slot_by_flags(int flags);
88 int alloc_slot(struct rproc **rpp);
89 void free_slot(struct rproc *rp);
90 char *get_next_label(char *ptr, char *label, char *caller_label);
91 void add_forward_ipc(struct rproc *rp, struct priv *privp);
92 void add_backward_ipc(struct rproc *rp, struct priv *privp);
93 void init_privs(struct rproc *rp, struct priv *privp);
94 void end_srv_init(struct rproc *rp);
95 
96 /* update.c */
97 void rupdate_clear_upds(void);
98 void rupdate_add_upd(struct rprocupd* rpupd);
99 void rupdate_set_new_upd_flags(struct rprocupd* rpupd);
100 void rupdate_upd_init(struct rprocupd* rpupd, struct rproc *rp);
101 void rupdate_upd_clear(struct rprocupd* rpupd);
102 void rupdate_upd_move(struct rproc* src_rp, struct rproc* dst_rp);
103 #define request_prepare_update_service(rp, state) \
104 	request_prepare_update_service_debug(__FILE__, __LINE__, rp, state)
105 void request_prepare_update_service_debug(char *file, int line,
106 	struct rproc *rp, int state);
107 int srv_update(endpoint_t src_e, endpoint_t dst_e, int sys_upd_flags);
108 int update_service(struct rproc **src_rpp,
109 	struct rproc **dst_rpp, int swap_flag, int sys_upd_flags);
110 void rollback_service(struct rproc **src_rpp,
111 	struct rproc **dst_rpp);
112 void update_period(message *m_ptr);
113 int start_update_prepare(int allow_retries);
114 struct rprocupd* start_update_prepare_next(void);
115 int start_update(void);
116 int start_srv_update(struct rprocupd *rpupd);
117 int complete_srv_update(struct rprocupd *rpupd);
118 void end_srv_update(struct rprocupd *rpupd, int result, int reply_flag);
119 int abort_update_proc(int reason);
120 #define end_update(result, reply_flag) \
121 	end_update_debug(__FILE__, __LINE__, result, reply_flag)
122 void end_update_debug(char *file, int line,
123         int result, int reply_flag);
124 
125 /* utility.c */
126 int init_service(struct rproc *rp, int type, int flags);
127 int fi_service(struct rproc *rp);
128 void fill_send_mask(sys_map_t *send_mask, int set_bits);
129 void fill_call_mask( int *calls, int tot_nr_calls,
130 	bitchunk_t *call_mask, int call_base, int is_init);
131 #define srv_to_string(RP) srv_to_string_gen(RP, DEBUG)
132 char* srv_to_string_gen(struct rproc *rp, int is_verbose);
133 char* srv_upd_to_string(struct rprocupd *rpupd);
134 int rs_asynsend(struct rproc *rp, message *m_ptr, int no_reply);
135 int rs_receive_ticks(endpoint_t src, message *m_ptr,
136     int *status_ptr, clock_t ticks);
137 void reply(endpoint_t who, struct rproc *rp, message *m_ptr);
138 void late_reply(struct rproc *rp, int code);
139 int rs_isokendpt(endpoint_t endpoint, int *proc);
140 int sched_init_proc(struct rproc *rp);
141 int update_sig_mgrs(struct rproc *rp, endpoint_t sig_mgr,
142 	endpoint_t bak_sig_mgr);
143 int rs_is_idle(void);
144 void rs_idle_period(void);
145 void print_services_status(void);
146 void print_update_status(void);
147 
148 /* error.c */
149 char * init_strerror(int errnum);
150 char * lu_strerror(int errnum);
151 
152