Changeset 50e5b25 in mainline
- Timestamp:
- 2008-11-23T11:00:08Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f714576
- Parents:
- 31696b4f
- Location:
- uspace/srv/fs/fat
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat.h
r31696b4f r50e5b25 204 204 extern void fat_write(ipc_callid_t, ipc_call_t *); 205 205 extern void fat_truncate(ipc_callid_t, ipc_call_t *); 206 extern void fat_destroy(ipc_callid_t, ipc_call_t *); 206 207 207 208 extern fat_idx_t *fat_idx_get_new(dev_handle_t); -
uspace/srv/fs/fat/fat_ops.c
r31696b4f r50e5b25 217 217 } 218 218 219 /* 220 * Forward declarations of FAT libfs operations. 221 */ 222 static void *fat_node_get(dev_handle_t, fs_index_t); 223 static void fat_node_put(void *); 224 static void *fat_create_node(dev_handle_t, int); 225 static int fat_destroy_node(void *); 226 static bool fat_link(void *, void *, const char *); 227 static int fat_unlink(void *, void *); 228 static void *fat_match(void *, const char *); 229 static fs_index_t fat_index_get(void *); 230 static size_t fat_size_get(void *); 231 static unsigned fat_lnkcnt_get(void *); 232 static bool fat_has_children(void *); 233 static void *fat_root_get(dev_handle_t); 234 static char fat_plb_get_char(unsigned); 235 static bool fat_is_directory(void *); 236 static bool fat_is_file(void *node); 237 238 /* 239 * FAT libfs operations. 240 */ 241 219 242 /** Instantiate a FAT in-core node. */ 220 staticvoid *fat_node_get(dev_handle_t dev_handle, fs_index_t index)243 void *fat_node_get(dev_handle_t dev_handle, fs_index_t index) 221 244 { 222 245 void *node; … … 232 255 } 233 256 234 staticvoid fat_node_put(void *node)257 void fat_node_put(void *node) 235 258 { 236 259 fat_node_t *nodep = (fat_node_t *)node; … … 258 281 } 259 282 260 staticvoid *fat_create_node(dev_handle_t dev_handle, int flags)283 void *fat_create_node(dev_handle_t dev_handle, int flags) 261 284 { 262 285 fat_idx_t *idxp; … … 289 312 } 290 313 291 static int fat_destroy_node(void *node) 314 int fat_destroy_node(void *node) 315 { 316 fat_node_t *nodep = (fat_node_t *)node; 317 fat_bs_t *bs; 318 319 /* 320 * The node is not reachable from the file system. This means that the 321 * link count should be zero and that the index structure cannot be 322 * found in the position hash. Obviously, we don't need to lock the node 323 * nor its index structure. 324 */ 325 assert(nodep->lnkcnt == 0); 326 327 /* 328 * The node may not have any children. 329 */ 330 assert(fat_has_children(node) == false); 331 332 bs = block_bb_get(nodep->idx->dev_handle); 333 if (nodep->firstc != FAT_CLST_RES0) { 334 assert(nodep->size); 335 /* Free all clusters allocated to the node. */ 336 fat_free_clusters(bs, nodep->idx->dev_handle, nodep->firstc); 337 } 338 339 fat_idx_destroy(nodep->idx); 340 free(nodep); 341 return EOK; 342 } 343 344 bool fat_link(void *prnt, void *chld, const char *name) 345 { 346 return false; /* not supported at the moment */ 347 } 348 349 int fat_unlink(void *prnt, void *chld) 292 350 { 293 351 return ENOTSUP; /* not supported at the moment */ 294 352 } 295 353 296 static bool fat_link(void *prnt, void *chld, const char *name) 297 { 298 return false; /* not supported at the moment */ 299 } 300 301 static int fat_unlink(void *prnt, void *chld) 302 { 303 return ENOTSUP; /* not supported at the moment */ 304 } 305 306 static void *fat_match(void *prnt, const char *component) 354 void *fat_match(void *prnt, const char *component) 307 355 { 308 356 fat_bs_t *bs; … … 371 419 } 372 420 373 staticfs_index_t fat_index_get(void *node)421 fs_index_t fat_index_get(void *node) 374 422 { 375 423 fat_node_t *fnodep = (fat_node_t *)node; … … 379 427 } 380 428 381 s tatic size_t fat_size_get(void *node)429 size_t fat_size_get(void *node) 382 430 { 383 431 return ((fat_node_t *)node)->size; 384 432 } 385 433 386 staticunsigned fat_lnkcnt_get(void *node)434 unsigned fat_lnkcnt_get(void *node) 387 435 { 388 436 return ((fat_node_t *)node)->lnkcnt; 389 437 } 390 438 391 staticbool fat_has_children(void *node)439 bool fat_has_children(void *node) 392 440 { 393 441 fat_bs_t *bs; … … 439 487 } 440 488 441 staticvoid *fat_root_get(dev_handle_t dev_handle)489 void *fat_root_get(dev_handle_t dev_handle) 442 490 { 443 491 return fat_node_get(dev_handle, 0); 444 492 } 445 493 446 staticchar fat_plb_get_char(unsigned pos)494 char fat_plb_get_char(unsigned pos) 447 495 { 448 496 return fat_reg.plb_ro[pos % PLB_SIZE]; 449 497 } 450 498 451 staticbool fat_is_directory(void *node)499 bool fat_is_directory(void *node) 452 500 { 453 501 return ((fat_node_t *)node)->type == FAT_DIRECTORY; 454 502 } 455 503 456 staticbool fat_is_file(void *node)504 bool fat_is_file(void *node) 457 505 { 458 506 return ((fat_node_t *)node)->type == FAT_FILE; … … 839 887 } 840 888 889 void fat_destroy(ipc_callid_t rid, ipc_call_t *request) 890 { 891 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 892 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 893 int rc; 894 895 fat_node_t *nodep = fat_node_get(dev_handle, index); 896 if (!nodep) { 897 ipc_answer_0(rid, ENOENT); 898 return; 899 } 900 901 rc = fat_destroy_node(nodep); 902 ipc_answer_0(rid, rc); 903 } 904 841 905 /** 842 906 * @}
Note:
See TracChangeset
for help on using the changeset viewer.