32,7 → 32,7 |
|
/** |
* @file vfs.c |
* @brief VFS multiplexer for HelenOS. |
* @brief VFS_REGISTER method. |
*/ |
|
#include <ipc/ipc.h> |
48,9 → 48,6 |
#include <libadt/list.h> |
#include "vfs.h" |
|
|
#define dprintf(...) printf(__VA_ARGS__) |
|
atomic_t fs_head_futex = FUTEX_INITIALIZER; |
link_t fs_head; |
|
137,7 → 134,7 |
* @param rid Hash of the call with the request. |
* @param request Call structure with the request. |
*/ |
static void vfs_register(ipc_callid_t rid, ipc_call_t *request) |
void vfs_register(ipc_callid_t rid, ipc_call_t *request) |
{ |
ipc_callid_t callid; |
ipc_call_t call; |
274,75 → 271,6 |
fs_info->vfs_info.name); |
} |
|
static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
bool keep_on_going = 1; |
|
printf("Connection opened from %p\n", icall->in_phone_hash); |
|
/* |
* The connection was opened via the IPC_CONNECT_ME_TO call. |
* This call needs to be answered. |
*/ |
ipc_answer_fast(iid, EOK, 0, 0); |
|
/* |
* Here we enter the main connection fibril loop. |
* The logic behind this loop and the protocol is that we'd like to keep |
* each connection open for a while before we close it. The benefit of |
* this is that the client doesn't have to establish a new connection |
* upon each request. On the other hand, the client must be ready to |
* re-establish a connection if we hang it up due to reaching of maximum |
* number of requests per connection or due to the client timing out. |
*/ |
|
while (keep_on_going) { |
ipc_callid_t callid; |
ipc_call_t call; |
|
callid = async_get_call(&call); |
|
printf("Received call, method=%d\n", IPC_GET_METHOD(call)); |
|
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
keep_on_going = false; |
break; |
case VFS_REGISTER: |
vfs_register(callid, &call); |
keep_on_going = false; |
break; |
case VFS_MOUNT: |
case VFS_UNMOUNT: |
case VFS_OPEN: |
case VFS_CREATE: |
case VFS_CLOSE: |
case VFS_READ: |
case VFS_WRITE: |
case VFS_SEEK: |
default: |
ipc_answer_fast(callid, ENOTSUP, 0, 0); |
break; |
} |
} |
|
/* TODO: cleanup after the client */ |
|
} |
|
int main(int argc, char **argv) |
{ |
ipcarg_t phonead; |
|
printf("VFS: HelenOS VFS server\n"); |
|
list_initialize(&fs_head); |
async_set_client_connection(vfs_connection); |
ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, &phonead); |
async_manager(); |
return 0; |
} |
|
/** |
* @} |
*/ |