41,7 → 41,7 |
#include <async.h> |
#include <errno.h> |
#include <unistd.h> |
#include <stdio.h>> |
#include <stdio.h> |
#include "../../vfs/vfs.h" |
|
#define dprintf(...) printf(__VA_ARGS__) |
62,20 → 62,48 |
} |
}; |
|
/** |
* This connection fibril processes VFS requests from VFS. |
* |
* In order to support simultaneous VFS requests, our design is as follows. |
* The connection fibril accepts VFS requests from VFS. If there is only one |
* instance of the fibril, VFS will need to serialize all VFS requests it sends |
* to FAT. To overcome this bottleneck, VFS can send FAT the IPC_M_CONNECT_ME_TO |
* call. In that case, a new connection fibril will be created, which in turn |
* will accept the call. Thus, a new phone will be opened for VFS. |
* |
* There are few issues with this arrangement. First, VFS can run out of |
* available phones. In that case, VFS can close some other phones or use one |
* phone for more serialized requests. Similarly, FAT can refuse to duplicate |
* the connection. VFS should then just make use of already existing phones and |
* route its requests through them. To avoid paying the fibril creation price |
* upon each request, FAT might want to keep the connections open after the |
* request has been completed. |
*/ |
static void fat_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
if (iid) { |
/* |
* This fibril processes request from the VFS server. |
* This only happens for connections opened by |
* IPC_M_CONNECT_ME_TO calls as opposed to callback connections |
* created by IPC_M_CONNECT_TO_ME. |
*/ |
void fat_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
dprintf("Callback connection established.\n"); |
ipc_answer_fast(iid, EOK, 0, 0); |
} |
|
dprintf("VFS-FAT connection established.\n"); |
while (1) { |
ipc_callid_t callid; |
ipc_call_t call; |
|
callid = async_get_call(&call); |
switch (IPC_GET_METHOD(call)) { |
default: |
ipc_answer_fast(callid, ENOTSUP, 0, 0); |
break; |
} |
} |
} |
|
int main(int argc, char **argv) |
{ |
112,14 → 140,25 |
ipcarg_t phonehash; |
ipc_connect_to_me(vfs_phone, 0, 0, &phonehash); |
|
/* |
* Create a connection fibril to handle the callback connection. |
*/ |
async_new_connection(phonehash, 0, NULL, fat_connection); |
|
/* |
* Tell the async framework that other connections are to be handled by |
* the same connection fibril as well. |
*/ |
async_set_client_connection(fat_connection); |
|
/* |
* Pick up the answer for the request to the VFS_REQUEST call. |
*/ |
async_wait_for(req, NULL); |
dprintf("FAT filesystem registered.\n"); |
|
async_create_manager(); |
|
/* |
* TODO: Interestingly, if we merely return, the only thread dies. |
* If the only thread dies, the whole task is destroyed. |