Changeset b72efe8 in mainline for uspace/srv
- Timestamp:
- 2011-06-19T14:38:59Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 74464e8
- Parents:
- 1d1bb0f
- Location:
- uspace/srv
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r1d1bb0f rb72efe8 466 466 fibril_mutex_lock(&drivers_list->drivers_mutex); 467 467 468 link_t *link = drivers_list->drivers.next; 469 while (link != &drivers_list->drivers) { 468 list_foreach(drivers_list->drivers, link) { 470 469 drv = list_get_instance(link, driver_t, drivers); 471 470 score = get_match_score(drv, node); … … 474 473 best_drv = drv; 475 474 } 476 link = link->next;477 475 } 478 476 … … 536 534 driver_t *res = NULL; 537 535 driver_t *drv = NULL; 538 link_t *link;539 536 540 537 fibril_mutex_lock(&drv_list->drivers_mutex); 541 538 542 link = drv_list->drivers.next; 543 while (link != &drv_list->drivers) { 539 list_foreach(drv_list->drivers, link) { 544 540 drv = list_get_instance(link, driver_t, drivers); 545 541 if (str_cmp(drv->name, drv_name) == 0) { … … 547 543 break; 548 544 } 549 550 link = link->next;551 545 } 552 546 … … 584 578 * that has not been passed to the driver. 585 579 */ 586 link = driver->devices. next;587 while (link != &driver->devices ) {580 link = driver->devices.head.next; 581 while (link != &driver->devices.head) { 588 582 dev = list_get_instance(link, dev_node_t, driver_devices); 589 583 if (dev->passed_to_driver) { … … 622 616 * Restart the cycle to go through all devices again. 623 617 */ 624 link = driver->devices. next;618 link = driver->devices.head.next; 625 619 } 626 620 … … 1187 1181 1188 1182 fun_node_t *fun; 1189 link_t *link; 1190 1191 for (link = dev->functions.next; 1192 link != &dev->functions; 1193 link = link->next) { 1183 1184 list_foreach(dev->functions, link) { 1194 1185 fun = list_get_instance(link, fun_node_t, dev_functions); 1195 1186 … … 1385 1376 { 1386 1377 dev_class_t *cl; 1387 link_t *link = class_list->classes.next; 1388 1389 while (link != &class_list->classes) { 1378 1379 list_foreach(class_list->classes, link) { 1390 1380 cl = list_get_instance(link, dev_class_t, link); 1391 1381 if (str_cmp(cl->name, class_name) == 0) { 1392 1382 return cl; 1393 1383 } 1394 link = link->next;1395 1384 } 1396 1385 … … 1408 1397 assert(dev_name != NULL); 1409 1398 1410 link_t *link; 1411 for (link = dev_class->devices.next; 1412 link != &dev_class->devices; 1413 link = link->next) { 1399 list_foreach(dev_class->devices, link) { 1414 1400 dev_class_info_t *dev = list_get_instance(link, 1415 1401 dev_class_info_t, link); -
uspace/srv/devman/devman.h
r1d1bb0f rb72efe8 96 96 /** List of device ids for device-to-driver matching. */ 97 97 match_id_list_t match_ids; 98 /** Pointer to the linked list of devices controlled by this driver. */99 li nk_t devices;98 /** List of devices controlled by this driver. */ 99 list_t devices; 100 100 101 101 /** … … 108 108 typedef struct driver_list { 109 109 /** List of drivers */ 110 li nk_t drivers;110 list_t drivers; 111 111 /** Fibril mutex for list of drivers. */ 112 112 fibril_mutex_t drivers_mutex; … … 130 130 131 131 /** List of device functions. */ 132 li nk_t functions;132 list_t functions; 133 133 /** Driver of this device. */ 134 134 driver_t *drv; … … 170 170 match_id_list_t match_ids; 171 171 172 /** The list of device classes to which this device function belongs. */173 li nk_t classes;172 /** List of device classes to which this device function belongs. */ 173 list_t classes; 174 174 /** Devmap handle if the device function is registered by devmap. */ 175 175 devmap_handle_t devmap_handle; … … 228 228 * this class. 229 229 */ 230 li nk_t devices;230 list_t devices; 231 231 232 232 /** … … 280 280 typedef struct class_list { 281 281 /** List of classes. */ 282 li nk_t classes;282 list_t classes; 283 283 284 284 /** -
uspace/srv/devman/match.c
r1d1bb0f rb72efe8 59 59 int get_match_score(driver_t *drv, dev_node_t *dev) 60 60 { 61 link_t *drv_head = &drv->match_ids.ids ;62 link_t *dev_head = &dev->pfun->match_ids.ids ;61 link_t *drv_head = &drv->match_ids.ids.head; 62 link_t *dev_head = &dev->pfun->match_ids.ids.head; 63 63 64 if (list_empty(drv_head) || list_empty(dev_head)) 64 if (list_empty(&drv->match_ids.ids) || 65 list_empty(&dev->pfun->match_ids.ids)) { 65 66 return 0; 67 } 66 68 67 69 /* … … 70 72 int highest_score = 0; 71 73 72 link_t *drv_link = drv->match_ids.ids. next;74 link_t *drv_link = drv->match_ids.ids.head.next; 73 75 while (drv_link != drv_head) { 74 76 link_t *dev_link = dev_head->next; -
uspace/srv/devmap/devmap.c
r1d1bb0f rb72efe8 57 57 */ 58 58 typedef struct { 59 /** Pointers to previous and next drivers in linkedlist */59 /** Link to drivers_list */ 60 60 link_t drivers; 61 61 62 /** Pointer to the linked list of devices controlled by this driver */63 li nk_t devices;62 /** List of devices controlled by this driver */ 63 list_t devices; 64 64 65 65 /** Session asociated with this driver */ … … 77 77 */ 78 78 typedef struct { 79 /** Pointer to the previous and next device in the list of all namespaces*/79 /** Link to namespaces_list */ 80 80 link_t namespaces; 81 81 … … 94 94 */ 95 95 typedef struct { 96 /** Pointer to the previous and next device in the list of all devices*/96 /** Link to global list of devices (devices_list) */ 97 97 link_t devices; 98 /** Pointer to the previous and next device in the list of devices 99 owned by one driver */ 98 /** Link to driver list of devices (devmap_driver_t.devices) */ 100 99 link_t driver_devices; 101 100 /** Unique device identifier */ … … 225 224 static devmap_namespace_t *devmap_namespace_find_name(const char *name) 226 225 { 227 link_t *item;228 229 226 assert(fibril_mutex_is_locked(&devices_list_mutex)); 230 227 231 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {228 list_foreach(namespaces_list, item) { 232 229 devmap_namespace_t *namespace = 233 230 list_get_instance(item, devmap_namespace_t, namespaces); … … 246 243 static devmap_namespace_t *devmap_namespace_find_handle(devmap_handle_t handle) 247 244 { 248 link_t *item;249 250 245 assert(fibril_mutex_is_locked(&devices_list_mutex)); 251 246 252 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {247 list_foreach(namespaces_list, item) { 253 248 devmap_namespace_t *namespace = 254 249 list_get_instance(item, devmap_namespace_t, namespaces); … … 264 259 const char *name) 265 260 { 266 link_t *item;267 268 261 assert(fibril_mutex_is_locked(&devices_list_mutex)); 269 262 270 for (item = devices_list.next; item != &devices_list; item = item->next) {263 list_foreach(devices_list, item) { 271 264 devmap_device_t *device = 272 265 list_get_instance(item, devmap_device_t, devices); … … 286 279 static devmap_device_t *devmap_device_find_handle(devmap_handle_t handle) 287 280 { 288 link_t *item;289 290 281 assert(fibril_mutex_is_locked(&devices_list_mutex)); 291 282 292 for (item = devices_list.next; item != &devices_list; item = item->next) {283 list_foreach(devices_list, item) { 293 284 devmap_device_t *device = 294 285 list_get_instance(item, devmap_device_t, devices); … … 473 464 fibril_mutex_lock(&driver->devices_mutex); 474 465 475 while (!list_empty(&(driver->devices))) { 476 devmap_device_t *device = list_get_instance(driver->devices.next, 477 devmap_device_t, driver_devices); 466 while (!list_empty(&driver->devices)) { 467 devmap_device_t *device = list_get_instance( 468 list_first(&driver->devices), devmap_device_t, 469 driver_devices); 478 470 devmap_device_unregister_core(device); 479 471 } … … 815 807 } 816 808 817 link_t *item;818 809 size_t pos = 0; 819 for (item = namespaces_list.next; item != &namespaces_list; 820 item = item->next) { 810 list_foreach(namespaces_list, item) { 821 811 devmap_namespace_t *namespace = 822 812 list_get_instance(item, devmap_namespace_t, namespaces); … … 881 871 } 882 872 883 link_t *item;884 873 size_t pos = 0; 885 for (item = devices_list.next; item != &devices_list; item = item->next) {874 list_foreach(devices_list, item) { 886 875 devmap_device_t *device = 887 876 list_get_instance(item, devmap_device_t, devices); -
uspace/srv/fs/ext2fs/ext2fs_ops.c
r1d1bb0f rb72efe8 187 187 { 188 188 EXT2FS_DBG("(%" PRIun ", -)", devmap_handle); 189 link_t *link;190 189 ext2fs_instance_t *tmp; 191 190 … … 198 197 } 199 198 200 for (link = instance_list.next; link != &instance_list; link = link->next) {199 list_foreach(instance_list, link) { 201 200 tmp = list_get_instance(link, ext2fs_instance_t, link); 202 201 -
uspace/srv/fs/fat/fat_idx.c
r1d1bb0f rb72efe8 67 67 68 68 /** Sorted list of intervals of freed indices. */ 69 li nk_t freed_head;69 list_t freed_list; 70 70 } unused_t; 71 71 … … 74 74 75 75 /** List of unused structures. */ 76 static LIST_INITIALIZE(unused_ head);76 static LIST_INITIALIZE(unused_list); 77 77 78 78 static void unused_initialize(unused_t *u, devmap_handle_t devmap_handle) … … 82 82 u->next = 0; 83 83 u->remaining = ((uint64_t)((fs_index_t)-1)) + 1; 84 list_initialize(&u->freed_ head);84 list_initialize(&u->freed_list); 85 85 } 86 86 … … 88 88 { 89 89 unused_t *u; 90 link_t *l;91 90 92 91 if (lock) 93 92 fibril_mutex_lock(&unused_lock); 94 for (l = unused_head.next; l != &unused_head; l = l->next) { 93 94 list_foreach(unused_list, l) { 95 95 u = list_get_instance(l, unused_t, link); 96 96 if (u->devmap_handle == devmap_handle) 97 97 return u; 98 98 } 99 99 100 if (lock) 100 101 fibril_mutex_unlock(&unused_lock); … … 249 250 return false; 250 251 251 if (list_empty(&u->freed_ head)) {252 if (list_empty(&u->freed_list)) { 252 253 if (u->remaining) { 253 254 /* … … 262 263 } else { 263 264 /* There are some freed indices which we can reuse. */ 264 freed_t *f = list_get_instance( u->freed_head.next, freed_t,265 link);265 freed_t *f = list_get_instance(list_first(&u->freed_list), 266 freed_t, link); 266 267 *index = f->first; 267 268 if (f->first++ == f->last) { … … 320 321 link_t *lnk; 321 322 freed_t *n; 322 for (lnk = u->freed_ head.next; lnk != &u->freed_head;323 for (lnk = u->freed_list.head.next; lnk != &u->freed_list.head; 323 324 lnk = lnk->next) { 324 325 freed_t *f = list_get_instance(lnk, freed_t, link); 325 326 if (f->first == index + 1) { 326 327 f->first--; 327 if (lnk->prev != &u->freed_ head)328 if (lnk->prev != &u->freed_list.head) 328 329 try_coalesce_intervals(lnk->prev, lnk, 329 330 lnk); … … 333 334 if (f->last == index - 1) { 334 335 f->last++; 335 if (lnk->next != &u->freed_ head)336 if (lnk->next != &u->freed_list.head) 336 337 try_coalesce_intervals(lnk, lnk->next, 337 338 lnk); … … 359 360 n->first = index; 360 361 n->last = index; 361 list_append(&n->link, &u->freed_ head);362 list_append(&n->link, &u->freed_list); 362 363 } 363 364 fibril_mutex_unlock(&unused_lock); … … 558 559 fibril_mutex_lock(&unused_lock); 559 560 if (!unused_find(devmap_handle, false)) { 560 list_append(&u->link, &unused_ head);561 list_append(&u->link, &unused_list); 561 562 } else { 562 563 free(u); … … 594 595 fibril_mutex_unlock(&unused_lock); 595 596 596 while (!list_empty(&u->freed_ head)) {597 while (!list_empty(&u->freed_list)) { 597 598 freed_t *f; 598 f = list_get_instance( u->freed_head.next, freed_t, link);599 f = list_get_instance(list_first(&u->freed_list), freed_t, link); 599 600 list_remove(&f->link); 600 601 free(f); -
uspace/srv/fs/fat/fat_ops.c
r1d1bb0f rb72efe8 67 67 68 68 /** List of cached free FAT nodes. */ 69 static LIST_INITIALIZE(ffn_ head);69 static LIST_INITIALIZE(ffn_list); 70 70 71 71 /* … … 147 147 static int fat_node_fini_by_devmap_handle(devmap_handle_t devmap_handle) 148 148 { 149 link_t *lnk;150 149 fat_node_t *nodep; 151 150 int rc; … … 159 158 restart: 160 159 fibril_mutex_lock(&ffn_mutex); 161 for (lnk = ffn_head.next; lnk != &ffn_head; lnk = lnk->next) {160 list_foreach(ffn_list, lnk) { 162 161 nodep = list_get_instance(lnk, fat_node_t, ffn_link); 163 162 if (!fibril_mutex_trylock(&nodep->lock)) { … … 196 195 free(nodep); 197 196 198 /* Need to restart because we changed the ffn_headlist. */197 /* Need to restart because we changed ffn_list. */ 199 198 goto restart; 200 199 } … … 211 210 212 211 fibril_mutex_lock(&ffn_mutex); 213 if (!list_empty(&ffn_ head)) {212 if (!list_empty(&ffn_list)) { 214 213 /* Try to use a cached free node structure. */ 215 214 fat_idx_t *idxp_tmp; 216 nodep = list_get_instance(ffn_head.next, fat_node_t, ffn_link); 215 nodep = list_get_instance(list_first(&ffn_list), fat_node_t, 216 ffn_link); 217 217 if (!fibril_mutex_trylock(&nodep->lock)) 218 218 goto skip_cache; … … 473 473 if (nodep->idx) { 474 474 fibril_mutex_lock(&ffn_mutex); 475 list_append(&nodep->ffn_link, &ffn_ head);475 list_append(&nodep->ffn_link, &ffn_list); 476 476 fibril_mutex_unlock(&ffn_mutex); 477 477 } else { -
uspace/srv/fs/tmpfs/tmpfs.h
r1d1bb0f rb72efe8 67 67 size_t size; /**< File size if type is TMPFS_FILE. */ 68 68 void *data; /**< File content's if type is TMPFS_FILE. */ 69 li nk_t cs_head; /**< Head of child's siblings list. */69 list_t cs_list; /**< Child's siblings list. */ 70 70 } tmpfs_node_t; 71 71 -
uspace/srv/fs/tmpfs/tmpfs_ops.c
r1d1bb0f rb72efe8 85 85 static int tmpfs_has_children(bool *has_children, fs_node_t *fn) 86 86 { 87 *has_children = !list_empty(&TMPFS_NODE(fn)->cs_ head);87 *has_children = !list_empty(&TMPFS_NODE(fn)->cs_list); 88 88 return EOK; 89 89 } … … 180 180 nh_link); 181 181 182 while (!list_empty(&nodep->cs_ head)) {183 tmpfs_dentry_t *dentryp = list_get_instance( nodep->cs_head.next,184 tmpfs_dentry_t, link);182 while (!list_empty(&nodep->cs_list)) { 183 tmpfs_dentry_t *dentryp = list_get_instance( 184 list_first(&nodep->cs_list), tmpfs_dentry_t, link); 185 185 186 186 assert(nodep->type == TMPFS_DIRECTORY); … … 214 214 nodep->data = NULL; 215 215 link_initialize(&nodep->nh_link); 216 list_initialize(&nodep->cs_ head);216 list_initialize(&nodep->cs_list); 217 217 } 218 218 … … 262 262 { 263 263 tmpfs_node_t *parentp = TMPFS_NODE(pfn); 264 link_t *lnk; 265 266 for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head; 267 lnk = lnk->next) { 264 265 list_foreach(parentp->cs_list, lnk) { 268 266 tmpfs_dentry_t *dentryp; 269 267 dentryp = list_get_instance(lnk, tmpfs_dentry_t, link); … … 353 351 354 352 assert(!nodep->lnkcnt); 355 assert(list_empty(&nodep->cs_ head));353 assert(list_empty(&nodep->cs_list)); 356 354 357 355 unsigned long key[] = { … … 373 371 tmpfs_node_t *childp = TMPFS_NODE(cfn); 374 372 tmpfs_dentry_t *dentryp; 375 link_t *lnk;376 373 377 374 assert(parentp->type == TMPFS_DIRECTORY); 378 375 379 376 /* Check for duplicit entries. */ 380 for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head; 381 lnk = lnk->next) { 377 list_foreach(parentp->cs_list, lnk) { 382 378 dentryp = list_get_instance(lnk, tmpfs_dentry_t, link); 383 379 if (!str_cmp(dentryp->name, nm)) … … 401 397 dentryp->node = childp; 402 398 childp->lnkcnt++; 403 list_append(&dentryp->link, &parentp->cs_ head);399 list_append(&dentryp->link, &parentp->cs_list); 404 400 405 401 return EOK; … … 411 407 tmpfs_node_t *childp = NULL; 412 408 tmpfs_dentry_t *dentryp; 413 link_t *lnk;414 409 415 410 if (!parentp) 416 411 return EBUSY; 417 412 418 for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head; 419 lnk = lnk->next) { 413 list_foreach(parentp->cs_list, lnk) { 420 414 dentryp = list_get_instance(lnk, tmpfs_dentry_t, link); 421 415 if (!str_cmp(dentryp->name, nm)) { … … 423 417 assert(FS_NODE(childp) == cfn); 424 418 break; 425 } 419 } 426 420 } 427 421 … … 429 423 return ENOENT; 430 424 431 if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_ head))425 if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_list)) 432 426 return ENOTEMPTY; 433 427 … … 550 544 tmpfs_dentry_t *dentryp; 551 545 link_t *lnk; 552 aoff64_t i;553 546 554 547 assert(nodep->type == TMPFS_DIRECTORY); … … 559 552 * hash table. 560 553 */ 561 for (i = 0, lnk = nodep->cs_head.next; 562 (i < pos) && (lnk != &nodep->cs_head); 563 i++, lnk = lnk->next) 564 ; 565 566 if (lnk == &nodep->cs_head) { 554 lnk = list_nth(&nodep->cs_list, pos); 555 556 if (lnk == NULL) { 567 557 async_answer_0(callid, ENOENT); 568 558 async_answer_1(rid, ENOENT, 0); -
uspace/srv/hid/input/generic/input.c
r1d1bb0f rb72efe8 75 75 76 76 /** List of keyboard devices */ 77 static li nk_t kbd_devs;77 static list_t kbd_devs; 78 78 79 79 /** List of mouse devices */ 80 li nk_t mouse_devs;80 list_t mouse_devs; 81 81 82 82 bool irc_service = false; -
uspace/srv/hid/input/include/input.h
r1d1bb0f rb72efe8 47 47 extern int irc_phone; 48 48 49 extern li nk_t mouse_devs;49 extern list_t mouse_devs; 50 50 51 51 void input_event_move(int, int); -
uspace/srv/hw/netif/ne2000/dp8390.c
r1d1bb0f rb72efe8 483 483 } 484 484 485 static li nk_t *ne2k_receive(ne2k_t *ne2k)485 static list_t *ne2k_receive(ne2k_t *ne2k) 486 486 { 487 487 /* … … 490 490 * frames from the network, but they will be lost. 491 491 */ 492 li nk_t *frames = (link_t *) malloc(sizeof(link_t));492 list_t *frames = (list_t *) malloc(sizeof(list_t)); 493 493 if (frames != NULL) 494 494 list_initialize(frames); … … 567 567 } 568 568 569 li nk_t *ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, uint8_t tsr)569 list_t *ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, uint8_t tsr) 570 570 { 571 571 /* List of received frames */ 572 li nk_t *frames = NULL;572 list_t *frames = NULL; 573 573 574 574 if (isr & (ISR_PTX | ISR_TXE)) { -
uspace/srv/hw/netif/ne2000/dp8390.h
r1d1bb0f rb72efe8 241 241 extern void ne2k_down(ne2k_t *); 242 242 extern void ne2k_send(ne2k_t *, packet_t *); 243 extern li nk_t *ne2k_interrupt(ne2k_t *, uint8_t, uint8_t);243 extern list_t *ne2k_interrupt(ne2k_t *, uint8_t, uint8_t); 244 244 245 245 #endif -
uspace/srv/hw/netif/ne2000/ne2000.c
r1d1bb0f rb72efe8 168 168 169 169 if (ne2k != NULL) { 170 li nk_t *frames =170 list_t *frames = 171 171 ne2k_interrupt(ne2k, IRQ_GET_ISR(*call), IRQ_GET_TSR(*call)); 172 172 173 173 if (frames != NULL) { 174 174 while (!list_empty(frames)) { 175 frame_t *frame = 176 list_ get_instance(frames->next, frame_t, link);175 frame_t *frame = list_get_instance( 176 list_first(frames), frame_t, link); 177 177 178 178 list_remove(&frame->link); 179 nil_received_msg(nil_phone, device_id, frame->packet,180 SERVICE_NONE);179 nil_received_msg(nil_phone, device_id, 180 frame->packet, SERVICE_NONE); 181 181 free(frame); 182 182 } -
uspace/srv/ns/clonable.c
r1d1bb0f rb72efe8 52 52 53 53 /** List of clonable-service connection requests. */ 54 static li nk_t cs_req;54 static list_t cs_req; 55 55 56 56 int clonable_init(void) … … 76 76 ipc_callid_t callid) 77 77 { 78 if (list_empty(&cs_req)) { 78 link_t *req_link; 79 80 req_link = list_first(&cs_req); 81 if (req_link == NULL) { 79 82 /* There was no pending connection request. */ 80 83 printf("%s: Unexpected clonable server.\n", NAME); … … 83 86 } 84 87 85 cs_req_t *csr = list_get_instance( cs_req.next, cs_req_t, link);86 list_remove( &csr->link);88 cs_req_t *csr = list_get_instance(req_link, cs_req_t, link); 89 list_remove(req_link); 87 90 88 91 /* Currently we can only handle a single type of clonable service. */ -
uspace/srv/ns/service.c
r1d1bb0f rb72efe8 123 123 } pending_conn_t; 124 124 125 static li nk_t pending_conn;125 static list_t pending_conn; 126 126 127 127 int service_init(void) … … 141 141 void process_pending_conn(void) 142 142 { 143 link_t *cur;144 145 143 loop: 146 for (cur = pending_conn.next; cur != &pending_conn; cur = cur->next) {144 list_foreach(pending_conn, cur) { 147 145 pending_conn_t *pr = list_get_instance(cur, pending_conn_t, link); 148 146 -
uspace/srv/ns/task.c
r1d1bb0f rb72efe8 189 189 } pending_wait_t; 190 190 191 static li nk_t pending_wait;191 static list_t pending_wait; 192 192 193 193 int task_init(void) … … 212 212 void process_pending_wait(void) 213 213 { 214 link_t *cur;215 214 task_exit_t texit; 216 215 217 216 loop: 218 for (cur = pending_wait.next; cur != &pending_wait; cur = cur->next) {217 list_foreach(pending_wait, cur) { 219 218 pending_wait_t *pr = list_get_instance(cur, pending_wait_t, link); 220 219 -
uspace/srv/vfs/vfs.h
r1d1bb0f rb72efe8 145 145 extern fibril_mutex_t nodes_mutex; 146 146 147 extern fibril_condvar_t fs_ head_cv;148 extern fibril_mutex_t fs_ head_lock;149 extern li nk_t fs_head; /**< List of registered file systems. */147 extern fibril_condvar_t fs_list_cv; 148 extern fibril_mutex_t fs_list_lock; 149 extern list_t fs_list; /**< List of registered file systems. */ 150 150 151 151 extern vfs_pair_t rootfs; /**< Root file system. */ … … 158 158 } plb_entry_t; 159 159 160 extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_ head. */160 extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_entries. */ 161 161 extern uint8_t *plb; /**< Path Lookup Buffer */ 162 extern li nk_t plb_head;/**< List of active PLB entries. */162 extern list_t plb_entries; /**< List of active PLB entries. */ 163 163 164 164 #define MAX_MNTOPTS_LEN 256 -
uspace/srv/vfs/vfs_lookup.c
r1d1bb0f rb72efe8 50 50 51 51 FIBRIL_MUTEX_INITIALIZE(plb_mutex); 52 LIST_INITIALIZE(plb_ head); /**< PLB entry ring buffer. */52 LIST_INITIALIZE(plb_entries); /**< PLB entry ring buffer. */ 53 53 uint8_t *plb = NULL; 54 54 … … 102 102 size_t last; /* the last free index */ 103 103 104 if (list_empty(&plb_ head)) {104 if (list_empty(&plb_entries)) { 105 105 first = 0; 106 106 last = PLB_SIZE - 1; 107 107 } else { 108 plb_entry_t *oldest = list_get_instance( plb_head.next,109 plb_entry_t, plb_link);110 plb_entry_t *newest = list_get_instance( plb_head.prev,111 plb_entry_t, plb_link);108 plb_entry_t *oldest = list_get_instance( 109 list_first(&plb_entries), plb_entry_t, plb_link); 110 plb_entry_t *newest = list_get_instance( 111 list_last(&plb_entries), plb_entry_t, plb_link); 112 112 113 113 first = (newest->index + newest->len) % PLB_SIZE; … … 145 145 * buffer. 146 146 */ 147 list_append(&entry.plb_link, &plb_ head);147 list_append(&entry.plb_link, &plb_entries); 148 148 149 149 fibril_mutex_unlock(&plb_mutex); -
uspace/srv/vfs/vfs_ops.c
r1d1bb0f rb72efe8 325 325 * This will also give us its file system handle. 326 326 */ 327 fibril_mutex_lock(&fs_ head_lock);327 fibril_mutex_lock(&fs_list_lock); 328 328 fs_handle_t fs_handle; 329 329 recheck: … … 331 331 if (!fs_handle) { 332 332 if (flags & IPC_FLAG_BLOCKING) { 333 fibril_condvar_wait(&fs_ head_cv, &fs_head_lock);333 fibril_condvar_wait(&fs_list_cv, &fs_list_lock); 334 334 goto recheck; 335 335 } 336 336 337 fibril_mutex_unlock(&fs_ head_lock);337 fibril_mutex_unlock(&fs_list_lock); 338 338 async_answer_0(callid, ENOENT); 339 339 async_answer_0(rid, ENOENT); … … 343 343 return; 344 344 } 345 fibril_mutex_unlock(&fs_ head_lock);345 fibril_mutex_unlock(&fs_list_lock); 346 346 347 347 /* Acknowledge that we know fs_name. */ -
uspace/srv/vfs/vfs_register.c
r1d1bb0f rb72efe8 52 52 #include "vfs.h" 53 53 54 FIBRIL_CONDVAR_INITIALIZE(fs_ head_cv);55 FIBRIL_MUTEX_INITIALIZE(fs_ head_lock);56 LIST_INITIALIZE(fs_ head);54 FIBRIL_CONDVAR_INITIALIZE(fs_list_cv); 55 FIBRIL_MUTEX_INITIALIZE(fs_list_lock); 56 LIST_INITIALIZE(fs_list); 57 57 58 58 atomic_t fs_handle_next = { … … 149 149 } 150 150 151 fibril_mutex_lock(&fs_ head_lock);151 fibril_mutex_lock(&fs_list_lock); 152 152 153 153 /* … … 159 159 */ 160 160 dprintf("FS is already registered.\n"); 161 fibril_mutex_unlock(&fs_ head_lock);161 fibril_mutex_unlock(&fs_list_lock); 162 162 free(fs_info); 163 163 async_answer_0(rid, EEXISTS); … … 169 169 */ 170 170 dprintf("Inserting FS into the list of registered file systems.\n"); 171 list_append(&fs_info->fs_link, &fs_ head);171 list_append(&fs_info->fs_link, &fs_list); 172 172 173 173 /* … … 180 180 dprintf("Callback connection expected\n"); 181 181 list_remove(&fs_info->fs_link); 182 fibril_mutex_unlock(&fs_ head_lock);182 fibril_mutex_unlock(&fs_list_lock); 183 183 free(fs_info); 184 184 async_answer_0(rid, EINVAL); … … 197 197 dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call)); 198 198 list_remove(&fs_info->fs_link); 199 fibril_mutex_unlock(&fs_ head_lock);199 fibril_mutex_unlock(&fs_list_lock); 200 200 async_hangup(fs_info->sess); 201 201 free(fs_info); … … 211 211 dprintf("Client suggests wrong size of PFB, size = %d\n", size); 212 212 list_remove(&fs_info->fs_link); 213 fibril_mutex_unlock(&fs_ head_lock);213 fibril_mutex_unlock(&fs_list_lock); 214 214 async_hangup(fs_info->sess); 215 215 free(fs_info); … … 235 235 async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle); 236 236 237 fibril_condvar_broadcast(&fs_ head_cv);238 fibril_mutex_unlock(&fs_ head_lock);237 fibril_condvar_broadcast(&fs_list_cv); 238 fibril_mutex_unlock(&fs_list_lock); 239 239 240 240 dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n", … … 254 254 /* 255 255 * For now, we don't try to be very clever and very fast. 256 * We simply lookup the session in the fs_headlist and256 * We simply lookup the session in fs_list and 257 257 * begin an exchange. 258 258 */ 259 fibril_mutex_lock(&fs_head_lock); 260 261 link_t *cur; 262 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 259 fibril_mutex_lock(&fs_list_lock); 260 261 list_foreach(fs_list, cur) { 263 262 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 264 263 265 264 if (fs->fs_handle == handle) { 266 fibril_mutex_unlock(&fs_ head_lock);265 fibril_mutex_unlock(&fs_list_lock); 267 266 268 267 assert(fs->sess); … … 274 273 } 275 274 276 fibril_mutex_unlock(&fs_ head_lock);275 fibril_mutex_unlock(&fs_list_lock); 277 276 278 277 return NULL; … … 293 292 * @param name File system name. 294 293 * @param lock If true, the function will lock and unlock the 295 * fs_ head_lock.294 * fs_list_lock. 296 295 * 297 296 * @return File system handle or zero if file system not found. … … 303 302 304 303 if (lock) 305 fibril_mutex_lock(&fs_head_lock); 306 307 link_t *cur; 308 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 304 fibril_mutex_lock(&fs_list_lock); 305 306 list_foreach(fs_list, cur) { 309 307 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 310 308 if (str_cmp(fs->vfs_info.name, name) == 0) { … … 315 313 316 314 if (lock) 317 fibril_mutex_unlock(&fs_ head_lock);315 fibril_mutex_unlock(&fs_list_lock); 318 316 319 317 return handle; … … 330 328 { 331 329 vfs_info_t *info = NULL; 332 link_t *cur; 333 334 fibril_mutex_lock(&fs_head_lock); 335 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 330 331 fibril_mutex_lock(&fs_list_lock); 332 list_foreach(fs_list, cur) { 336 333 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 337 334 if (fs->fs_handle == handle) { … … 340 337 } 341 338 } 342 fibril_mutex_unlock(&fs_ head_lock);339 fibril_mutex_unlock(&fs_list_lock); 343 340 344 341 return info;
Note:
See TracChangeset
for help on using the changeset viewer.