Subversion Repositories HelenOS

Rev

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

Rev 2532 Rev 2535
Line 30... Line 30...
30
 * @{
30
 * @{
31
 */
31
 */
32
 
32
 
33
/**
33
/**
34
 * @file    vfs.c
34
 * @file    vfs.c
35
 * @brief   VFS multiplexer for HelenOS.
35
 * @brief   VFS_REGISTER method.
36
 */
36
 */
37
 
37
 
38
#include <ipc/ipc.h>
38
#include <ipc/ipc.h>
39
#include <ipc/services.h>
39
#include <ipc/services.h>
40
#include <async.h>
40
#include <async.h>
Line 46... Line 46...
46
#include <bool.h>
46
#include <bool.h>
47
#include <futex.h>
47
#include <futex.h>
48
#include <libadt/list.h>
48
#include <libadt/list.h>
49
#include "vfs.h"
49
#include "vfs.h"
50
 
50
 
51
 
-
 
52
#define dprintf(...)    printf(__VA_ARGS__)
-
 
53
 
-
 
54
atomic_t fs_head_futex = FUTEX_INITIALIZER;
51
atomic_t fs_head_futex = FUTEX_INITIALIZER;
55
link_t fs_head;
52
link_t fs_head;
56
 
53
 
57
/** Verify the VFS info structure.
54
/** Verify the VFS info structure.
58
 *
55
 *
Line 135... Line 132...
135
/** VFS_REGISTER protocol function.
132
/** VFS_REGISTER protocol function.
136
 *
133
 *
137
 * @param rid       Hash of the call with the request.
134
 * @param rid       Hash of the call with the request.
138
 * @param request   Call structure with the request.
135
 * @param request   Call structure with the request.
139
 */
136
 */
140
static void vfs_register(ipc_callid_t rid, ipc_call_t *request)
137
void vfs_register(ipc_callid_t rid, ipc_call_t *request)
141
{
138
{
142
    ipc_callid_t callid;
139
    ipc_callid_t callid;
143
    ipc_call_t call;
140
    ipc_call_t call;
144
    int rc;
141
    int rc;
145
    size_t size;
142
    size_t size;
Line 272... Line 269...
272
    ipc_answer_fast(rid, EOK, 0, 0);
269
    ipc_answer_fast(rid, EOK, 0, 0);
273
    dprintf("\"%s\" filesystem successfully registered.\n",
270
    dprintf("\"%s\" filesystem successfully registered.\n",
274
        fs_info->vfs_info.name);
271
        fs_info->vfs_info.name);
275
}
272
}
276
 
273
 
277
static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall)
-
 
278
{
-
 
279
    bool keep_on_going = 1;
-
 
280
 
-
 
281
    printf("Connection opened from %p\n", icall->in_phone_hash);
-
 
282
 
-
 
283
    /*
-
 
284
     * The connection was opened via the IPC_CONNECT_ME_TO call.
-
 
285
     * This call needs to be answered.
-
 
286
     */
-
 
287
    ipc_answer_fast(iid, EOK, 0, 0);
-
 
288
 
-
 
289
    /*
-
 
290
     * Here we enter the main connection fibril loop.
-
 
291
     * The logic behind this loop and the protocol is that we'd like to keep
-
 
292
     * each connection open for a while before we close it. The benefit of
-
 
293
     * this is that the client doesn't have to establish a new connection
-
 
294
     * upon each request.  On the other hand, the client must be ready to
-
 
295
     * re-establish a connection if we hang it up due to reaching of maximum
-
 
296
     * number of requests per connection or due to the client timing out.
-
 
297
     */
-
 
298
     
-
 
299
    while (keep_on_going) {
-
 
300
        ipc_callid_t callid;
-
 
301
        ipc_call_t call;
-
 
302
 
-
 
303
        callid = async_get_call(&call);
-
 
304
 
-
 
305
        printf("Received call, method=%d\n", IPC_GET_METHOD(call));
-
 
306
       
-
 
307
        switch (IPC_GET_METHOD(call)) {
-
 
308
        case IPC_M_PHONE_HUNGUP:
-
 
309
            keep_on_going = false;
-
 
310
            break;
-
 
311
        case VFS_REGISTER:
-
 
312
            vfs_register(callid, &call);
-
 
313
            keep_on_going = false;
-
 
314
            break;
-
 
315
        case VFS_MOUNT:
-
 
316
        case VFS_UNMOUNT:
-
 
317
        case VFS_OPEN:
-
 
318
        case VFS_CREATE:
-
 
319
        case VFS_CLOSE:
-
 
320
        case VFS_READ:
-
 
321
        case VFS_WRITE:
-
 
322
        case VFS_SEEK:
-
 
323
        default:
-
 
324
            ipc_answer_fast(callid, ENOTSUP, 0, 0);
-
 
325
            break;
-
 
326
        }
-
 
327
    }
-
 
328
 
-
 
329
    /* TODO: cleanup after the client */
-
 
330
   
-
 
331
}
-
 
332
 
-
 
333
int main(int argc, char **argv)
-
 
334
{
-
 
335
    ipcarg_t phonead;
-
 
336
 
-
 
337
    printf("VFS: HelenOS VFS server\n");
-
 
338
 
-
 
339
    list_initialize(&fs_head);
-
 
340
    async_set_client_connection(vfs_connection);
-
 
341
    ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, &phonead);
-
 
342
    async_manager();
-
 
343
    return 0;
-
 
344
}
-
 
345
 
-
 
346
/**
274
/**
347
 * @}
275
 * @}
348
 */
276
 */