Changes in uspace/srv/fs/tmpfs/tmpfs_ops.c [ffa2c8ef:75160a6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/tmpfs/tmpfs_ops.c
rffa2c8ef r75160a6 29 29 /** @addtogroup fs 30 30 * @{ 31 */ 31 */ 32 32 33 33 /** … … 39 39 #include "tmpfs.h" 40 40 #include "../../vfs/vfs.h" 41 #include <macros.h> 42 #include <stdint.h> 41 #include <ipc/ipc.h> 43 42 #include <async.h> 44 43 #include <errno.h> 45 44 #include <atomic.h> 46 45 #include <stdlib.h> 47 #include <str .h>46 #include <string.h> 48 47 #include <stdio.h> 49 48 #include <assert.h> … … 68 67 69 68 /* Forward declarations of static functions. */ 70 static int tmpfs_match(fs_node_t **, fs_node_t *, const char *); 71 static int tmpfs_node_get(fs_node_t **, devmap_handle_t, fs_index_t); 72 static int tmpfs_node_open(fs_node_t *); 73 static int tmpfs_node_put(fs_node_t *); 74 static int tmpfs_create_node(fs_node_t **, devmap_handle_t, int); 75 static int tmpfs_destroy_node(fs_node_t *); 69 static fs_node_t *tmpfs_match(fs_node_t *, const char *); 70 static fs_node_t *tmpfs_node_get(dev_handle_t, fs_index_t); 71 static void tmpfs_node_put(fs_node_t *); 72 static fs_node_t *tmpfs_create_node(dev_handle_t, int); 76 73 static int tmpfs_link_node(fs_node_t *, fs_node_t *, const char *); 77 74 static int tmpfs_unlink_node(fs_node_t *, fs_node_t *, const char *); 75 static int tmpfs_destroy_node(fs_node_t *); 78 76 79 77 /* Implementation of helper functions. */ 80 static int tmpfs_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)81 {82 return tmpfs_node_get(rfn, devmap_handle, TMPFS_SOME_ROOT);83 }84 85 static int tmpfs_has_children(bool *has_children, fs_node_t *fn)86 {87 *has_children = !list_empty(&TMPFS_NODE(fn)->cs_head);88 return EOK;89 }90 91 78 static fs_index_t tmpfs_index_get(fs_node_t *fn) 92 79 { … … 94 81 } 95 82 96 static aoff64_t tmpfs_size_get(fs_node_t *fn)83 static size_t tmpfs_size_get(fs_node_t *fn) 97 84 { 98 85 return TMPFS_NODE(fn)->size; … … 104 91 } 105 92 93 static bool tmpfs_has_children(fs_node_t *fn) 94 { 95 return !list_empty(&TMPFS_NODE(fn)->cs_head); 96 } 97 98 static fs_node_t *tmpfs_root_get(dev_handle_t dev_handle) 99 { 100 return tmpfs_node_get(dev_handle, TMPFS_SOME_ROOT); 101 } 102 106 103 static char tmpfs_plb_get_char(unsigned pos) 107 104 { … … 117 114 { 118 115 return TMPFS_NODE(fn)->type == TMPFS_FILE; 119 }120 121 static devmap_handle_t tmpfs_device_get(fs_node_t *fn)122 {123 return 0;124 116 } 125 117 126 118 /** libfs operations */ 127 119 libfs_ops_t tmpfs_libfs_ops = { 128 .root_get = tmpfs_root_get,129 120 .match = tmpfs_match, 130 121 .node_get = tmpfs_node_get, 131 .node_open = tmpfs_node_open,132 122 .node_put = tmpfs_node_put, 133 123 .create = tmpfs_create_node, … … 135 125 .link = tmpfs_link_node, 136 126 .unlink = tmpfs_unlink_node, 137 .has_children = tmpfs_has_children,138 127 .index_get = tmpfs_index_get, 139 128 .size_get = tmpfs_size_get, 140 129 .lnkcnt_get = tmpfs_lnkcnt_get, 130 .has_children = tmpfs_has_children, 131 .root_get = tmpfs_root_get, 141 132 .plb_get_char = tmpfs_plb_get_char, 142 133 .is_directory = tmpfs_is_directory, 143 .is_file = tmpfs_is_file, 144 .device_get = tmpfs_device_get 134 .is_file = tmpfs_is_file 145 135 }; 146 136 … … 148 138 hash_table_t nodes; 149 139 150 #define NODES_KEY_ DEV 0151 #define NODES_KEY_ INDEX1140 #define NODES_KEY_INDEX 0 141 #define NODES_KEY_DEV 1 152 142 153 143 /* Implementation of hash table interface for the nodes hash table. */ … … 161 151 tmpfs_node_t *nodep = hash_table_get_instance(item, tmpfs_node_t, 162 152 nh_link); 163 164 switch (keys) { 165 case 1: 166 return (nodep->devmap_handle == key[NODES_KEY_DEV]); 167 case 2: 168 return ((nodep->devmap_handle == key[NODES_KEY_DEV]) && 169 (nodep->index == key[NODES_KEY_INDEX])); 170 default: 171 assert((keys == 1) || (keys == 2)); 172 } 173 174 return 0; 153 return (nodep->index == key[NODES_KEY_INDEX] && 154 nodep->dev_handle == key[NODES_KEY_DEV]); 175 155 } 176 156 177 157 static void nodes_remove_callback(link_t *item) 178 158 { 179 tmpfs_node_t *nodep = hash_table_get_instance(item, tmpfs_node_t,180 nh_link);181 182 while (!list_empty(&nodep->cs_head)) {183 tmpfs_dentry_t *dentryp = list_get_instance(nodep->cs_head.next,184 tmpfs_dentry_t, link);185 186 assert(nodep->type == TMPFS_DIRECTORY);187 list_remove(&dentryp->link);188 free(dentryp);189 }190 191 if (nodep->data) {192 assert(nodep->type == TMPFS_FILE);193 free(nodep->data);194 }195 free(nodep->bp);196 free(nodep);197 159 } 198 160 … … 208 170 nodep->bp = NULL; 209 171 nodep->index = 0; 210 nodep->dev map_handle = 0;172 nodep->dev_handle = 0; 211 173 nodep->type = TMPFS_NONE; 212 174 nodep->lnkcnt = 0; … … 232 194 } 233 195 234 static bool tmpfs_instance_init(dev map_handle_t devmap_handle)196 static bool tmpfs_instance_init(dev_handle_t dev_handle) 235 197 { 236 198 fs_node_t *rfn; 237 int rc;238 199 239 r c = tmpfs_create_node(&rfn, devmap_handle, L_DIRECTORY);240 if ( rc != EOK || !rfn)200 rfn = tmpfs_create_node(dev_handle, L_DIRECTORY); 201 if (!rfn) 241 202 return false; 242 203 TMPFS_NODE(rfn)->lnkcnt = 0; /* FS root is not linked */ … … 244 205 } 245 206 246 static void tmpfs_instance_done(devmap_handle_t devmap_handle) 247 { 248 unsigned long key[] = { 249 [NODES_KEY_DEV] = devmap_handle 250 }; 251 /* 252 * Here we are making use of one special feature of our hash table 253 * implementation, which allows to remove more items based on a partial 254 * key match. In the following, we are going to remove all nodes 255 * matching our device handle. The nodes_remove_callback() function will 256 * take care of resource deallocation. 257 */ 258 hash_table_remove(&nodes, key, 1); 259 } 260 261 int tmpfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component) 207 fs_node_t *tmpfs_match(fs_node_t *pfn, const char *component) 262 208 { 263 209 tmpfs_node_t *parentp = TMPFS_NODE(pfn); … … 266 212 for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head; 267 213 lnk = lnk->next) { 268 tmpfs_dentry_t *dentryp; 269 dentryp = list_get_instance(lnk, tmpfs_dentry_t, link); 270 if (!str_cmp(dentryp->name, component)) { 271 *rfn = FS_NODE(dentryp->node); 272 return EOK; 273 } 274 } 275 276 *rfn = NULL; 277 return EOK; 278 } 279 280 int tmpfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index) 214 tmpfs_dentry_t *dentryp = list_get_instance(lnk, tmpfs_dentry_t, 215 link); 216 if (!str_cmp(dentryp->name, component)) 217 return FS_NODE(dentryp->node); 218 } 219 220 return NULL; 221 } 222 223 fs_node_t *tmpfs_node_get(dev_handle_t dev_handle, fs_index_t index) 281 224 { 282 225 unsigned long key[] = { 283 [NODES_KEY_ DEV] = devmap_handle,284 [NODES_KEY_ INDEX] = index226 [NODES_KEY_INDEX] = index, 227 [NODES_KEY_DEV] = dev_handle 285 228 }; 286 229 link_t *lnk = hash_table_find(&nodes, key); 287 if (lnk) { 288 tmpfs_node_t *nodep; 289 nodep = hash_table_get_instance(lnk, tmpfs_node_t, nh_link); 290 *rfn = FS_NODE(nodep); 291 } else { 292 *rfn = NULL; 293 } 294 return EOK; 295 } 296 297 int tmpfs_node_open(fs_node_t *fn) 230 if (!lnk) 231 return NULL; 232 return FS_NODE(hash_table_get_instance(lnk, tmpfs_node_t, nh_link)); 233 } 234 235 void tmpfs_node_put(fs_node_t *fn) 298 236 { 299 237 /* nothing to do */ 300 return EOK; 301 } 302 303 int tmpfs_node_put(fs_node_t *fn) 304 { 305 /* nothing to do */ 306 return EOK; 307 } 308 309 int tmpfs_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int lflag) 310 { 311 fs_node_t *rootfn; 312 int rc; 313 238 } 239 240 fs_node_t *tmpfs_create_node(dev_handle_t dev_handle, int lflag) 241 { 314 242 assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY)); 315 243 316 244 tmpfs_node_t *nodep = malloc(sizeof(tmpfs_node_t)); 317 245 if (!nodep) 318 return ENOMEM;246 return NULL; 319 247 tmpfs_node_initialize(nodep); 320 248 nodep->bp = malloc(sizeof(fs_node_t)); 321 249 if (!nodep->bp) { 322 250 free(nodep); 323 return ENOMEM;251 return NULL; 324 252 } 325 253 fs_node_initialize(nodep->bp); 326 254 nodep->bp->data = nodep; /* link the FS and TMPFS nodes */ 327 328 rc = tmpfs_root_get(&rootfn, devmap_handle); 329 assert(rc == EOK); 330 if (!rootfn) 255 if (!tmpfs_root_get(dev_handle)) 331 256 nodep->index = TMPFS_SOME_ROOT; 332 257 else 333 258 nodep->index = tmpfs_next_index++; 334 nodep->dev map_handle = devmap_handle;259 nodep->dev_handle = dev_handle; 335 260 if (lflag & L_DIRECTORY) 336 261 nodep->type = TMPFS_DIRECTORY; … … 340 265 /* Insert the new node into the nodes hash table. */ 341 266 unsigned long key[] = { 342 [NODES_KEY_ DEV] = nodep->devmap_handle,343 [NODES_KEY_ INDEX] = nodep->index267 [NODES_KEY_INDEX] = nodep->index, 268 [NODES_KEY_DEV] = nodep->dev_handle 344 269 }; 345 270 hash_table_insert(&nodes, key, &nodep->nh_link); 346 *rfn = FS_NODE(nodep); 347 return EOK; 348 } 349 350 int tmpfs_destroy_node(fs_node_t *fn) 351 { 352 tmpfs_node_t *nodep = TMPFS_NODE(fn); 353 354 assert(!nodep->lnkcnt); 355 assert(list_empty(&nodep->cs_head)); 356 357 unsigned long key[] = { 358 [NODES_KEY_DEV] = nodep->devmap_handle, 359 [NODES_KEY_INDEX] = nodep->index 360 }; 361 hash_table_remove(&nodes, key, 2); 362 363 /* 364 * The nodes_remove_callback() function takes care of the actual 365 * resource deallocation. 366 */ 367 return EOK; 271 return FS_NODE(nodep); 368 272 } 369 273 … … 439 343 } 440 344 345 int tmpfs_destroy_node(fs_node_t *fn) 346 { 347 tmpfs_node_t *nodep = TMPFS_NODE(fn); 348 349 assert(!nodep->lnkcnt); 350 assert(list_empty(&nodep->cs_head)); 351 352 unsigned long key[] = { 353 [NODES_KEY_INDEX] = nodep->index, 354 [NODES_KEY_DEV] = nodep->dev_handle 355 }; 356 hash_table_remove(&nodes, key, 2); 357 358 if (nodep->type == TMPFS_FILE) 359 free(nodep->data); 360 free(nodep->bp); 361 free(nodep); 362 return EOK; 363 } 364 441 365 void tmpfs_mounted(ipc_callid_t rid, ipc_call_t *request) 442 366 { 443 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 444 fs_node_t *rootfn; 445 int rc; 446 447 /* Accept the mount options. */ 448 char *opts; 449 rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL); 450 if (rc != EOK) { 451 async_answer_0(rid, rc); 452 return; 453 } 454 455 /* Check if this device is not already mounted. */ 456 rc = tmpfs_root_get(&rootfn, devmap_handle); 457 if ((rc == EOK) && (rootfn)) { 458 (void) tmpfs_node_put(rootfn); 367 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 368 369 /* accept the mount options */ 370 ipc_callid_t callid; 371 size_t size; 372 if (!ipc_data_write_receive(&callid, &size)) { 373 ipc_answer_0(callid, EINVAL); 374 ipc_answer_0(rid, EINVAL); 375 return; 376 } 377 char *opts = malloc(size + 1); 378 if (!opts) { 379 ipc_answer_0(callid, ENOMEM); 380 ipc_answer_0(rid, ENOMEM); 381 return; 382 } 383 ipcarg_t retval = ipc_data_write_finalize(callid, opts, size); 384 if (retval != EOK) { 385 ipc_answer_0(rid, retval); 459 386 free(opts); 460 async_answer_0(rid, EEXIST);461 return;462 }387 return; 388 } 389 opts[size] = '\0'; 463 390 464 391 /* Initialize TMPFS instance. */ 465 if (!tmpfs_instance_init(devmap_handle)) { 466 free(opts); 467 async_answer_0(rid, ENOMEM); 468 return; 469 } 470 471 rc = tmpfs_root_get(&rootfn, devmap_handle); 472 assert(rc == EOK); 473 tmpfs_node_t *rootp = TMPFS_NODE(rootfn); 392 if (!tmpfs_instance_init(dev_handle)) { 393 ipc_answer_0(rid, ENOMEM); 394 return; 395 } 396 397 tmpfs_node_t *rootp = TMPFS_NODE(tmpfs_root_get(dev_handle)); 474 398 if (str_cmp(opts, "restore") == 0) { 475 if (tmpfs_restore(dev map_handle))476 async_answer_3(rid, EOK, rootp->index, rootp->size,399 if (tmpfs_restore(dev_handle)) 400 ipc_answer_3(rid, EOK, rootp->index, rootp->size, 477 401 rootp->lnkcnt); 478 402 else 479 async_answer_0(rid, ELIMIT);403 ipc_answer_0(rid, ELIMIT); 480 404 } else { 481 async_answer_3(rid, EOK, rootp->index, rootp->size,405 ipc_answer_3(rid, EOK, rootp->index, rootp->size, 482 406 rootp->lnkcnt); 483 407 } 484 free(opts);485 408 } 486 409 … … 490 413 } 491 414 492 void tmpfs_unmounted(ipc_callid_t rid, ipc_call_t *request)493 {494 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);495 496 tmpfs_instance_done(devmap_handle);497 async_answer_0(rid, EOK);498 }499 500 void tmpfs_unmount(ipc_callid_t rid, ipc_call_t *request)501 {502 libfs_unmount(&tmpfs_libfs_ops, rid, request);503 }504 505 415 void tmpfs_lookup(ipc_callid_t rid, ipc_call_t *request) 506 416 { … … 510 420 void tmpfs_read(ipc_callid_t rid, ipc_call_t *request) 511 421 { 512 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 513 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 514 aoff64_t pos = 515 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 516 422 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 423 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 424 off_t pos = (off_t)IPC_GET_ARG3(*request); 425 517 426 /* 518 427 * Lookup the respective TMPFS node. … … 520 429 link_t *hlp; 521 430 unsigned long key[] = { 522 [NODES_KEY_ DEV] = devmap_handle,523 [NODES_KEY_ INDEX] = index431 [NODES_KEY_INDEX] = index, 432 [NODES_KEY_DEV] = dev_handle, 524 433 }; 525 434 hlp = hash_table_find(&nodes, key); 526 435 if (!hlp) { 527 async_answer_0(rid, ENOENT);436 ipc_answer_0(rid, ENOENT); 528 437 return; 529 438 } 530 439 tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t, 531 440 nh_link); 532 441 533 442 /* 534 443 * Receive the read request. … … 536 445 ipc_callid_t callid; 537 446 size_t size; 538 if (! async_data_read_receive(&callid, &size)) {539 async_answer_0(callid, EINVAL);540 async_answer_0(rid, EINVAL);447 if (!ipc_data_read_receive(&callid, &size)) { 448 ipc_answer_0(callid, EINVAL); 449 ipc_answer_0(rid, EINVAL); 541 450 return; 542 451 } … … 544 453 size_t bytes; 545 454 if (nodep->type == TMPFS_FILE) { 546 bytes = m in(nodep->size - pos, size);547 (void) async_data_read_finalize(callid, nodep->data + pos,455 bytes = max(0, min(nodep->size - pos, size)); 456 (void) ipc_data_read_finalize(callid, nodep->data + pos, 548 457 bytes); 549 458 } else { 550 459 tmpfs_dentry_t *dentryp; 551 460 link_t *lnk; 552 aoff64_t i;461 int i; 553 462 554 463 assert(nodep->type == TMPFS_DIRECTORY); … … 560 469 */ 561 470 for (i = 0, lnk = nodep->cs_head.next; 562 (i < pos) && (lnk != &nodep->cs_head);471 i < pos && lnk != &nodep->cs_head; 563 472 i++, lnk = lnk->next) 564 473 ; 565 474 566 475 if (lnk == &nodep->cs_head) { 567 async_answer_0(callid, ENOENT);568 async_answer_1(rid, ENOENT, 0);476 ipc_answer_0(callid, ENOENT); 477 ipc_answer_1(rid, ENOENT, 0); 569 478 return; 570 479 } … … 572 481 dentryp = list_get_instance(lnk, tmpfs_dentry_t, link); 573 482 574 (void) async_data_read_finalize(callid, dentryp->name,483 (void) ipc_data_read_finalize(callid, dentryp->name, 575 484 str_size(dentryp->name) + 1); 576 485 bytes = 1; … … 580 489 * Answer the VFS_READ call. 581 490 */ 582 async_answer_1(rid, EOK, bytes);491 ipc_answer_1(rid, EOK, bytes); 583 492 } 584 493 585 494 void tmpfs_write(ipc_callid_t rid, ipc_call_t *request) 586 495 { 587 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 588 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 589 aoff64_t pos = 590 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 591 496 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 497 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 498 off_t pos = (off_t)IPC_GET_ARG3(*request); 499 592 500 /* 593 501 * Lookup the respective TMPFS node. … … 595 503 link_t *hlp; 596 504 unsigned long key[] = { 597 [NODES_KEY_ DEV] = devmap_handle,598 [NODES_KEY_ INDEX] = index505 [NODES_KEY_INDEX] = index, 506 [NODES_KEY_DEV] = dev_handle 599 507 }; 600 508 hlp = hash_table_find(&nodes, key); 601 509 if (!hlp) { 602 async_answer_0(rid, ENOENT);510 ipc_answer_0(rid, ENOENT); 603 511 return; 604 512 } … … 611 519 ipc_callid_t callid; 612 520 size_t size; 613 if (! async_data_write_receive(&callid, &size)) {614 async_answer_0(callid, EINVAL);615 async_answer_0(rid, EINVAL);521 if (!ipc_data_write_receive(&callid, &size)) { 522 ipc_answer_0(callid, EINVAL); 523 ipc_answer_0(rid, EINVAL); 616 524 return; 617 525 } … … 622 530 if (pos + size <= nodep->size) { 623 531 /* The file size is not changing. */ 624 (void) async_data_write_finalize(callid, nodep->data + pos, size);625 async_answer_2(rid, EOK, size, nodep->size);532 (void) ipc_data_write_finalize(callid, nodep->data + pos, size); 533 ipc_answer_2(rid, EOK, size, nodep->size); 626 534 return; 627 535 } … … 636 544 void *newdata = realloc(nodep->data, nodep->size + delta); 637 545 if (!newdata) { 638 async_answer_0(callid, ENOMEM);639 async_answer_2(rid, EOK, 0, nodep->size);546 ipc_answer_0(callid, ENOMEM); 547 ipc_answer_2(rid, EOK, 0, nodep->size); 640 548 return; 641 549 } … … 644 552 nodep->size += delta; 645 553 nodep->data = newdata; 646 (void) async_data_write_finalize(callid, nodep->data + pos, size);647 async_answer_2(rid, EOK, size, nodep->size);554 (void) ipc_data_write_finalize(callid, nodep->data + pos, size); 555 ipc_answer_2(rid, EOK, size, nodep->size); 648 556 } 649 557 650 558 void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request) 651 559 { 652 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 653 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 654 aoff64_t size = 655 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 656 560 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 561 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 562 size_t size = (off_t)IPC_GET_ARG3(*request); 563 657 564 /* 658 565 * Lookup the respective TMPFS node. 659 566 */ 567 link_t *hlp; 660 568 unsigned long key[] = { 661 [NODES_KEY_ DEV] = devmap_handle,662 [NODES_KEY_ INDEX] = index569 [NODES_KEY_INDEX] = index, 570 [NODES_KEY_DEV] = dev_handle 663 571 }; 664 link_t *hlp = hash_table_find(&nodes, key);572 hlp = hash_table_find(&nodes, key); 665 573 if (!hlp) { 666 async_answer_0(rid, ENOENT);574 ipc_answer_0(rid, ENOENT); 667 575 return; 668 576 } 669 577 tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t, 670 578 nh_link); 671 579 672 580 if (size == nodep->size) { 673 async_answer_0(rid, EOK); 674 return; 675 } 676 677 if (size > SIZE_MAX) { 678 async_answer_0(rid, ENOMEM); 679 return; 680 } 681 581 ipc_answer_0(rid, EOK); 582 return; 583 } 584 682 585 void *newdata = realloc(nodep->data, size); 683 586 if (!newdata) { 684 async_answer_0(rid, ENOMEM); 685 return; 686 } 687 587 ipc_answer_0(rid, ENOMEM); 588 return; 589 } 688 590 if (size > nodep->size) { 689 591 size_t delta = size - nodep->size; 690 592 memset(newdata + nodep->size, 0, delta); 691 593 } 692 693 594 nodep->size = size; 694 595 nodep->data = newdata; 695 async_answer_0(rid, EOK);596 ipc_answer_0(rid, EOK); 696 597 } 697 598 698 599 void tmpfs_close(ipc_callid_t rid, ipc_call_t *request) 699 600 { 700 async_answer_0(rid, EOK);601 ipc_answer_0(rid, EOK); 701 602 } 702 603 703 604 void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request) 704 605 { 705 dev map_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request);606 dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); 706 607 fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); 707 608 int rc; … … 709 610 link_t *hlp; 710 611 unsigned long key[] = { 711 [NODES_KEY_ DEV] = devmap_handle,712 [NODES_KEY_ INDEX] = index612 [NODES_KEY_INDEX] = index, 613 [NODES_KEY_DEV] = dev_handle 713 614 }; 714 615 hlp = hash_table_find(&nodes, key); 715 616 if (!hlp) { 716 async_answer_0(rid, ENOENT);617 ipc_answer_0(rid, ENOENT); 717 618 return; 718 619 } … … 720 621 nh_link); 721 622 rc = tmpfs_destroy_node(FS_NODE(nodep)); 722 async_answer_0(rid, rc);623 ipc_answer_0(rid, rc); 723 624 } 724 625 … … 735 636 void tmpfs_sync(ipc_callid_t rid, ipc_call_t *request) 736 637 { 737 /* 738 * TMPFS keeps its data structures always consistent, 739 * thus the sync operation is a no-op. 740 */ 741 async_answer_0(rid, EOK); 638 /* Dummy implementation */ 639 ipc_answer_0(rid, EOK); 742 640 } 743 641
Note:
See TracChangeset
for help on using the changeset viewer.