Changeset f15cf1a6 in mainline
- Timestamp:
- 2008-02-17T16:22:10Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cf19ab5
- Parents:
- e704503
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/vfs.c
re704503 rf15cf1a6 311 311 int res; 312 312 ipcarg_t rc; 313 ipc_call_t answer; 314 aid_t req; 315 316 futex_down(&vfs_phone_futex); 317 async_serialize_start(); 318 if (vfs_phone < 0) { 319 res = vfs_connect(); 320 if (res < 0) { 321 async_serialize_end(); 322 futex_up(&vfs_phone_futex); 323 return res; 324 } 325 } 326 req = async_send_1(vfs_phone, VFS_MKDIR, mode, &answer); 313 aid_t req; 314 315 futex_down(&vfs_phone_futex); 316 async_serialize_start(); 317 if (vfs_phone < 0) { 318 res = vfs_connect(); 319 if (res < 0) { 320 async_serialize_end(); 321 futex_up(&vfs_phone_futex); 322 return res; 323 } 324 } 325 req = async_send_1(vfs_phone, VFS_MKDIR, mode, NULL); 327 326 rc = ipc_data_write_start(vfs_phone, path, strlen(path)); 328 327 if (rc != EOK) { … … 336 335 futex_up(&vfs_phone_futex); 337 336 return EOK; 337 } 338 339 static int _unlink(const char *path, int lflag) 340 { 341 int res; 342 ipcarg_t rc; 343 aid_t req; 344 345 futex_down(&vfs_phone_futex); 346 async_serialize_start(); 347 if (vfs_phone < 0) { 348 res = vfs_connect(); 349 if (res < 0) { 350 async_serialize_end(); 351 futex_up(&vfs_phone_futex); 352 return res; 353 } 354 } 355 req = async_send_0(vfs_phone, VFS_UNLINK, NULL); 356 rc = ipc_data_write_start(vfs_phone, path, strlen(path)); 357 if (rc != EOK) { 358 async_wait_for(req, NULL); 359 async_serialize_end(); 360 futex_up(&vfs_phone_futex); 361 return (int) rc; 362 } 363 async_wait_for(req, &rc); 364 async_serialize_end(); 365 futex_up(&vfs_phone_futex); 366 return EOK; 367 } 368 369 int unlink(const char *path) 370 { 371 return _unlink(path, L_NONE); 372 } 373 374 int rmdir(const char *path) 375 { 376 return _unlink(path, L_DIRECTORY); 338 377 } 339 378 -
uspace/lib/libc/include/unistd.h
re704503 rf15cf1a6 51 51 extern int ftruncate(int, off_t); 52 52 extern int close(int); 53 extern int unlink(const char *); 54 extern int rmdir(const char *); 53 55 54 56 extern void _exit(int status); -
uspace/srv/fs/tmpfs/tmpfs_ops.c
re704503 rf15cf1a6 331 331 /* handle hit */ 332 332 if (lflag & L_DESTROY) { 333 unsigned old_lnkcnt = TMPFS_GET_LNKCNT(dcur); 333 334 int res = destroy_component(dcur); 334 unsigned lnkcnt = (res == EOK) ? 0 : TMPFS_GET_LNKCNT(dcur);335 335 ipc_answer_5(rid, (ipcarg_t)res, tmpfs_reg.fs_handle, 336 dev_handle, dcur->index, dcur->size, lnkcnt);336 dev_handle, dcur->index, dcur->size, old_lnkcnt); 337 337 return; 338 338 } -
uspace/srv/vfs/vfs.c
re704503 rf15cf1a6 112 112 vfs_mkdir(callid, &call); 113 113 break; 114 case VFS_UNLINK: 115 vfs_unlink(callid, &call); 116 break; 114 117 default: 115 118 ipc_answer_0(callid, ENOTSUP); -
uspace/srv/vfs/vfs.h
re704503 rf15cf1a6 142 142 */ 143 143 /** 144 * No lookup flags used. 145 */ 146 #define L_NONE 0 147 /** 144 148 * Lookup will succeed only if the object is a regular file. If L_CREATE is 145 149 * specified, an empty file will be created. This flag is mutually exclusive … … 276 280 extern void vfs_truncate(ipc_callid_t, ipc_call_t *); 277 281 extern void vfs_mkdir(ipc_callid_t, ipc_call_t *); 282 extern void vfs_unlink(ipc_callid_t, ipc_call_t *); 278 283 279 284 #endif -
uspace/srv/vfs/vfs_ops.c
re704503 rf15cf1a6 591 591 { 592 592 int mode = IPC_GET_ARG1(*request); 593 593 594 size_t len; 594 595 595 ipc_callid_t callid; 596 596 … … 630 630 } 631 631 632 void vfs_unlink(ipc_callid_t rid, ipc_call_t *request) 633 { 634 int lflag = IPC_GET_ARG1(*request); 635 636 size_t len; 637 ipc_callid_t callid; 638 639 if (!ipc_data_write_receive(&callid, &len)) { 640 ipc_answer_0(callid, EINVAL); 641 ipc_answer_0(rid, EINVAL); 642 return; 643 } 644 645 /* 646 * Now we are on the verge of accepting the path. 647 * 648 * There is one optimization we could do in the future: copy the path 649 * directly into the PLB using some kind of a callback. 650 */ 651 char *path = malloc(len); 652 653 if (!path) { 654 ipc_answer_0(callid, ENOMEM); 655 ipc_answer_0(rid, ENOMEM); 656 return; 657 } 658 659 int rc; 660 if ((rc = ipc_data_write_finalize(callid, path, len))) { 661 ipc_answer_0(rid, rc); 662 free(path); 663 return; 664 } 665 666 rwlock_write_lock(&namespace_rwlock); 667 lflag &= L_DIRECTORY; /* sanitize lflag */ 668 vfs_lookup_res_t lr; 669 rc = vfs_lookup_internal(path, len, lflag | L_DESTROY, &lr, NULL); 670 free(path); 671 if (rc != EOK) { 672 rwlock_write_unlock(&namespace_rwlock); 673 ipc_answer_0(rid, rc); 674 return; 675 } 676 677 /* 678 * The name has already been unlinked by vfs_lookup_internal(). 679 * We have to get and put the VFS node to ensure that it is 680 * VFS_FREE'd after the last reference to it is dropped. 681 */ 682 vfs_node_t *node = vfs_node_get(&lr); 683 node->lnkcnt--; 684 rwlock_write_unlock(&namespace_rwlock); 685 vfs_node_put(node); 686 ipc_answer_0(rid, EOK); 687 } 688 632 689 /** 633 690 * @}
Note:
See TracChangeset
for help on using the changeset viewer.