Changeset cde485d in mainline
- Timestamp:
- 2008-06-06T20:23:02Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b7b6753
- Parents:
- f49b0ea
- Location:
- uspace/srv/fs/fat
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat.c
rf49b0ea rcde485d 56 56 [IPC_METHOD_TO_VFS_OP(VFS_TRUNCATE)] = VFS_OP_NULL, 57 57 [IPC_METHOD_TO_VFS_OP(VFS_MOUNT)] = VFS_OP_NULL, 58 [IPC_METHOD_TO_VFS_OP(VFS_MOUNTED)] = VFS_OP_DEFINED, 58 59 [IPC_METHOD_TO_VFS_OP(VFS_UNMOUNT)] = VFS_OP_NULL, 59 60 } … … 98 99 callid = async_get_call(&call); 99 100 switch (IPC_GET_METHOD(call)) { 101 case VFS_MOUNTED: 102 fat_mounted(callid, &call); 103 break; 104 case VFS_MOUNT: 105 fat_mount(callid, &call); 106 break; 100 107 case VFS_LOOKUP: 101 108 fat_lookup(callid, &call); … … 111 118 { 112 119 int vfs_phone; 120 int rc; 113 121 114 122 printf("FAT: HelenOS FAT file system server.\n"); 123 124 rc = fat_idx_init(); 125 if (rc != EOK) 126 goto err; 115 127 116 128 vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0, 0); … … 120 132 } 121 133 122 int rc;123 134 rc = fs_register(vfs_phone, &fat_reg, &fat_vfs_info, fat_connection); 124 135 if (rc != EOK) { 125 printf("Failed to register the FAT file system (%d)\n", rc);126 return rc;136 fat_idx_fini(); 137 goto err; 127 138 } 128 139 … … 133 144 /* not reached */ 134 145 return 0; 146 147 err: 148 printf("Failed to register the FAT file system (%d)\n", rc); 149 return rc; 135 150 } 136 151 -
uspace/srv/fs/fat/fat.h
rf49b0ea rcde485d 218 218 extern fs_reg_t fat_reg; 219 219 220 extern void fat_mounted(ipc_callid_t, ipc_call_t *); 221 extern void fat_mount(ipc_callid_t, ipc_call_t *); 220 222 extern void fat_lookup(ipc_callid_t, ipc_call_t *); 221 223 222 224 extern fat_idx_t *fat_idx_get_by_pos(dev_handle_t, fat_cluster_t, unsigned); 223 225 extern fat_idx_t *fat_idx_get_by_index(dev_handle_t, fs_index_t); 226 227 extern int fat_idx_init(void); 228 extern void fat_idx_fini(void); 229 extern int fat_idx_init_by_dev_handle(dev_handle_t); 230 extern void fat_idx_fini_by_dev_handle(dev_handle_t); 224 231 225 232 #endif -
uspace/srv/fs/fat/fat_idx.c
rf49b0ea rcde485d 74 74 /** List of unused structures. */ 75 75 static LIST_INITIALIZE(unused_head); 76 77 static void unused_initialize(unused_t *u, dev_handle_t dev_handle) 78 { 79 link_initialize(&u->link); 80 u->dev_handle = dev_handle; 81 u->next = 0; 82 u->remaining = ((uint64_t)((fs_index_t)-1)) + 1; 83 list_initialize(&u->freed_head); 84 } 76 85 77 86 /** Futex protecting the up_hash and ui_hash. */ … … 402 411 } 403 412 413 int fat_idx_init(void) 414 { 415 if (!hash_table_create(&up_hash, UPH_BUCKETS, 3, &uph_ops)) 416 return ENOMEM; 417 if (!hash_table_create(&ui_hash, UIH_BUCKETS, 2, &uih_ops)) { 418 hash_table_destroy(&up_hash); 419 return ENOMEM; 420 } 421 return EOK; 422 } 423 424 void fat_idx_fini(void) 425 { 426 /* We assume the hash tables are empty. */ 427 hash_table_destroy(&up_hash); 428 hash_table_destroy(&ui_hash); 429 } 430 431 int fat_idx_init_by_dev_handle(dev_handle_t dev_handle) 432 { 433 unused_t *u = (unused_t *) malloc(sizeof(unused_t)); 434 if (!u) 435 return ENOMEM; 436 unused_initialize(u, dev_handle); 437 futex_down(&unused_futex); 438 list_append(&u->link, &unused_head); 439 futex_up(&unused_futex); 440 return EOK; 441 } 442 443 void fat_idx_fini_by_dev_handle(dev_handle_t dev_handle) 444 { 445 unused_t *u; 446 link_t *l; 447 448 futex_down(&unused_futex); 449 for (l = unused_head.next; l != &unused_head; l = l->next) { 450 u = list_get_instance(l, unused_t, link); 451 if (u->dev_handle == dev_handle) 452 goto hit; 453 } 454 futex_up(&unused_futex); 455 456 assert(false); /* should not happen */ 457 458 hit: 459 list_remove(&u->link); 460 futex_up(&unused_futex); 461 462 while (!list_empty(&u->freed_head)) { 463 freed_t *f; 464 f = list_get_instance(u->freed_head.next, freed_t, link); 465 list_remove(&f->link); 466 free(f); 467 } 468 free(u); 469 } 470 471 /** 472 * @} 473 */ -
uspace/srv/fs/fat/fat_ops.c
rf49b0ea rcde485d 559 559 }; 560 560 561 void fat_mounted(ipc_callid_t rid, ipc_call_t *request) 562 { 563 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 564 int rc; 565 566 rc = fat_idx_init_by_dev_handle(dev_handle); 567 if (rc != EOK) { 568 ipc_answer_0(rid, rc); 569 return; 570 } 571 572 ipc_answer_0(rid, EOK); 573 } 574 575 void fat_mount(ipc_callid_t rid, ipc_call_t *request) 576 { 577 ipc_answer_0(rid, ENOTSUP); 578 } 579 561 580 void fat_lookup(ipc_callid_t rid, ipc_call_t *request) 562 581 {
Note:
See TracChangeset
for help on using the changeset viewer.