1 /* This file contains the main directory for the server. It waits for a
2 * request and then send a response. */
5 #include <minix/vfsif.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 /*===========================================================================*
20 *===========================================================================*/
23 int ind
, error
, transid
;
25 /* SEF local startup. */
30 /* Wait for request message. */
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. */
40 assert(IS_VFS_FS_TRANSID(transid
));
44 caller_uid
= -1; /* To trap errors */
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
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
) {
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 /*===========================================================================*
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. */
98 /*===========================================================================*
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 */
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 /*===========================================================================*
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 /*===========================================================================*
142 *===========================================================================*/
143 void reply(who
, m_out
)
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
);