Subversion Repositories HelenOS

Rev

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

Rev 2546 Rev 2549
Line 49... Line 49...
49
 
49
 
50
atomic_t plb_futex = FUTEX_INITIALIZER;
50
atomic_t plb_futex = FUTEX_INITIALIZER;
51
link_t plb_head;    /**< PLB entry ring buffer. */
51
link_t plb_head;    /**< PLB entry ring buffer. */
52
uint8_t *plb = NULL;
52
uint8_t *plb = NULL;
53
 
53
 
-
 
54
/** Perform a path lookup.
-
 
55
 *
-
 
56
 * @param path      Path to be resolved; it needn't be an ASCIIZ string.
-
 
57
 * @param len       Number of path characters pointed by path.
-
 
58
 * @param result    Empty node structure where the result will be stored.
-
 
59
 * @param altroot   If non-empty, will be used instead of rootfs as the root
-
 
60
 *          of the whole VFS tree.
-
 
61
 *
-
 
62
 * @return      EOK on success or an error code from errno.h.
-
 
63
 */
54
int vfs_lookup_internal(char *path, size_t len, vfs_node_t *result)
64
int vfs_lookup_internal(char *path, size_t len, vfs_node_t *result,
-
 
65
    vfs_node_t *altroot)
55
{
66
{
-
 
67
    vfs_node_t *root;
-
 
68
 
56
    if (!len)
69
    if (!len)
57
        return EINVAL;
70
        return EINVAL;
58
 
71
 
-
 
72
    if (altroot)
-
 
73
        root = altroot;
-
 
74
    else
-
 
75
        root = rootfs;
-
 
76
 
59
    if (!rootfs)
77
    if (!root)
60
        return ENOENT;
78
        return ENOENT;
61
   
79
   
62
    futex_down(&plb_futex);
80
    futex_down(&plb_futex);
63
 
81
 
64
    plb_entry_t entry;
82
    plb_entry_t entry;
Line 123... Line 141...
123
   
141
   
124
    memcpy(&plb[first], path, cnt1);
142
    memcpy(&plb[first], path, cnt1);
125
    memcpy(plb, &path[cnt1], cnt2);
143
    memcpy(plb, &path[cnt1], cnt2);
126
 
144
 
127
    ipc_call_t answer;
145
    ipc_call_t answer;
128
    int phone = vfs_grab_phone(rootfs->fs_handle);
146
    int phone = vfs_grab_phone(root->fs_handle);
129
    aid_t req = async_send_3(phone, VFS_LOOKUP, (ipcarg_t) first,
147
    aid_t req = async_send_3(phone, VFS_LOOKUP, (ipcarg_t) first,
130
        (ipcarg_t) last, (ipcarg_t) rootfs->dev_handle, &answer);
148
        (ipcarg_t) last, (ipcarg_t) root->dev_handle, &answer);
131
    vfs_release_phone(phone);
149
    vfs_release_phone(phone);
132
 
150
 
133
    ipcarg_t rc;
151
    ipcarg_t rc;
134
    async_wait_for(req, &rc);
152
    async_wait_for(req, &rc);
135
 
153
 
136
    futex_down(&plb_futex);
154
    futex_down(&plb_futex);
137
    list_remove(&entry.plb_link);
155
    list_remove(&entry.plb_link);
-
 
156
    /*
-
 
157
     * Erasing the path from PLB will come handy for debugging purposes.
-
 
158
     */
-
 
159
    memset(&plb[first], 0, cnt1);
-
 
160
    memset(plb, 0, cnt2);
138
    futex_up(&plb_futex);
161
    futex_up(&plb_futex);
139
 
162
 
140
    if (rc == EOK) {
163
    if (rc == EOK) {
141
        result->fs_handle = (int) IPC_GET_ARG1(answer);
164
        result->fs_handle = (int) IPC_GET_ARG1(answer);
142
        result->dev_handle = (int) IPC_GET_ARG2(answer);
165
        result->dev_handle = (int) IPC_GET_ARG2(answer);