Subversion Repositories HelenOS

Rev

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

Rev 2679 Rev 2681
Line 36... Line 36...
36
 */
36
 */
37
 
37
 
38
#include <ipc/ipc.h>
38
#include <ipc/ipc.h>
39
#include <async.h>
39
#include <async.h>
40
#include <errno.h>
40
#include <errno.h>
41
#include <futex.h>
41
#include <rwlock.h>
42
#include <sys/types.h>
42
#include <sys/types.h>
43
#include <stdlib.h>
43
#include <stdlib.h>
44
#include "vfs.h"
44
#include "vfs.h"
45
 
45
 
46
void vfs_open(ipc_callid_t rid, ipc_call_t *request)
46
void vfs_open(ipc_callid_t rid, ipc_call_t *request)
Line 91... Line 91...
91
    /*
91
    /*
92
     * Avoid the race condition in which the file can be deleted before we
92
     * Avoid the race condition in which the file can be deleted before we
93
     * find/create-and-lock the VFS node corresponding to the looked-up
93
     * find/create-and-lock the VFS node corresponding to the looked-up
94
     * triplet.
94
     * triplet.
95
     */
95
     */
96
    futex_down(&namespace_futex);
96
    rwlock_reader_lock(&namespace_rwlock);
97
 
97
 
98
    /*
98
    /*
99
     * The path is now populated and we can call vfs_lookup_internal().
99
     * The path is now populated and we can call vfs_lookup_internal().
100
     */
100
     */
101
    vfs_triplet_t triplet;
101
    vfs_triplet_t triplet;
102
    rc = vfs_lookup_internal(path, size, &triplet, NULL);
102
    rc = vfs_lookup_internal(path, size, &triplet, NULL);
103
    if (rc) {
103
    if (rc) {
104
        futex_up(&namespace_futex);
104
        rwlock_reader_unlock(&namespace_rwlock);
105
        ipc_answer_0(rid, rc);
105
        ipc_answer_0(rid, rc);
106
        free(path);
106
        free(path);
107
        return;
107
        return;
108
    }
108
    }
109
 
109
 
Line 111... Line 111...
111
     * Path is no longer needed.
111
     * Path is no longer needed.
112
     */
112
     */
113
    free(path);
113
    free(path);
114
 
114
 
115
    vfs_node_t *node = vfs_node_get(&triplet);
115
    vfs_node_t *node = vfs_node_get(&triplet);
116
    futex_up(&namespace_futex);
116
    rwlock_reader_unlock(&namespace_rwlock);
117
 
117
 
118
    /*
118
    /*
119
     * Get ourselves a file descriptor and the corresponding vfs_file_t
119
     * Get ourselves a file descriptor and the corresponding vfs_file_t
120
     * structure.
120
     * structure.
121
     */
121
     */