Subversion Repositories HelenOS

Rev

Rev 2520 | Rev 2523 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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