2
* Copyright (c) 2006 Martin Decky
3
* Copyright (c) 2008 Jakub Jermar
4
* Copyright (c) 2011 Martin Sucha
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
11
* - Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* - Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
* - The name of the author may not be used to endorse or promote products
17
* derived from this software without specific prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
* @brief EXT2 file system driver for HelenOS.
41
#include <ipc/services.h>
49
#include "../../vfs/vfs.h"
53
vfs_info_t ext2fs_vfs_info = {
60
* This connection fibril processes VFS requests from VFS.
62
* In order to support simultaneous VFS requests, our design is as follows.
63
* The connection fibril accepts VFS requests from VFS. If there is only one
64
* instance of the fibril, VFS will need to serialize all VFS requests it sends
65
* to EXT2FS. To overcome this bottleneck, VFS can send EXT2FS the IPC_M_CONNECT_ME_TO
66
* call. In that case, a new connection fibril will be created, which in turn
67
* will accept the call. Thus, a new phone will be opened for VFS.
69
* There are few issues with this arrangement. First, VFS can run out of
70
* available phones. In that case, VFS can close some other phones or use one
71
* phone for more serialized requests. Similarily, EXT2FS can refuse to duplicate
72
* the connection. VFS should then just make use of already existing phones and
73
* route its requests through them. To avoid paying the fibril creation price
74
* upon each request, EXT2FS might want to keep the connections open after the
75
* request has been completed.
77
static void ext2fs_connection(ipc_callid_t iid, ipc_call_t *icall)
81
* This only happens for connections opened by
82
* IPC_M_CONNECT_ME_TO calls as opposed to callback connections
83
* created by IPC_M_CONNECT_TO_ME.
85
async_answer_0(iid, EOK);
88
dprintf(NAME ": connection opened\n");
93
callid = async_get_call(&call);
94
switch (IPC_GET_IMETHOD(call)) {
95
case IPC_M_PHONE_HUNGUP:
98
ext2fs_mounted(callid, &call);
101
ext2fs_mount(callid, &call);
103
case VFS_OUT_UNMOUNTED:
104
ext2fs_unmounted(callid, &call);
106
case VFS_OUT_UNMOUNT:
107
ext2fs_unmount(callid, &call);
110
ext2fs_lookup(callid, &call);
113
ext2fs_read(callid, &call);
116
ext2fs_write(callid, &call);
118
case VFS_OUT_TRUNCATE:
119
ext2fs_truncate(callid, &call);
122
ext2fs_stat(callid, &call);
125
ext2fs_close(callid, &call);
127
case VFS_OUT_DESTROY:
128
ext2fs_destroy(callid, &call);
130
case VFS_OUT_OPEN_NODE:
131
ext2fs_open_node(callid, &call);
134
ext2fs_sync(callid, &call);
137
async_answer_0(callid, ENOTSUP);
143
int main(int argc, char **argv)
148
printf(NAME ": HelenOS EXT2 file system server\n");
150
vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0);
151
if (vfs_phone < EOK) {
152
printf(NAME ": failed to connect to VFS\n");
156
rc = ext2fs_global_init();
158
printf(NAME ": Failed global initialization\n");
162
rc = fs_register(vfs_phone, &ext2fs_reg, &ext2fs_vfs_info, ext2fs_connection);
164
fprintf(stdout, NAME ": Failed to register fs (%d)\n", rc);
168
printf(NAME ": Accepting connections\n");