Changeset 72bde81 in mainline for uspace/srv/vfs/vfs_ops.c
- Timestamp:
- 2008-01-27T14:59:32Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2db4ac8
- Parents:
- 1fe186f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
r1fe186f r72bde81 116 116 } 117 117 118 /* 119 * Deliver the file system name. 120 */ 118 /* Deliver the file system name. */ 121 119 char fs_name[FS_NAME_MAXLEN + 1]; 122 120 (void) ipc_data_write_finalize(callid, fs_name, size); … … 133 131 } 134 132 135 /* 136 * Now, we want the client to send us the mount point. 137 */ 133 /* Now, we want the client to send us the mount point. */ 138 134 if (!ipc_data_write_receive(&callid, &size)) { 139 135 ipc_answer_0(callid, EINVAL); … … 142 138 } 143 139 144 /* 145 * Check whether size is reasonable wrt. the mount point. 146 */ 140 /* Check whether size is reasonable wrt. the mount point. */ 147 141 if (size < 1 || size > MAX_PATH_LEN) { 148 142 ipc_answer_0(callid, EINVAL); … … 150 144 return; 151 145 } 152 /* 153 * Allocate buffer for the mount point data being received. 154 */ 146 /* Allocate buffer for the mount point data being received. */ 155 147 uint8_t *buf; 156 148 buf = malloc(size); … … 161 153 } 162 154 163 /* 164 * Deliver the mount point. 165 */ 155 /* Deliver the mount point. */ 166 156 (void) ipc_data_write_finalize(callid, buf, size); 167 157 … … 187 177 } 188 178 189 /* 190 * Finally, we need to resolve the path to the mountpoint. 191 */ 179 /* Finally, we need to resolve the path to the mountpoint. */ 192 180 vfs_lookup_res_t mp_res; 193 181 futex_down(&rootfs_futex); 194 182 if (rootfs.fs_handle) { 195 /* 196 * We already have the root FS. 197 */ 183 /* We already have the root FS. */ 198 184 rwlock_write_lock(&namespace_rwlock); 199 185 rc = vfs_lookup_internal(buf, size, L_DIRECTORY, &mp_res, 200 186 NULL); 201 187 if (rc != EOK) { 202 /* 203 * The lookup failed for some reason. 204 */ 188 /* The lookup failed for some reason. */ 205 189 rwlock_write_unlock(&namespace_rwlock); 206 190 futex_up(&rootfs_futex); … … 226 210 rwlock_write_unlock(&namespace_rwlock); 227 211 } else { 228 /* 229 * We still don't have the root file system mounted. 230 */ 212 /* We still don't have the root file system mounted. */ 231 213 if ((size == 1) && (buf[0] == '/')) { 232 /* 233 * For this simple, but important case, we are done. 234 */ 214 /* For this simple, but important case, we are done. */ 235 215 rootfs = mr_res.triplet; 236 216 futex_up(&rootfs_futex); … … 348 328 rwlock_read_lock(&namespace_rwlock); 349 329 350 /* 351 * The path is now populated and we can call vfs_lookup_internal(). 352 */ 330 /* The path is now populated and we can call vfs_lookup_internal(). */ 353 331 vfs_lookup_res_t lr; 354 332 rc = vfs_lookup_internal(path, len, lflag, &lr, NULL); … … 360 338 } 361 339 362 /* 363 * Path is no longer needed. 364 */ 340 /** Path is no longer needed. */ 365 341 free(path); 366 342 … … 391 367 vfs_node_put(node); 392 368 393 /* 394 * Success! Return the new file descriptor to the client. 395 */ 369 /* Success! Return the new file descriptor to the client. */ 396 370 ipc_answer_1(rid, EOK, fd); 397 371 } … … 412 386 int fd = IPC_GET_ARG1(*request); 413 387 414 /* 415 * Lookup the file structure corresponding to the file descriptor. 416 */ 388 /* Lookup the file structure corresponding to the file descriptor. */ 417 389 vfs_file_t *file = vfs_file_get(fd); 418 390 if (!file) { … … 454 426 int fs_phone = vfs_grab_phone(file->node->fs_handle); 455 427 456 /* 457 * Make a VFS_READ/VFS_WRITE request at the destination FS server. 458 */ 428 /* Make a VFS_READ/VFS_WRITE request at the destination FS server. */ 459 429 aid_t msg; 460 430 ipc_call_t answer; … … 472 442 vfs_release_phone(fs_phone); 473 443 474 /* 475 * Wait for reply from the FS server. 476 */ 444 /* Wait for reply from the FS server. */ 477 445 ipcarg_t rc; 478 446 async_wait_for(msg, &rc); 479 447 size_t bytes = IPC_GET_ARG1(answer); 480 448 481 /* 482 * Unlock the VFS node. 483 */ 449 /* Unlock the VFS node. */ 484 450 if (read) 485 451 rwlock_read_unlock(&file->node->contents_rwlock); … … 490 456 } 491 457 492 /* 493 * Update the position pointer and unlock the open file. 494 */ 458 /* Update the position pointer and unlock the open file. */ 495 459 file->pos += bytes; 496 460 futex_up(&file->lock); … … 520 484 521 485 522 /* 523 * Lookup the file structure corresponding to the file descriptor. 524 */ 486 /* Lookup the file structure corresponding to the file descriptor. */ 525 487 vfs_file_t *file = vfs_file_get(fd); 526 488 if (!file) { … … 582 544 rwlock_write_lock(&file->node->contents_rwlock); 583 545 int fs_phone = vfs_grab_phone(file->node->fs_handle); 584 rc = async_req_3_0(fs_phone, VFS_TRUNCATE, (ipcarg_t)file->node->dev_handle, 585 (ipcarg_t)file->node->index, (ipcarg_t)size); 546 rc = async_req_3_0(fs_phone, VFS_TRUNCATE, 547 (ipcarg_t)file->node->dev_handle, (ipcarg_t)file->node->index, 548 (ipcarg_t)size); 586 549 vfs_release_phone(fs_phone); 587 550 if (rc == EOK) … … 593 556 } 594 557 558 void vfs_mkdir(ipc_callid_t rid, ipc_call_t *request) 559 { 560 int mode = IPC_GET_ARG1(*request); 561 size_t len; 562 563 ipc_callid_t callid; 564 565 if (!ipc_data_write_receive(&callid, &len)) { 566 ipc_answer_0(callid, EINVAL); 567 ipc_answer_0(rid, EINVAL); 568 return; 569 } 570 571 /* 572 * Now we are on the verge of accepting the path. 573 * 574 * There is one optimization we could do in the future: copy the path 575 * directly into the PLB using some kind of a callback. 576 */ 577 char *path = malloc(len); 578 579 if (!path) { 580 ipc_answer_0(callid, ENOMEM); 581 ipc_answer_0(rid, ENOMEM); 582 return; 583 } 584 585 int rc; 586 if ((rc = ipc_data_write_finalize(callid, path, len))) { 587 ipc_answer_0(rid, rc); 588 free(path); 589 return; 590 } 591 592 rwlock_write_lock(&namespace_rwlock); 593 int lflag = L_DIRECTORY | L_CREATE | L_EXCLUSIVE; 594 rc = vfs_lookup_internal(path, len, lflag, NULL, NULL); 595 rwlock_write_unlock(&namespace_rwlock); 596 free(path); 597 ipc_answer_0(rid, rc); 598 } 599 595 600 /** 596 601 * @}
Note:
See TracChangeset
for help on using the changeset viewer.