Rev 3516 | Rev 3521 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3516 | Rev 3519 | ||
---|---|---|---|
Line 114... | Line 114... | ||
114 | node->dirty = false; |
114 | node->dirty = false; |
115 | } |
115 | } |
116 | 116 | ||
117 | static void fat_node_sync(fat_node_t *node) |
117 | static void fat_node_sync(fat_node_t *node) |
118 | { |
118 | { |
119 | /* TODO */ |
119 | block_t *bb, *b; |
- | 120 | fat_dentry_t *d; |
|
- | 121 | uint16_t bps; |
|
- | 122 | unsigned dps; |
|
- | 123 | ||
- | 124 | assert(node->dirty); |
|
- | 125 | ||
- | 126 | bb = block_get(node->idx->dev_handle, BS_BLOCK, BS_SIZE); |
|
- | 127 | bps = uint16_t_le2host(FAT_BS(bb)->bps); |
|
- | 128 | dps = bps / sizeof(fat_dentry_t); |
|
- | 129 | ||
- | 130 | /* Read the block that contains the dentry of interest. */ |
|
- | 131 | b = _fat_block_get(bb->data, node->idx->dev_handle, node->idx->pfc, |
|
- | 132 | (node->idx->pdi * sizeof(fat_dentry_t)) / bps); |
|
- | 133 | ||
- | 134 | d = ((fat_dentry_t *)b->data) + (node->idx->pdi % dps); |
|
- | 135 | ||
- | 136 | d->firstc = host2uint16_t_le(node->firstc); |
|
- | 137 | if (node->type == FAT_FILE) |
|
- | 138 | d->size = host2uint32_t_le(node->size); |
|
- | 139 | /* TODO: update other fields? (e.g time fields, attr field) */ |
|
- | 140 | ||
- | 141 | b->dirty = true; /* need to sync block */ |
|
- | 142 | block_put(b); |
|
- | 143 | block_put(bb); |
|
120 | } |
144 | } |
121 | 145 | ||
122 | /** Internal version of fat_node_get(). |
146 | /** Internal version of fat_node_get(). |
123 | * |
147 | * |
124 | * @param idxp Locked index structure. |
148 | * @param idxp Locked index structure. |