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 50... Line 50...
50
    .fs_handle = 0,
50
    .fs_handle = 0,
51
    .dev_handle = 0,
51
    .dev_handle = 0,
52
    .index = 0,
52
    .index = 0,
53
};
53
};
54
 
54
 
55
static int lookup_root(int fs_handle, int dev_handle, vfs_triplet_t *root)
55
static int lookup_root(int fs_handle, int dev_handle, vfs_triplet_t *root,
-
 
56
    size_t *size)
56
{
57
{
57
    vfs_pair_t altroot = {
58
    vfs_pair_t altroot = {
58
        .fs_handle = fs_handle,
59
        .fs_handle = fs_handle,
59
        .dev_handle = dev_handle,
60
        .dev_handle = dev_handle,
60
    };
61
    };
61
 
62
 
62
    return vfs_lookup_internal("/", strlen("/"), root, &altroot);
63
    return vfs_lookup_internal("/", strlen("/"), root, size, &altroot);
63
}
64
}
64
 
65
 
65
void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
66
void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
66
{
67
{
67
    int dev_handle;
68
    int dev_handle;
Line 158... Line 159...
158
     * node cannot be removed. However, we do take a reference to it so
159
     * node cannot be removed. However, we do take a reference to it so
159
     * that we can track how many times it has been mounted.
160
     * that we can track how many times it has been mounted.
160
     */
161
     */
161
    int rc;
162
    int rc;
162
    vfs_triplet_t mounted_root;
163
    vfs_triplet_t mounted_root;
-
 
164
    size_t mrsz;
163
    rc = lookup_root(fs_handle, dev_handle, &mounted_root);
165
    rc = lookup_root(fs_handle, dev_handle, &mounted_root, &mrsz);
164
    if (rc != EOK) {
166
    if (rc != EOK) {
165
        free(buf);
167
        free(buf);
166
        ipc_answer_0(rid, rc);
168
        ipc_answer_0(rid, rc);
167
        return;
169
        return;
168
    }
170
    }
169
    vfs_node_t *mr_node = vfs_node_get(&mounted_root);
171
    vfs_node_t *mr_node = vfs_node_get(&mounted_root, mrsz);
170
    if (!mr_node) {
172
    if (!mr_node) {
171
        free(buf);
173
        free(buf);
172
        ipc_answer_0(rid, ENOMEM);
174
        ipc_answer_0(rid, ENOMEM);
173
        return;
175
        return;
174
    }
176
    }
175
 
177
 
176
    /*
178
    /*
177
     * Finally, we need to resolve the path to the mountpoint.
179
     * Finally, we need to resolve the path to the mountpoint.
178
     */
180
     */
179
    vfs_triplet_t mp;
181
    vfs_triplet_t mp;
-
 
182
    size_t mpsz;
180
    futex_down(&rootfs_futex);
183
    futex_down(&rootfs_futex);
181
    if (rootfs.fs_handle) {
184
    if (rootfs.fs_handle) {
182
        /*
185
        /*
183
         * We already have the root FS.
186
         * We already have the root FS.
184
         */
187
         */
185
        rwlock_writer_lock(&namespace_rwlock);
188
        rwlock_writer_lock(&namespace_rwlock);
186
        rc = vfs_lookup_internal(buf, size, &mp, NULL);
189
        rc = vfs_lookup_internal(buf, size, &mp, &mpsz, NULL);
187
        if (rc != EOK) {
190
        if (rc != EOK) {
188
            /*
191
            /*
189
             * The lookup failed for some reason.
192
             * The lookup failed for some reason.
190
             */
193
             */
191
            rwlock_writer_unlock(&namespace_rwlock);
194
            rwlock_writer_unlock(&namespace_rwlock);
Line 193... Line 196...
193
            vfs_node_put(mr_node);  /* failed -> drop reference */
196
            vfs_node_put(mr_node);  /* failed -> drop reference */
194
            free(buf);
197
            free(buf);
195
            ipc_answer_0(rid, rc);
198
            ipc_answer_0(rid, rc);
196
            return;
199
            return;
197
        }
200
        }
198
        mp_node = vfs_node_get(&mp);
201
        mp_node = vfs_node_get(&mp, mpsz);
199
        if (!mp_node) {
202
        if (!mp_node) {
200
            rwlock_writer_unlock(&namespace_rwlock);
203
            rwlock_writer_unlock(&namespace_rwlock);
201
            futex_up(&rootfs_futex);
204
            futex_up(&rootfs_futex);
202
            vfs_node_put(mr_node);  /* failed -> drop reference */
205
            vfs_node_put(mr_node);  /* failed -> drop reference */
203
            free(buf);
206
            free(buf);