Rev 3665 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3665 | Rev 3742 | ||
---|---|---|---|
Line 387... | Line 387... | ||
387 | block_t *b; |
387 | block_t *b; |
388 | int i, j; |
388 | int i, j; |
389 | uint16_t bps; |
389 | uint16_t bps; |
390 | unsigned dps; |
390 | unsigned dps; |
391 | unsigned blocks; |
391 | unsigned blocks; |
- | 392 | fat_cluster_t mcl, lcl; |
|
- | 393 | int rc; |
|
392 | 394 | ||
393 | futex_down(&childp->lock); |
395 | futex_down(&childp->lock); |
394 | if (childp->lnkcnt == 1) { |
396 | if (childp->lnkcnt == 1) { |
395 | /* |
397 | /* |
396 | * On FAT, we don't support multiple hard links. |
398 | * On FAT, we don't support multiple hard links. |
Line 435... | Line 437... | ||
435 | goto hit; |
437 | goto hit; |
436 | } |
438 | } |
437 | } |
439 | } |
438 | block_put(b); |
440 | block_put(b); |
439 | } |
441 | } |
- | 442 | j = 0; |
|
440 | 443 | ||
441 | /* |
444 | /* |
442 | * We need to grow the parent in order to create a new unused dentry. |
445 | * We need to grow the parent in order to create a new unused dentry. |
443 | */ |
446 | */ |
- | 447 | if (parentp->idx->pfc == FAT_CLST_ROOT) { |
|
- | 448 | /* Can't grow the root directory. */ |
|
444 | futex_up(&parentp->idx->lock); |
449 | futex_up(&parentp->idx->lock); |
445 | return ENOTSUP; /* XXX */ |
450 | return ENOSPC; |
- | 451 | } |
|
- | 452 | rc = fat_alloc_clusters(bs, parentp->idx->dev_handle, 1, &mcl, &lcl); |
|
- | 453 | if (rc != EOK) { |
|
- | 454 | futex_up(&parentp->idx->lock); |
|
- | 455 | return rc; |
|
- | 456 | } |
|
- | 457 | fat_append_clusters(bs, parentp, mcl); |
|
- | 458 | b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NOREAD); |
|
- | 459 | d = (fat_dentry_t *)b->data; |
|
- | 460 | /* |
|
- | 461 | * Clear all dentries in the block except for the first one (the first |
|
- | 462 | * dentry will be cleared in the next step). |
|
- | 463 | */ |
|
- | 464 | memset(d + 1, 0, bps - sizeof(fat_dentry_t)); |
|
446 | 465 | ||
447 | hit: |
466 | hit: |
448 | /* |
467 | /* |
449 | * At this point we only establish the link between the parent and the |
468 | * At this point we only establish the link between the parent and the |
450 | * child. The dentry, except of the name and the extension, will remain |
469 | * child. The dentry, except of the name and the extension, will remain |
451 | * uninitialized until the the corresponding node is synced. Thus the |
470 | * uninitialized until the corresponding node is synced. Thus the valid |
452 | * valid dentry data is kept in the child node structure. |
471 | * dentry data is kept in the child node structure. |
453 | */ |
472 | */ |
454 | memset(d, 0, sizeof(fat_dentry_t)); |
473 | memset(d, 0, sizeof(fat_dentry_t)); |
455 | fat_dentry_name_set(d, name); |
474 | fat_dentry_name_set(d, name); |
456 | b->dirty = true; /* need to sync block */ |
475 | b->dirty = true; /* need to sync block */ |
457 | block_put(b); |
476 | block_put(b); |