Changeset 47a776f9 in mainline for uspace/srv/vfs/vfs.c
- Timestamp:
- 2007-09-19T18:56:02Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d2d0baf
- Parents:
- 26f2af0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.c
r26f2af0 r47a776f9 40 40 #include <async.h> 41 41 #include <errno.h> 42 #include <stdio.h> 42 43 #include <stdlib.h> 43 44 #include <string.h> … … 48 49 #include "vfs.h" 49 50 51 52 #define dprintf(...) printf(__VA_ARGS__) 53 50 54 atomic_t fs_head_futex = FUTEX_INITIALIZER; 51 55 link_t fs_head; … … 65 69 * characters [a-z]+[a-z0-9_-]*. 66 70 */ 67 if (!islower(info->name[0])) 68 return false; 71 if (!islower(info->name[0])) { 72 dprintf("The name doesn't start with a lowercase character.\n"); 73 return false; 74 } 69 75 for (i = 1; i < FS_NAME_MAXLEN; i++) { 70 76 if (!(islower(info->name[i]) || isdigit(info->name[i])) && 71 77 (info->name[i] != '-') && (info->name[i] != '_')) { 72 if (info->name[i] == '\0') 78 if (info->name[i] == '\0') { 73 79 break; 74 else 80 } else { 81 dprintf("The name contains illegal " 82 "characters.\n"); 75 83 return false; 84 } 76 85 } 77 86 } … … 81 90 * Check if the FS implements mandatory VFS operations. 82 91 */ 83 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_REGISTER)] != VFS_OP_DEFINED) 84 return false; 85 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_MOUNT)] != VFS_OP_DEFINED) 86 return false; 87 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_UNMOUNT)] != VFS_OP_DEFINED) 88 return false; 89 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_LOOKUP)] != VFS_OP_DEFINED) 90 return false; 91 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_OPEN)] != VFS_OP_DEFINED) 92 return false; 93 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_CLOSE)] != VFS_OP_DEFINED) 94 return false; 95 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_READ)] != VFS_OP_DEFINED) 96 return false; 92 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_REGISTER)] != VFS_OP_DEFINED) { 93 dprintf("Operation VFS_REGISTER not defined by the client.\n"); 94 return false; 95 } 96 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_MOUNT)] != VFS_OP_DEFINED) { 97 dprintf("Operation VFS_MOUNT not defined by the client.\n"); 98 return false; 99 } 100 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_UNMOUNT)] != VFS_OP_DEFINED) { 101 dprintf("Operation VFS_UNMOUNT not defined by the client.\n"); 102 return false; 103 } 104 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_LOOKUP)] != VFS_OP_DEFINED) { 105 dprintf("Operation VFS_LOOKUP not defined by the client.\n"); 106 return false; 107 } 108 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_OPEN)] != VFS_OP_DEFINED) { 109 dprintf("Operation VFS_OPEN not defined by the client.\n"); 110 return false; 111 } 112 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_CLOSE)] != VFS_OP_DEFINED) { 113 dprintf("Operation VFS_CLOSE not defined by the client.\n"); 114 return false; 115 } 116 if (info->ops[IPC_METHOD_TO_VFS_OP(VFS_READ)] != VFS_OP_DEFINED) { 117 dprintf("Operation VFS_READ not defined by the client.\n"); 118 return false; 119 } 97 120 98 121 /* … … 100 123 */ 101 124 for (i = VFS_FIRST; i < VFS_LAST; i++) { 102 if ((IPC_METHOD_TO_VFS_OP(i) != VFS_OP_NULL) && 103 (IPC_METHOD_TO_VFS_OP(i) != VFS_OP_DEFAULT) && 104 (IPC_METHOD_TO_VFS_OP(i) != VFS_OP_DEFINED)) 105 return false; 125 if ((info->ops[IPC_METHOD_TO_VFS_OP(i)] != VFS_OP_NULL) && 126 (info->ops[IPC_METHOD_TO_VFS_OP(i)] != VFS_OP_DEFAULT) && 127 (info->ops[IPC_METHOD_TO_VFS_OP(i)] != VFS_OP_DEFINED)) { 128 dprintf("Operation info not understood.\n"); 129 return false; 130 } 106 131 } 107 132 return true; … … 120 145 size_t size; 121 146 147 dprintf("Processing VFS_REGISTER request received from %p.\n", 148 request->in_phone_hash); 149 122 150 /* 123 151 * The first call has to be IPC_M_DATA_SEND in which we receive the … … 127 155 /* 128 156 * The client doesn't obey the same protocol as we do. 129 */ 157 */ 158 dprintf("Receiving of VFS info failed.\n"); 130 159 ipc_answer_fast(callid, EINVAL, 0, 0); 131 160 ipc_answer_fast(rid, EINVAL, 0, 0); 132 161 return; 133 162 } 163 164 dprintf("VFS info received, size = %d\n", size); 134 165 135 166 /* … … 142 173 * the info structure. 143 174 */ 175 dprintf("Received VFS info has bad size.\n"); 144 176 ipc_answer_fast(callid, EINVAL, 0, 0); 145 177 ipc_answer_fast(rid, EINVAL, 0, 0); … … 153 185 fs_info = (fs_info_t *) malloc(sizeof(fs_info_t)); 154 186 if (!fs_info) { 187 dprintf("Could not allocate memory for FS info.\n"); 155 188 ipc_answer_fast(callid, ENOMEM, 0, 0); 156 189 ipc_answer_fast(rid, ENOMEM, 0, 0); … … 160 193 161 194 rc = ipc_data_deliver(callid, &call, &fs_info->vfs_info, size); 162 if (!rc) { 195 if (rc != EOK) { 196 dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n", 197 rc); 163 198 free(fs_info); 164 199 ipc_answer_fast(callid, rc, 0, 0); … … 166 201 return; 167 202 } 203 204 dprintf("VFS info delivered.\n"); 168 205 169 206 if (!vfs_info_sane(&fs_info->vfs_info)) { … … 188 225 * We already register a fs like this. 189 226 */ 227 dprintf("FS is already registered.\n"); 190 228 futex_up(&fs_head_futex); 191 229 free(fs_info); … … 199 237 * Add fs_info to the list of registered FS's. 200 238 */ 239 dprintf("Adding FS into the registered list.\n"); 201 240 list_append(&fs_info->fs_link, &fs_head); 202 241 … … 213 252 callid = async_get_call(&call); 214 253 if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) { 254 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); 215 255 list_remove(&fs_info->fs_link); 216 256 futex_up(&fs_head_futex); … … 223 263 ipc_answer_fast(callid, EOK, 0, 0); 224 264 265 dprintf("Callback connection to FS created.\n"); 266 225 267 futex_up(&fs_head_futex); 226 268 … … 229 271 */ 230 272 ipc_answer_fast(rid, EOK, 0, 0); 273 dprintf("\"%s\" filesystem successfully registered.\n", 274 fs_info->vfs_info.name); 231 275 } 232 276 … … 234 278 { 235 279 bool keep_on_going = 1; 280 281 printf("Connection opened from %p\n", icall->in_phone_hash); 236 282 237 283 /* … … 256 302 257 303 callid = async_get_call(&call); 304 305 printf("Received call, method=%d\n", IPC_GET_METHOD(call)); 258 306 259 307 switch (IPC_GET_METHOD(call)) { … … 287 335 ipcarg_t phonead; 288 336 337 printf("VFS: HelenOS VFS server\n"); 338 289 339 list_initialize(&fs_head); 290 340 async_set_client_connection(vfs_connection);
Note:
See TracChangeset
for help on using the changeset viewer.