Changeset b72efe8 in mainline for uspace/srv/fs
- 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/fs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.