Subversion Repositories HelenOS

Rev

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

Rev 2552 Rev 2553
Line 43... Line 43...
43
#include <bool.h>
43
#include <bool.h>
44
#include <futex.h>
44
#include <futex.h>
45
#include <libadt/list.h>
45
#include <libadt/list.h>
46
#include "vfs.h"
46
#include "vfs.h"
47
 
47
 
-
 
48
atomic_t rootfs_futex = FUTEX_INITIALIZER;
48
vfs_node_t rootfs = { 0 };
49
vfs_node_t rootfs = { 0 };
49
 
50
 
50
static int lookup_root(int fs_handle, int dev_handle, vfs_node_t *root)
51
static int lookup_root(int fs_handle, int dev_handle, vfs_node_t *root)
51
{
52
{
52
    vfs_node_t altroot = {
53
    vfs_node_t altroot = {
Line 56... Line 57...
56
         * At this point, we don't know what is the index of the root
57
         * At this point, we don't know what is the index of the root
57
         * node. Finally, that's what this function is about.
58
         * node. Finally, that's what this function is about.
58
         */
59
         */
59
    };
60
    };
60
 
61
 
61
    return vfs_lookup_internal("/", 1, root, &altroot);
62
    return vfs_lookup_internal("/", strlen("/"), root, &altroot);
62
}
63
}
63
 
64
 
64
void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
65
void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
65
{
66
{
66
    int dev_handle;
67
    int dev_handle;
Line 147... Line 148...
147
 
148
 
148
    /*
149
    /*
149
     * Finally, we need to resolve the path to the mountpoint.
150
     * Finally, we need to resolve the path to the mountpoint.
150
     */
151
     */
151
    vfs_node_t mp;
152
    vfs_node_t mp;
-
 
153
    futex_down(&rootfs_futex);
152
    if (rootfs.fs_handle) {
154
    if (rootfs.fs_handle) {
153
        /*
155
        /*
154
         * We already have the root FS.
156
         * We already have the root FS.
155
         */
157
         */
156
        rc = vfs_lookup_internal((char *) (buf + FS_NAME_MAXLEN),
158
        rc = vfs_lookup_internal((char *) (buf + FS_NAME_MAXLEN),
157
            size - FS_NAME_MAXLEN, &mp, NULL);
159
            size - FS_NAME_MAXLEN, &mp, NULL);
158
        if (rc != EOK) {
160
        if (rc != EOK) {
159
            /*
161
            /*
160
             * The lookup failed for some reason.
162
             * The lookup failed for some reason.
161
             */
163
             */
-
 
164
            futex_up(&rootfs_futex);
162
            free(buf);
165
            free(buf);
163
            ipc_answer_fast(rid, rc, 0, 0);
166
            ipc_answer_fast(rid, rc, 0, 0);
164
            return;
167
            return;
165
        }
168
        }
166
    } else {
169
    } else {
167
        /*
170
        /*
168
         * We still don't have the root file system mounted.
171
         * We still don't have the root file system mounted.
169
         */
172
         */
170
        if ((size - FS_NAME_MAXLEN == 1) &&
173
        if ((size - FS_NAME_MAXLEN == strlen("/")) &&
171
            (buf[FS_NAME_MAXLEN] == '/')) {
174
            (buf[FS_NAME_MAXLEN] == '/')) {
172
            /*
175
            /*
173
             * For this simple, but important case, we are done.
176
             * For this simple, but important case, we are done.
174
             */
177
             */
175
            rootfs = mounted_root;
178
            rootfs = mounted_root;
-
 
179
            futex_up(&rootfs_futex);
176
            free(buf);
180
            free(buf);
177
            ipc_answer_fast(rid, EOK, 0, 0);
181
            ipc_answer_fast(rid, EOK, 0, 0);
178
            return;
182
            return;
179
        } else {
183
        } else {
180
            /*
184
            /*
181
             * We can't resolve this without the root filesystem
185
             * We can't resolve this without the root filesystem
182
             * being mounted first.
186
             * being mounted first.
183
             */
187
             */
-
 
188
            futex_up(&rootfs_futex);
184
            free(buf);
189
            free(buf);
185
            ipc_answer_fast(rid, ENOENT, 0, 0);
190
            ipc_answer_fast(rid, ENOENT, 0, 0);
186
            return;
191
            return;
187
        }
192
        }
188
    }
193
    }
-
 
194
    futex_up(&rootfs_futex);
189
       
195
   
190
    /*
196
    /*
191
     * At this point, we have all necessary pieces: file system and device
197
     * At this point, we have all necessary pieces: file system and device
192
     * handles, and we know the mount point VFS node and also the root node
198
     * handles, and we know the mount point VFS node and also the root node
193
     * of the file system being mounted.
199
     * of the file system being mounted.
194
     */
200
     */