Rev 2951 | Rev 3110 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2951 | Rev 2953 | ||
---|---|---|---|
Line 389... | Line 389... | ||
389 | unsigned dps; /* dentries per sector */ |
389 | unsigned dps; /* dentries per sector */ |
390 | unsigned blocks; |
390 | unsigned blocks; |
391 | fat_dentry_t *d; |
391 | fat_dentry_t *d; |
392 | block_t *b; |
392 | block_t *b; |
393 | 393 | ||
- | 394 | futex_down(&parentp->idx->lock); |
|
394 | bps = fat_bps_get(parentp->idx->dev_handle); |
395 | bps = fat_bps_get(parentp->idx->dev_handle); |
395 | dps = bps / sizeof(fat_dentry_t); |
396 | dps = bps / sizeof(fat_dentry_t); |
396 | blocks = parentp->size / bps + (parentp->size % bps != 0); |
397 | blocks = parentp->size / bps + (parentp->size % bps != 0); |
397 | for (i = 0; i < blocks; i++) { |
398 | for (i = 0; i < blocks; i++) { |
398 | unsigned dentries; |
399 | unsigned dentries; |
Line 406... | Line 407... | ||
406 | switch (fat_classify_dentry(d)) { |
407 | switch (fat_classify_dentry(d)) { |
407 | case FAT_DENTRY_SKIP: |
408 | case FAT_DENTRY_SKIP: |
408 | continue; |
409 | continue; |
409 | case FAT_DENTRY_LAST: |
410 | case FAT_DENTRY_LAST: |
410 | block_put(b); |
411 | block_put(b); |
- | 412 | futex_up(&parentp->idx->lock); |
|
411 | return NULL; |
413 | return NULL; |
412 | default: |
414 | default: |
413 | case FAT_DENTRY_VALID: |
415 | case FAT_DENTRY_VALID: |
414 | dentry_name_canonify(d, name); |
416 | dentry_name_canonify(d, name); |
415 | break; |
417 | break; |
416 | } |
418 | } |
417 | if (strcmp(name, component) == 0) { |
419 | if (strcmp(name, component) == 0) { |
418 | /* hit */ |
420 | /* hit */ |
419 | void *node; |
421 | void *node; |
- | 422 | /* |
|
- | 423 | * Assume tree hierarchy for locking. We |
|
- | 424 | * already have the parent and now we are going |
|
- | 425 | * to lock the child. Never lock in the oposite |
|
- | 426 | * order. |
|
- | 427 | */ |
|
420 | fat_idx_t *idx = fat_idx_get_by_pos( |
428 | fat_idx_t *idx = fat_idx_get_by_pos( |
421 | parentp->idx->dev_handle, parentp->firstc, |
429 | parentp->idx->dev_handle, parentp->firstc, |
422 | i * dps + j); |
430 | i * dps + j); |
- | 431 | futex_up(&parentp->idx->lock); |
|
423 | if (!idx) { |
432 | if (!idx) { |
424 | /* |
433 | /* |
425 | * Can happen if memory is low or if we |
434 | * Can happen if memory is low or if we |
426 | * run out of 32-bit indices. |
435 | * run out of 32-bit indices. |
427 | */ |
436 | */ |
Line 434... | Line 443... | ||
434 | return node; |
443 | return node; |
435 | } |
444 | } |
436 | } |
445 | } |
437 | block_put(b); |
446 | block_put(b); |
438 | } |
447 | } |
439 | - | ||
- | 448 | futex_up(&parentp->idx->lock); |
|
440 | return NULL; |
449 | return NULL; |
441 | } |
450 | } |
442 | 451 | ||
443 | static fs_index_t fat_index_get(void *node) |
452 | static fs_index_t fat_index_get(void *node) |
444 | { |
453 | { |