mkfs: drop support for running on DOS
[minix.git] / servers / iso9660fs / main.c
blobe4f59d854f75277d83e8f0b830762b1d8a4ad831
1 /* This file contains the main directory for the server. It waits for a
2 * request and then send a response. */
4 #include "inc.h"
5 #include <minix/vfsif.h>
6 #include <assert.h>
7 #include "const.h"
8 #include "glo.h"
10 /* Declare some local functions. */
11 static void get_work(message *m_in);
13 /* SEF functions and variables. */
14 static void sef_local_startup(void);
15 static int sef_cb_init_fresh(int type, sef_init_info_t *info);
16 static void sef_cb_signal_handler(int signo);
18 /*===========================================================================*
19 * main *
20 *===========================================================================*/
21 int main(void) {
22 endpoint_t who_e;
23 int ind, error, transid;
25 /* SEF local startup. */
26 sef_local_startup();
28 for (;;) {
30 /* Wait for request message. */
31 get_work(&fs_m_in);
33 transid = TRNS_GET_ID(fs_m_in.m_type);
34 fs_m_in.m_type = TRNS_DEL_ID(fs_m_in.m_type);
35 if (fs_m_in.m_type == 0) {
36 assert(!IS_VFS_FS_TRANSID(transid));
37 fs_m_in.m_type = transid; /* Backwards compat. */
38 transid = 0;
39 } else
40 assert(IS_VFS_FS_TRANSID(transid));
42 error = OK;
44 caller_uid = -1; /* To trap errors */
45 caller_gid = -1;
47 who_e = fs_m_in.m_source; /* source of the request */
49 if (who_e != VFS_PROC_NR) { /* If the message is not for us just
50 * continue */
51 continue;
54 req_nr = fs_m_in.m_type;
56 if (req_nr < VFS_BASE) {
57 fs_m_in.m_type += VFS_BASE;
58 req_nr = fs_m_in.m_type;
61 ind = req_nr-VFS_BASE;
63 if (ind < 0 || ind >= NREQS) {
64 error = EINVAL;
65 } else
66 error = (*fs_call_vec[ind])(); /* Process the request calling
67 * the appropriate function. */
69 fs_m_out.m_type = error;
70 if (IS_VFS_FS_TRANSID(transid)) {
71 /* If a transaction ID was set, reset it */
72 fs_m_out.m_type = TRNS_ADD_ID(fs_m_out.m_type, transid);
74 reply(who_e, &fs_m_out); /* returns the response to VFS */
78 /*===========================================================================*
79 * sef_local_startup *
80 *===========================================================================*/
81 static void sef_local_startup()
83 /* Register init callbacks. */
84 sef_setcb_init_fresh(sef_cb_init_fresh);
85 sef_setcb_init_restart(sef_cb_init_fail);
87 /* No live update support for now. */
89 /* Register signal callbacks. */
90 sef_setcb_signal_handler(sef_cb_signal_handler);
92 /* Let SEF perform startup. */
93 sef_startup();
96 /*===========================================================================*
97 * sef_cb_init_fresh *
98 *===========================================================================*/
99 static int sef_cb_init_fresh(int type, sef_init_info_t *info)
101 /* Initialize the iso9660fs server. */
103 /* SELF_E will contain the id of this process */
104 SELF_E = getprocnr();
105 /* hash_init(); */ /* Init the table with the ids */
106 setenv("TZ","",1); /* Used to calculate the time */
108 return(OK);
111 /*===========================================================================*
112 * sef_cb_signal_handler *
113 *===========================================================================*/
114 static void sef_cb_signal_handler(int signo)
116 /* Only check for termination signal, ignore anything else. */
117 if (signo != SIGTERM) return;
119 /* No need to do a sync, as this is a read-only file system. */
121 /* If the file system has already been unmounted, exit immediately.
122 * We might not get another message.
124 if (unmountdone) exit(0);
127 /*===========================================================================*
128 * get_work *
129 *===========================================================================*/
130 static void get_work(m_in)
131 message *m_in; /* pointer to message */
133 int s; /* receive status */
134 if (OK != (s = sef_receive(ANY, m_in))) /* wait for message */
135 panic("sef_receive failed: %d", s);
138 /*===========================================================================*
139 * reply *
140 *===========================================================================*/
141 void reply(who, m_out)
142 int who;
143 message *m_out; /* report result */
145 if (OK != send(who, m_out)) /* send the message */
146 printf("ISOFS(%d) was unable to send reply\n", SELF_E);