4 /* Library-local variables. */
7 int fsdriver_mounted
= FALSE
;
9 static int fsdriver_running
;
12 * Process an incoming VFS request, and send a reply. If the message is not
13 * a file system request from VFS, pass it on to the generic message handler.
14 * Multithreaded file systems should indicate that the reply is to be sent to
18 fsdriver_process(const struct fsdriver
* __restrict fdp
,
19 const message
* __restrict m_ptr
, int ipc_status
, int asyn_reply
)
25 /* Is this a file system request at all? */
26 if (is_ipc_notify(ipc_status
) || m_ptr
->m_source
!= VFS_PROC_NR
) {
27 if (fdp
->fdr_other
!= NULL
)
28 fdp
->fdr_other(m_ptr
, ipc_status
);
30 return; /* do not send a reply */
33 /* Call the appropriate function. */
34 transid
= TRNS_GET_ID(m_ptr
->m_type
);
35 call_nr
= TRNS_DEL_ID(m_ptr
->m_type
);
37 memset(&m_out
, 0, sizeof(m_out
));
39 if (fsdriver_mounted
|| call_nr
== REQ_READSUPER
) {
40 call_nr
-= FS_BASE
; /* unsigned; wrapping is intended */
42 if (call_nr
< NREQS
&& fsdriver_callvec
[call_nr
] != NULL
)
43 r
= (fsdriver_callvec
[call_nr
])(fdp
, m_ptr
, &m_out
);
50 m_out
.m_type
= TRNS_ADD_ID(r
, transid
);
53 r
= asynsend(m_ptr
->m_source
, &m_out
);
55 r
= ipc_send(m_ptr
->m_source
, &m_out
);
58 printf("fsdriver: sending reply failed (%d)\n", r
);
60 if (fdp
->fdr_postcall
!= NULL
)
65 * Terminate the file server as soon as the file system has been unmounted.
68 fsdriver_terminate(void)
71 fsdriver_running
= FALSE
;
77 * Main program of any file server task.
80 fsdriver_task(struct fsdriver
* fdp
)
85 fsdriver_running
= TRUE
;
87 while (fsdriver_running
|| fsdriver_mounted
) {
88 if ((r
= sef_receive_status(ANY
, &mess
, &ipc_status
)) != OK
) {
90 continue; /* sef_cancel() was called */
92 panic("fsdriver: sef_receive_status failed: %d", r
);
95 fsdriver_process(fdp
, &mess
, ipc_status
, FALSE
/*asyn_reply*/);