Changeset cefd3ec in mainline
- Timestamp:
- 2011-06-11T19:18:42Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 52ee8b7a
- Parents:
- 8a40c49
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r8a40c49 rcefd3ec 374 374 int fat_match(fs_node_t **rfn, fs_node_t *pfn, const char *component) 375 375 { 376 fat_bs_t *bs;377 376 fat_node_t *parentp = FAT_NODE(pfn); 378 char name[FAT_NAME_LEN + 1 + FAT_EXT_LEN + 1]; 379 unsigned i, j; 380 unsigned blocks; 377 char name[FAT_LFN_NAME_SIZE]; 381 378 fat_dentry_t *d; 382 379 devmap_handle_t devmap_handle; 383 block_t *b;384 380 int rc; 385 381 … … 387 383 devmap_handle = parentp->idx->devmap_handle; 388 384 fibril_mutex_unlock(&parentp->idx->lock); 389 390 bs = block_bb_get(devmap_handle); 391 blocks = parentp->size / BPS(bs); 392 for (i = 0; i < blocks; i++) { 393 rc = fat_block_get(&b, bs, parentp, i, BLOCK_FLAGS_NONE); 394 if (rc != EOK) 395 return rc; 396 for (j = 0; j < DPS(bs); j++) { 397 d = ((fat_dentry_t *)b->data) + j; 398 switch (fat_classify_dentry(d)) { 399 case FAT_DENTRY_SKIP: 400 case FAT_DENTRY_FREE: 401 continue; 402 case FAT_DENTRY_LAST: 403 /* miss */ 404 rc = block_put(b); 405 *rfn = NULL; 406 return rc; 407 default: 408 case FAT_DENTRY_VALID: 409 fat_dentry_name_get(d, name); 410 break; 385 386 fat_directory_t di; 387 fat_directory_open(parentp, &di); 388 389 while (fat_directory_read(&di, name, &d) == EOK) { 390 if (fat_dentry_namecmp(name, component) == 0) { 391 /* hit */ 392 fat_node_t *nodep; 393 aoff64_t o = (di.pos-1) % (BPS(di.bs) / sizeof(fat_dentry_t)); 394 fat_idx_t *idx = fat_idx_get_by_pos(devmap_handle, 395 parentp->firstc, di.bnum * DPS(di.bs) + o); 396 if (!idx) { 397 /* 398 * Can happen if memory is low or if we 399 * run out of 32-bit indices. 400 */ 401 rc = fat_directory_close(&di); 402 return (rc == EOK) ? ENOMEM : rc; 411 403 } 412 if (fat_dentry_namecmp(name, component) == 0) { 413 /* hit */ 414 fat_node_t *nodep; 415 fat_idx_t *idx = fat_idx_get_by_pos(devmap_handle, 416 parentp->firstc, i * DPS(bs) + j); 417 if (!idx) { 418 /* 419 * Can happen if memory is low or if we 420 * run out of 32-bit indices. 421 */ 422 rc = block_put(b); 423 return (rc == EOK) ? ENOMEM : rc; 424 } 425 rc = fat_node_get_core(&nodep, idx); 426 fibril_mutex_unlock(&idx->lock); 427 if (rc != EOK) { 428 (void) block_put(b); 429 return rc; 430 } 431 *rfn = FS_NODE(nodep); 432 rc = block_put(b); 433 if (rc != EOK) 434 (void) fat_node_put(*rfn); 404 rc = fat_node_get_core(&nodep, idx); 405 fibril_mutex_unlock(&idx->lock); 406 if (rc != EOK) { 407 (void) fat_directory_close(&di); 435 408 return rc; 436 409 } 437 } 438 rc = block_put(b); 439 if (rc != EOK) 410 *rfn = FS_NODE(nodep); 411 rc = fat_directory_close(&di); 412 if (rc != EOK) 413 (void) fat_node_put(*rfn); 440 414 return rc; 441 }442 415 } 416 } 443 417 *rfn = NULL; 444 418 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.