Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev HEAD → Rev 3022

/branches/dd/uspace/srv/vfs/vfs.c
28,11 → 28,11
 
/** @addtogroup fs
* @{
*/
*/
 
/**
* @file vfs.c
* @brief VFS service for HelenOS.
* @file vfs.c
* @brief VFS service for HelenOS.
*/
 
#include <ipc/ipc.h>
43,21 → 43,24
#include <bool.h>
#include <string.h>
#include <as.h>
#include <libadt/list.h>
#include <atomic.h>
#include "vfs.h"
 
#define NAME "vfs"
#define dprintf(...) printf(__VA_ARGS__)
 
static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall)
{
bool keep_on_going = true;
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_0(iid, EOK);
 
/*
* Here we enter the main connection fibril loop.
* The logic behind this loop and the protocol is that we'd like to keep
69,101 → 72,98
* connection later.
*/
while (keep_on_going) {
ipc_callid_t callid;
ipc_call_t call;
ipc_callid_t callid = async_get_call(&call);
 
callid = async_get_call(&call);
 
printf("Received call, method=%d\n", IPC_GET_METHOD(call));
fs_handle_t fs_handle;
int phone;
switch (IPC_GET_METHOD(call)) {
case IPC_M_PHONE_HUNGUP:
keep_on_going = false;
break;
case VFS_IN_REGISTER:
case VFS_REGISTER:
vfs_register(callid, &call);
keep_on_going = false;
break;
case VFS_IN_MOUNT:
case VFS_MOUNT:
vfs_mount(callid, &call);
break;
case VFS_IN_OPEN:
case VFS_OPEN:
vfs_open(callid, &call);
break;
case VFS_IN_OPEN_NODE:
vfs_open_node(callid, &call);
break;
case VFS_IN_CLOSE:
case VFS_CLOSE:
vfs_close(callid, &call);
break;
case VFS_IN_READ:
case VFS_READ:
vfs_read(callid, &call);
break;
case VFS_IN_WRITE:
case VFS_WRITE:
vfs_write(callid, &call);
break;
case VFS_IN_SEEK:
case VFS_SEEK:
vfs_seek(callid, &call);
break;
case VFS_IN_TRUNCATE:
case VFS_TRUNCATE:
vfs_truncate(callid, &call);
break;
case VFS_IN_FSTAT:
vfs_fstat(callid, &call);
break;
case VFS_IN_STAT:
vfs_stat(callid, &call);
break;
case VFS_IN_MKDIR:
case VFS_MKDIR:
vfs_mkdir(callid, &call);
break;
case VFS_IN_UNLINK:
case VFS_UNLINK:
vfs_unlink(callid, &call);
break;
case VFS_IN_RENAME:
case VFS_RENAME:
vfs_rename(callid, &call);
break;
case VFS_IN_SYNC:
vfs_sync(callid, &call);
break;
default:
ipc_answer_0(callid, ENOTSUP);
break;
}
}
 
/* TODO: cleanup after the client */
/* TODO: cleanup after the client */
}
 
int main(int argc, char **argv)
{
printf(NAME ": HelenOS VFS server\n");
ipcarg_t phonead;
 
printf("VFS: HelenOS VFS server\n");
 
/*
* Initialize the list of registered file systems.
*/
list_initialize(&fs_head);
 
/*
* Initialize VFS node hash table.
*/
if (!vfs_nodes_init()) {
printf(NAME ": Failed to initialize VFS node hash table\n");
printf("Failed to initialize the VFS node hash table.\n");
return ENOMEM;
}
 
/*
* Allocate and initialize the Path Lookup Buffer.
*/
list_initialize(&plb_head);
plb = as_get_mappable_page(PLB_SIZE);
if (!plb) {
printf(NAME ": Cannot allocate a mappable piece of address space\n");
printf("Cannot allocate a mappable piece of address space\n");
return ENOMEM;
}
if (as_area_create(plb, PLB_SIZE, AS_AREA_READ | AS_AREA_WRITE |
AS_AREA_CACHEABLE) != plb) {
printf(NAME ": Cannot create address space area\n");
printf("Cannot create address space area.\n");
return ENOMEM;
}
memset(plb, 0, PLB_SIZE);
/*
* Set a connection handling function/fibril.
* Set a connectio handling function/fibril.
*/
async_set_client_connection(vfs_connection);
 
170,13 → 170,11
/*
* Register at the naming service.
*/
ipcarg_t phonead;
ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, &phonead);
 
/*
* Start accepting connections.
*/
printf(NAME ": Accepting connections\n");
async_manager();
return 0;
}
183,4 → 181,4
 
/**
* @}
*/
*/