Changeset 5f4cfb1e in mainline
- Timestamp:
- 2007-09-28T10:36:31Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 13125d3
- Parents:
- 566d798d
- Location:
- uspace/srv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat.c
r566d798d r5f4cfb1e 43 43 #include <unistd.h> 44 44 #include <stdio.h> 45 #include <as.h> >45 #include <as.h> 46 46 #include "../../vfs/vfs.h" 47 47 … … 65 65 66 66 uint8_t *plb_ro = NULL; 67 68 int fs_handle = 0; 67 69 68 70 /** … … 156 158 * Request sharing the Path Lookup Buffer with VFS. 157 159 */ 158 rc = ipc_call_sync_3(vfs_phone, IPC_M_AS_AREA_RECV, plb_ro, PLB_SIZE, 0,159 NULL, NULL, NULL);160 rc = ipc_call_sync_3(vfs_phone, IPC_M_AS_AREA_RECV, (ipcarg_t) plb_ro, 161 PLB_SIZE, 0, NULL, NULL, NULL); 160 162 if (rc) { 161 163 async_wait_for(req, NULL); … … 164 166 165 167 /* 168 * Pick up the answer for the request to the VFS_REQUEST call. 169 */ 170 async_wait_for(req, NULL); 171 fs_handle = (int) IPC_GET_ARG1(answer); 172 dprintf("FAT filesystem registered, fs_handle=%d.\n", fs_handle); 173 174 /* 166 175 * Create a connection fibril to handle the callback connection. 167 176 */ … … 173 182 */ 174 183 async_set_client_connection(fat_connection); 175 176 /*177 * Pick up the answer for the request to the VFS_REQUEST call.178 */179 async_wait_for(req, NULL);180 dprintf("FAT filesystem registered.\n");181 184 182 185 async_create_manager(); -
uspace/srv/vfs/vfs.h
r566d798d r5f4cfb1e 93 93 link_t fs_link; 94 94 vfs_info_t vfs_info; 95 int fs_handle; 96 atomic_t phone_futex; /**< Phone serializing futex. */ 95 97 ipcarg_t phone; 96 98 } fs_info_t; … … 143 145 extern link_t plb_head; /**< List of active PLB entries. */ 144 146 147 extern int vfs_grab_phone(int); 148 extern void vfs_release_phone(int); 149 145 150 extern int vfs_lookup_internal(char *path, size_t len, vfs_node_t *result); 146 151 -
uspace/srv/vfs/vfs_lookup.c
r566d798d r5f4cfb1e 126 126 127 127 ipc_call_t answer; 128 int phone = 0; /* TODO */ 129 aid_t req = async_send_2(phone, VFS_LOOKUP, (ipcarg_t) first, 130 (ipcarg_t) last, &answer); 128 int phone = vfs_grab_phone(rootfs->fs_handle); 129 aid_t req = async_send_3(phone, VFS_LOOKUP, (ipcarg_t) first, 130 (ipcarg_t) last, (ipcarg_t) rootfs->dev_handle, &answer); 131 vfs_release_phone(phone); 131 132 132 133 ipcarg_t rc; -
uspace/srv/vfs/vfs_register.c
r566d798d r5f4cfb1e 48 48 #include <as.h> 49 49 #include <libadt/list.h> 50 #include <assert.h> 50 51 #include "vfs.h" 51 52 52 53 atomic_t fs_head_futex = FUTEX_INITIALIZER; 53 54 link_t fs_head; 55 56 atomic_t fs_handle_next = { 57 .count = 1 58 }; 54 59 55 60 /** Verify the VFS info structure. … … 306 311 /* 307 312 * That was it. The FS has been registered. 308 */ 309 ipc_answer_fast(rid, EOK, 0, 0); 310 dprintf("\"%s\" filesystem successfully registered.\n", 311 fs_info->vfs_info.name); 312 313 * In reply to the VFS_REGISTER request, we assign the client file 314 * system a global file system handle. 315 */ 316 fs_info->fs_handle = (int) atomic_postinc(&fs_handle_next); 317 ipc_answer_fast(rid, EOK, (ipcarg_t) fs_info->fs_handle, 0); 318 dprintf("\"%s\" filesystem successfully registered, handle=%d.\n", 319 fs_info->vfs_info.name, fs_info->fs_handle); 320 321 } 322 323 /** For a given file system handle, implement policy for allocating a phone. 324 * 325 * @param handle File system handle. 326 * 327 * @return Phone over which a multi-call request can be safely 328 * sent. Return 0 if no phone was found. 329 */ 330 int vfs_grab_phone(int handle) 331 { 332 /* 333 * For now, we don't try to be very clever and very fast. 334 * We simply lookup the phone in the fs_head list. We currently don't 335 * open any additional phones (even though that itself would be pretty 336 * straightforward; housekeeping multiple open phones to a FS task would 337 * be more demanding). Instead, we simply take the respective 338 * phone_futex and keep it until vfs_release_phone(). 339 */ 340 futex_down(&fs_head_futex); 341 link_t *cur; 342 fs_info_t *fs; 343 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 344 fs = list_get_instance(cur, fs_info_t, fs_link); 345 if (fs->fs_handle == handle) { 346 futex_up(&fs_head_futex); 347 /* 348 * For now, take the futex unconditionally. 349 * Oh yeah, serialization rocks. 350 * It will be up'ed in vfs_release_phone(). 351 */ 352 futex_down(&fs->phone_futex); 353 return fs->phone; 354 } 355 } 356 futex_up(&fs_head_futex); 357 return 0; 358 } 359 360 /** Tell VFS that the phone is in use for any request. 361 * 362 * @param phone Phone to FS task. 363 */ 364 void vfs_release_phone(int phone) 365 { 366 bool found = false; 367 368 futex_down(&fs_head_futex); 369 link_t *cur; 370 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 371 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 372 if (fs->phone == phone) { 373 found = true; 374 futex_up(&fs_head_futex); 375 futex_up(&fs->phone_futex); 376 return; 377 } 378 } 379 futex_up(&fs_head_futex); 380 381 /* 382 * Not good to get here. 383 */ 384 assert(found == true); 313 385 } 314 386
Note:
See TracChangeset
for help on using the changeset viewer.