Rev 3595 | Rev 3621 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3595 | Rev 3609 | ||
---|---|---|---|
Line 232... | Line 232... | ||
232 | } |
232 | } |
233 | 233 | ||
234 | static void fat_node_put(void *node) |
234 | static void fat_node_put(void *node) |
235 | { |
235 | { |
236 | fat_node_t *nodep = (fat_node_t *)node; |
236 | fat_node_t *nodep = (fat_node_t *)node; |
- | 237 | bool destroy = false; |
|
237 | 238 | ||
238 | futex_down(&nodep->lock); |
239 | futex_down(&nodep->lock); |
239 | if (!--nodep->refcnt) { |
240 | if (!--nodep->refcnt) { |
- | 241 | if (nodep->idx) { |
|
240 | futex_down(&ffn_futex); |
242 | futex_down(&ffn_futex); |
241 | list_append(&nodep->ffn_link, &ffn_head); |
243 | list_append(&nodep->ffn_link, &ffn_head); |
242 | futex_up(&ffn_futex); |
244 | futex_up(&ffn_futex); |
- | 245 | } else { |
|
- | 246 | /* |
|
- | 247 | * The node does not have any index structure associated |
|
- | 248 | * with itself. This can only mean that we are releasing |
|
- | 249 | * the node after a failed attempt to allocate the index |
|
- | 250 | * structure for it. |
|
- | 251 | */ |
|
- | 252 | destroy = true; |
|
- | 253 | } |
|
243 | } |
254 | } |
244 | futex_up(&nodep->lock); |
255 | futex_up(&nodep->lock); |
- | 256 | if (destroy) |
|
- | 257 | free(node); |
|
245 | } |
258 | } |
246 | 259 | ||
247 | static void *fat_create(dev_handle_t dev_handle, int flags) |
260 | static void *fat_create_node(dev_handle_t dev_handle, int flags) |
248 | { |
261 | { |
- | 262 | fat_idx_t *idxp; |
|
- | 263 | fat_node_t *nodep; |
|
- | 264 | ||
- | 265 | nodep = fat_node_get_new(); |
|
- | 266 | if (!nodep) |
|
- | 267 | return NULL; |
|
- | 268 | idxp = fat_idx_get_new(dev_handle); |
|
- | 269 | if (!idxp) { |
|
- | 270 | fat_node_put(nodep); |
|
- | 271 | return NULL; |
|
- | 272 | } |
|
- | 273 | /* idxp->lock held */ |
|
- | 274 | if (flags & L_DIRECTORY) { |
|
- | 275 | nodep->type = FAT_DIRECTORY; |
|
- | 276 | } else { |
|
- | 277 | nodep->type = FAT_FILE; |
|
- | 278 | } |
|
- | 279 | nodep->size = 0; |
|
- | 280 | nodep->firstc = FAT_CLST_RES0; |
|
249 | return NULL; /* not supported at the moment */ |
281 | nodep->lnkcnt = 0; /* not linked anywhere */ |
- | 282 | nodep->refcnt = 1; |
|
- | 283 | ||
- | 284 | nodep->idx = idxp; |
|
- | 285 | idxp->nodep = nodep; |
|
- | 286 | ||
- | 287 | futex_up(&idxp->lock); |
|
- | 288 | return nodep; |
|
250 | } |
289 | } |
251 | 290 | ||
252 | static int fat_destroy(void *node) |
291 | static int fat_destroy_node(void *node) |
253 | { |
292 | { |
254 | return ENOTSUP; /* not supported at the moment */ |
293 | return ENOTSUP; /* not supported at the moment */ |
255 | } |
294 | } |
256 | 295 | ||
257 | static bool fat_link(void *prnt, void *chld, const char *name) |
296 | static bool fat_link(void *prnt, void *chld, const char *name) |
Line 422... | Line 461... | ||
422 | /** libfs operations */ |
461 | /** libfs operations */ |
423 | libfs_ops_t fat_libfs_ops = { |
462 | libfs_ops_t fat_libfs_ops = { |
424 | .match = fat_match, |
463 | .match = fat_match, |
425 | .node_get = fat_node_get, |
464 | .node_get = fat_node_get, |
426 | .node_put = fat_node_put, |
465 | .node_put = fat_node_put, |
427 | .create = fat_create, |
466 | .create = fat_create_node, |
428 | .destroy = fat_destroy, |
467 | .destroy = fat_destroy_node, |
429 | .link = fat_link, |
468 | .link = fat_link, |
430 | .unlink = fat_unlink, |
469 | .unlink = fat_unlink, |
431 | .index_get = fat_index_get, |
470 | .index_get = fat_index_get, |
432 | .size_get = fat_size_get, |
471 | .size_get = fat_size_get, |
433 | .lnkcnt_get = fat_lnkcnt_get, |
472 | .lnkcnt_get = fat_lnkcnt_get, |