Subversion Repositories HelenOS

Rev

Rev 2520 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2518 jermar 1
/*
2
 * Copyright (c) 2007 Jakub Jermar
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
 
29
/** @addtogroup fs
30
 * @{
31
 */
32
 
33
/**
34
 * @file    vfs.c
35
 * @brief   VFS multiplexer for HelenOS.
36
 */
37
 
2520 jermar 38
#include <ipc/ipc.h>
39
#include <ipc/services.h>
40
#include <async.h>
41
#include <errno.h>
42
#include "vfs.h"
43
 
2521 jermar 44
static void vfs_register(ipc_callid_t iid, ipc_call_t *icall)
45
{
46
    ipc_callid_t callid;
47
    ipc_call_t call;
48
 
49
    callid = async_get_call(&call);
50
    if (IPC_GET_METHOD(call) == IPC_M_DATA_SEND) {
51
        size_t size = IPC_GET_ARG3(call);
52
        if (size != sizeof(vfs_info_t)) {
53
            /*
54
             * The client is sending us something, which cannot be
55
             * the info structure.
56
             */
57
            ipc_answer_fast(iid, EINVAL, 0, 0);
58
            ipc_answer_fast(callid, EINVAL, 0, 0);
59
            return;
60
        }
61
        /*
62
         * XXX: continue here
63
         * Allocate an info structue, answer the call, check sanity
64
         * of the copied-in info structure, ...
65
         */
66
    } else {
67
        /*
68
         * The client doesn't obey the same protocol as we do.
69
         */
70
        ipc_answer_fast(iid, EINVAL, 0, 0);
71
        ipc_answer_fast(callid, EINVAL, 0, 0);
72
        return;
73
    }
74
}
75
 
2520 jermar 76
static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall)
77
{
78
    ipcarg_t iarg1, iarg2;
79
 
80
    /*
81
     * The connection was opened via the IPC_CONNECT_ME_TO call.
82
     * This call needs to be answered.
83
     *
84
     * The protocol is that the requested action is specified in ARG1
85
     * of the opening call. If the request has a single integer argument,
86
     * it is passed in ARG2.
87
     */
88
    iarg1 = IPC_GET_ARG1(*icall);
89
    iarg2 = IPC_GET_ARG2(*icall);
90
 
91
    /*
92
     * Now, the connection can either be from an individual FS,
93
     * which is trying to register itself and pass us its capabilities.
94
     * Or, the connection is a regular connection from a client that wants
95
     * us to do something for it (e.g. open a file, mount a fs etc.).
96
     */
97
    switch (iarg1) {
98
    case VFS_REGISTER:
2521 jermar 99
        vfs_register(iid, icall);
100
        break;
2520 jermar 101
    case VFS_MOUNT:
102
    case VFS_UNMOUNT:
103
    case VFS_OPEN:
104
    default:
105
        ipc_answer_fast(iid, ENOTSUP, 0, 0);
106
        break;
107
    }
108
}
109
 
2518 jermar 110
int main(int argc, char **argv)
111
{
2520 jermar 112
    ipcarg_t phonead;
113
 
114
    async_set_client_connection(vfs_connection);
115
    ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, &phonead);
116
    async_manager();
2518 jermar 117
    return 0;
118
}
119
 
120
/**
121
 * @}
122
 */