Subversion Repositories HelenOS

Rev

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

Rev 2536 Rev 2543
Line 43... Line 43...
43
#include <stdlib.h>
43
#include <stdlib.h>
44
#include <string.h>
44
#include <string.h>
45
#include <ctype.h>
45
#include <ctype.h>
46
#include <bool.h>
46
#include <bool.h>
47
#include <futex.h>
47
#include <futex.h>
-
 
48
#include <as.h>
48
#include <libadt/list.h>
49
#include <libadt/list.h>
49
#include "vfs.h"
50
#include "vfs.h"
50
 
51
 
51
atomic_t fs_head_futex = FUTEX_INITIALIZER;
52
atomic_t fs_head_futex = FUTEX_INITIALIZER;
52
link_t fs_head;
53
link_t fs_head;
Line 172... Line 173...
172
        dprintf("Received VFS info has bad size.\n");
173
        dprintf("Received VFS info has bad size.\n");
173
        ipc_answer_fast(callid, EINVAL, 0, 0);
174
        ipc_answer_fast(callid, EINVAL, 0, 0);
174
        ipc_answer_fast(rid, EINVAL, 0, 0);
175
        ipc_answer_fast(rid, EINVAL, 0, 0);
175
        return;
176
        return;
176
    }
177
    }
177
    fs_info_t *fs_info;
-
 
178
 
178
 
179
    /*
179
    /*
180
     * Allocate and initialize a buffer for the fs_info structure.
180
     * Allocate and initialize a buffer for the fs_info structure.
181
     */
181
     */
-
 
182
    fs_info_t *fs_info;
182
    fs_info = (fs_info_t *) malloc(sizeof(fs_info_t));
183
    fs_info = (fs_info_t *) malloc(sizeof(fs_info_t));
183
    if (!fs_info) {
184
    if (!fs_info) {
184
        dprintf("Could not allocate memory for FS info.\n");
185
        dprintf("Could not allocate memory for FS info.\n");
185
        ipc_answer_fast(callid, ENOMEM, 0, 0);
186
        ipc_answer_fast(callid, ENOMEM, 0, 0);
186
        ipc_answer_fast(rid, ENOMEM, 0, 0);
187
        ipc_answer_fast(rid, ENOMEM, 0, 0);
Line 259... Line 260...
259
    fs_info->phone = IPC_GET_ARG3(call);
260
    fs_info->phone = IPC_GET_ARG3(call);
260
    ipc_answer_fast(callid, EOK, 0, 0);
261
    ipc_answer_fast(callid, EOK, 0, 0);
261
 
262
 
262
    dprintf("Callback connection to FS created.\n");
263
    dprintf("Callback connection to FS created.\n");
263
 
264
 
-
 
265
    /*
-
 
266
     * The client will want us to send him the address space area with PLB.
-
 
267
     */
-
 
268
    callid = async_get_call(&call);
-
 
269
    if (IPC_GET_METHOD(call) != IPC_M_AS_AREA_RECV) {
-
 
270
        dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
-
 
271
        list_remove(&fs_info->fs_link);
-
 
272
        futex_up(&fs_head_futex);
-
 
273
        ipc_hangup(fs_info->phone);
-
 
274
        free(fs_info);
-
 
275
        ipc_answer_fast(callid, EINVAL, 0, 0);
-
 
276
        ipc_answer_fast(rid, EINVAL, 0, 0);
-
 
277
        return;
-
 
278
    }
-
 
279
   
-
 
280
    /*
-
 
281
     * We can only send the client address space area PLB_SIZE bytes long.
-
 
282
     */
-
 
283
    size = IPC_GET_ARG2(call);
-
 
284
    if (size != PLB_SIZE) {
-
 
285
        dprintf("Client suggests wrong size of PFB, size = %d\n", size);
-
 
286
        list_remove(&fs_info->fs_link);
-
 
287
        futex_up(&fs_head_futex);
-
 
288
        ipc_hangup(fs_info->phone);
-
 
289
        free(fs_info);
-
 
290
        ipc_answer_fast(callid, EINVAL, 0, 0);
-
 
291
        ipc_answer_fast(rid, EINVAL, 0, 0);
-
 
292
        return;
-
 
293
       
-
 
294
    }
-
 
295
 
-
 
296
    /*
-
 
297
     * Commit to read-only sharing the PLB with the client.
-
 
298
     */
-
 
299
    ipc_answer_fast(callid, EOK, (ipcarg_t) plb,
-
 
300
        (ipcarg_t) (AS_AREA_READ | AS_AREA_CACHEABLE));
-
 
301
 
-
 
302
    dprintf("Sharing PLB.\n");
-
 
303
 
264
    futex_up(&fs_head_futex);
304
    futex_up(&fs_head_futex);
265
 
305
 
266
    /*
306
    /*
267
     * That was it. The FS has been registered.
307
     * That was it. The FS has been registered.
268
     */
308
     */