test41: relax maximum timer tick rate
[minix.git] / servers / iso9660fs / main.c
blob8fae36a669cbd620ccb4ca9ada32da230a67849d
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();
95 lmfs_buf_pool(10);
98 /*===========================================================================*
99 * sef_cb_init_fresh *
100 *===========================================================================*/
101 static int sef_cb_init_fresh(int type, sef_init_info_t *info)
103 /* Initialize the iso9660fs server. */
105 /* SELF_E will contain the id of this process */
106 SELF_E = getprocnr();
107 /* hash_init(); */ /* Init the table with the ids */
108 setenv("TZ","",1); /* Used to calculate the time */
110 return(OK);
113 /*===========================================================================*
114 * sef_cb_signal_handler *
115 *===========================================================================*/
116 static void sef_cb_signal_handler(int signo)
118 /* Only check for termination signal, ignore anything else. */
119 if (signo != SIGTERM) return;
121 /* No need to do a sync, as this is a read-only file system. */
123 /* If the file system has already been unmounted, exit immediately.
124 * We might not get another message.
126 if (unmountdone) exit(0);
129 /*===========================================================================*
130 * get_work *
131 *===========================================================================*/
132 static void get_work(m_in)
133 message *m_in; /* pointer to message */
135 int s; /* receive status */
136 if (OK != (s = sef_receive(ANY, m_in))) /* wait for message */
137 panic("sef_receive failed: %d", s);
140 /*===========================================================================*
141 * reply *
142 *===========================================================================*/
143 void reply(who, m_out)
144 int who;
145 message *m_out; /* report result */
147 if (OK != send(who, m_out)) /* send the message */
148 printf("ISOFS(%d) was unable to send reply\n", SELF_E);