43,12 → 43,8 |
#include <bool.h> |
#include <futex.h> |
#include <libadt/list.h> |
#include <sys/types.h> |
#include "vfs.h" |
|
/** Per-connection futex protecting the files array. */ |
__thread atomic_t files_futex = FUTEX_INITIALIZER; |
|
/** |
* This is a per-connection table of open files. |
* Our assumption is that each client opens only one connection and therefore |
57,34 → 53,18 |
* several tables and several file handle name spaces per task. Besides of this, |
* the functionality will stay unchanged. So unless the client knows what it is |
* doing, it should open one connection to VFS only. |
* |
* Allocation of the open files table is deferred until the client makes the |
* first VFS_OPEN operation. |
*/ |
__thread vfs_file_t *files = NULL; |
__thread vfs_file_t files[MAX_OPEN_FILES]; |
|
/** Initialize the table of open files. */ |
static bool vfs_conn_open_files_init(void) |
bool vfs_conn_open_files_init(void) |
{ |
futex_down(&files_futex); |
if (!files) { |
files = malloc(MAX_OPEN_FILES * sizeof(vfs_file_t)); |
if (!files) { |
futex_up(&files_futex); |
return false; |
} |
memset(files, 0, MAX_OPEN_FILES * sizeof(vfs_file_t)); |
} |
futex_up(&files_futex); |
memset(files, 0, MAX_OPEN_FILES * sizeof(vfs_file_t)); |
return true; |
} |
|
void vfs_open(ipc_callid_t rid, ipc_call_t *request) |
{ |
if (!vfs_conn_open_files_init()) { |
ipc_answer_fast_0(rid, ENOMEM); |
return; |
} |
} |
|
/** |