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
< FS_BASE
) {
57 fs_m_in
.m_type
+= FS_BASE
;
58 req_nr
= fs_m_in
.m_type
;
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 /* hash_init(); */ /* Init the table with the ids */
106 setenv("TZ","",1); /* Used to calculate the time */
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 /*===========================================================================*
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 /*===========================================================================*
140 *===========================================================================*/
141 void reply(who
, m_out
)
143 message
*m_out
; /* report result */
145 if (OK
!= ipc_send(who
, m_out
)) /* send the message */
146 printf("ISOFS(%d) was unable to send reply\n", sef_self());