Subversion Repositories HelenOS

Rev

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

Rev 2681 Rev 2687
Line 55... Line 55...
55
     * We can receive flags and mode along with the VFS_OPEN call; the path
55
     * We can receive flags and mode along with the VFS_OPEN call; the path
56
     * will need to arrive in another call.
56
     * will need to arrive in another call.
57
     */
57
     */
58
    int flags = IPC_GET_ARG1(*request);
58
    int flags = IPC_GET_ARG1(*request);
59
    int mode = IPC_GET_ARG2(*request);
59
    int mode = IPC_GET_ARG2(*request);
60
    size_t size;
60
    size_t len;
61
 
61
 
62
    ipc_callid_t callid;
62
    ipc_callid_t callid;
63
 
63
 
64
    if (!ipc_data_write_receive(&callid, &size)) {
64
    if (!ipc_data_write_receive(&callid, &len)) {
65
        ipc_answer_0(callid, EINVAL);
65
        ipc_answer_0(callid, EINVAL);
66
        ipc_answer_0(rid, EINVAL);
66
        ipc_answer_0(rid, EINVAL);
67
        return;
67
        return;
68
    }
68
    }
69
 
69
 
Line 71... Line 71...
71
     * Now we are on the verge of accepting the path.
71
     * Now we are on the verge of accepting the path.
72
     *
72
     *
73
     * There is one optimization we could do in the future: copy the path
73
     * There is one optimization we could do in the future: copy the path
74
     * directly into the PLB using some kind of a callback.
74
     * directly into the PLB using some kind of a callback.
75
     */
75
     */
76
    char *path = malloc(size);
76
    char *path = malloc(len);
77
   
77
   
78
    if (!path) {
78
    if (!path) {
79
        ipc_answer_0(callid, ENOMEM);
79
        ipc_answer_0(callid, ENOMEM);
80
        ipc_answer_0(rid, ENOMEM);
80
        ipc_answer_0(rid, ENOMEM);
81
        return;
81
        return;
82
    }
82
    }
83
 
83
 
84
    int rc;
84
    int rc;
85
    if ((rc = ipc_data_write_finalize(callid, path, size))) {
85
    if ((rc = ipc_data_write_finalize(callid, path, len))) {
86
        ipc_answer_0(rid, rc);
86
        ipc_answer_0(rid, rc);
87
        free(path);
87
        free(path);
88
        return;
88
        return;
89
    }
89
    }
90
   
90
   
Line 97... Line 97...
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
    size_t size;
102
    rc = vfs_lookup_internal(path, size, &triplet, NULL);
103
    rc = vfs_lookup_internal(path, len, &triplet, &size, NULL);
103
    if (rc) {
104
    if (rc) {
104
        rwlock_reader_unlock(&namespace_rwlock);
105
        rwlock_reader_unlock(&namespace_rwlock);
105
        ipc_answer_0(rid, rc);
106
        ipc_answer_0(rid, rc);
106
        free(path);
107
        free(path);
107
        return;
108
        return;
Line 110... Line 111...
110
    /*
111
    /*
111
     * Path is no longer needed.
112
     * Path is no longer needed.
112
     */
113
     */
113
    free(path);
114
    free(path);
114
 
115
 
115
    vfs_node_t *node = vfs_node_get(&triplet);
116
    vfs_node_t *node = vfs_node_get(&triplet, size);
116
    rwlock_reader_unlock(&namespace_rwlock);
117
    rwlock_reader_unlock(&namespace_rwlock);
117
 
118
 
118
    /*
119
    /*
119
     * Get ourselves a file descriptor and the corresponding vfs_file_t
120
     * Get ourselves a file descriptor and the corresponding vfs_file_t
120
     * structure.
121
     * structure.