00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00038 #include <ipc/services.h>
00039 #include <ipc/ns.h>
00040 #include <async.h>
00041 #include <errno.h>
00042 #include <stdio.h>
00043 #include <bool.h>
00044 #include <str.h>
00045 #include <as.h>
00046 #include <atomic.h>
00047 #include "vfs.h"
00048
00049 #define NAME "vfs"
00050
00051 static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall)
00052 {
00053 bool keep_on_going = true;
00054
00055
00056
00057
00058
00059 async_answer_0(iid, EOK);
00060
00061 while (keep_on_going) {
00062 ipc_call_t call;
00063 ipc_callid_t callid = async_get_call(&call);
00064
00065 switch (IPC_GET_IMETHOD(call)) {
00066 case IPC_M_PHONE_HUNGUP:
00067 keep_on_going = false;
00068 break;
00069 case VFS_IN_REGISTER:
00070 vfs_register(callid, &call);
00071 keep_on_going = false;
00072 break;
00073 case VFS_IN_MOUNT:
00074 vfs_mount(callid, &call);
00075 break;
00076 case VFS_IN_UNMOUNT:
00077 vfs_unmount(callid, &call);
00078 break;
00079 case VFS_IN_OPEN:
00080 vfs_open(callid, &call);
00081 break;
00082 case VFS_IN_OPEN_NODE:
00083 vfs_open_node(callid, &call);
00084 break;
00085 case VFS_IN_CLOSE:
00086 vfs_close(callid, &call);
00087 break;
00088 case VFS_IN_READ:
00089 vfs_read(callid, &call);
00090 break;
00091 case VFS_IN_WRITE:
00092 vfs_write(callid, &call);
00093 break;
00094 case VFS_IN_SEEK:
00095 vfs_seek(callid, &call);
00096 break;
00097 case VFS_IN_TRUNCATE:
00098 vfs_truncate(callid, &call);
00099 break;
00100 case VFS_IN_FSTAT:
00101 vfs_fstat(callid, &call);
00102 break;
00103 case VFS_IN_STAT:
00104 vfs_stat(callid, &call);
00105 break;
00106 case VFS_IN_MKDIR:
00107 vfs_mkdir(callid, &call);
00108 break;
00109 case VFS_IN_UNLINK:
00110 vfs_unlink(callid, &call);
00111 break;
00112 case VFS_IN_RENAME:
00113 vfs_rename(callid, &call);
00114 break;
00115 case VFS_IN_SYNC:
00116 vfs_sync(callid, &call);
00117 break;
00118 case VFS_IN_DUP:
00119 vfs_dup(callid, &call);
00120 default:
00121 async_answer_0(callid, ENOTSUP);
00122 break;
00123 }
00124 }
00125
00126
00127
00128
00129
00130 }
00131
00132 int main(int argc, char **argv)
00133 {
00134 printf(NAME ": HelenOS VFS server\n");
00135
00136
00137
00138
00139 if (!vfs_nodes_init()) {
00140 printf(NAME ": Failed to initialize VFS node hash table\n");
00141 return ENOMEM;
00142 }
00143
00144
00145
00146
00147 plb = as_get_mappable_page(PLB_SIZE);
00148 if (!plb) {
00149 printf(NAME ": Cannot allocate a mappable piece of address space\n");
00150 return ENOMEM;
00151 }
00152
00153 if (as_area_create(plb, PLB_SIZE, AS_AREA_READ | AS_AREA_WRITE |
00154 AS_AREA_CACHEABLE) != plb) {
00155 printf(NAME ": Cannot create address space area\n");
00156 return ENOMEM;
00157 }
00158 memset(plb, 0, PLB_SIZE);
00159
00160
00161
00162
00163 async_set_client_data_constructor(vfs_client_data_create);
00164 async_set_client_data_destructor(vfs_client_data_destroy);
00165
00166
00167
00168
00169 async_set_client_connection(vfs_connection);
00170
00171
00172
00173
00174 if (service_register(SERVICE_VFS) != EOK) {
00175 printf("%s: Cannot register VFS service\n", NAME);
00176 return EINVAL;
00177 }
00178
00179
00180
00181
00182 printf(NAME ": Accepting connections\n");
00183 async_manager();
00184 return 0;
00185 }
00186