Subversion Repositories HelenOS

Rev

Rev 4439 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4439 Rev 4537
Line 38... Line 38...
38
#include <errno.h>
38
#include <errno.h>
39
#include <stdlib.h>
39
#include <stdlib.h>
40
#include <string.h>
40
#include <string.h>
41
#include <assert.h>
41
#include <assert.h>
42
#include <bool.h>
42
#include <bool.h>
-
 
43
#include <fibril.h>
-
 
44
#include <fibril_sync.h>
43
#include "vfs.h"
45
#include "vfs.h"
44
 
46
 
45
/**
47
/**
46
 * This is a per-connection table of open files.
48
 * This is a per-connection table of open files.
47
 * Our assumption is that each client opens only one connection and therefore
49
 * Our assumption is that each client opens only one connection and therefore
Line 55... Line 57...
55
 * first VFS_OPEN operation.
57
 * first VFS_OPEN operation.
56
 *
58
 *
57
 * This resource being per-connection and, in the first place, per-fibril, we
59
 * This resource being per-connection and, in the first place, per-fibril, we
58
 * don't need to protect it by a futex.
60
 * don't need to protect it by a futex.
59
 */
61
 */
60
__thread vfs_file_t **files = NULL;
62
fibril_local vfs_file_t **files = NULL;
61
 
63
 
62
/** Initialize the table of open files. */
64
/** Initialize the table of open files. */
63
bool vfs_files_init(void)
65
bool vfs_files_init(void)
64
{
66
{
65
    if (!files) {
67
    if (!files) {
Line 87... Line 89...
87
            files[i] = (vfs_file_t *) malloc(sizeof(vfs_file_t));
89
            files[i] = (vfs_file_t *) malloc(sizeof(vfs_file_t));
88
            if (!files[i])
90
            if (!files[i])
89
                return ENOMEM;
91
                return ENOMEM;
90
           
92
           
91
            memset(files[i], 0, sizeof(vfs_file_t));
93
            memset(files[i], 0, sizeof(vfs_file_t));
92
            futex_initialize(&files[i]->lock, 1);
94
            fibril_mutex_initialize(&files[i]->lock);
93
            vfs_file_addref(files[i]);
95
            vfs_file_addref(files[i]);
94
            return (int) i;
96
            return (int) i;
95
        }
97
        }
96
    }
98
    }
97
   
99