Changeset 852b801 in mainline for uspace/lib/libc
- Timestamp:
- 2009-06-28T18:59:02Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 75160a6
- Parents:
- 4198f9c3
- Location:
- uspace/lib/libc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/vfs/vfs.c
r4198f9c3 r852b801 39 39 #include <dirent.h> 40 40 #include <fcntl.h> 41 #include <stdio.h> 41 42 #include <sys/stat.h> 42 #include <stdio.h>43 43 #include <sys/types.h> 44 44 #include <ipc/ipc.h> … … 315 315 } 316 316 317 int fd_phone(int fildes)318 {319 futex_down(&vfs_phone_futex);320 async_serialize_start();321 vfs_connect();322 323 ipcarg_t device;324 ipcarg_t rc = async_req_1_1(vfs_phone, VFS_IN_DEVICE, fildes, &device);325 326 async_serialize_end();327 futex_up(&vfs_phone_futex);328 329 if (rc != EOK)330 return -1;331 332 return devmap_device_connect((dev_handle_t) device, 0);333 }334 335 int fd_node(int fildes, fdi_node_t *node)336 {337 futex_down(&vfs_phone_futex);338 async_serialize_start();339 vfs_connect();340 341 ipcarg_t fs_handle;342 ipcarg_t dev_handle;343 ipcarg_t index;344 ipcarg_t rc = async_req_1_3(vfs_phone, VFS_IN_NODE, fildes, &fs_handle,345 &dev_handle, &index);346 347 async_serialize_end();348 futex_up(&vfs_phone_futex);349 350 if (rc == EOK) {351 node->fs_handle = (fs_handle_t) fs_handle;352 node->dev_handle = (dev_handle_t) dev_handle;353 node->index = (fs_index_t) index;354 }355 356 return rc;357 }358 359 317 int fsync(int fildes) 360 318 { … … 404 362 futex_up(&vfs_phone_futex); 405 363 return (int) rc; 364 } 365 366 int fstat(int fildes, struct stat *stat) 367 { 368 ipcarg_t rc; 369 ipc_call_t answer; 370 aid_t req; 371 372 futex_down(&vfs_phone_futex); 373 async_serialize_start(); 374 vfs_connect(); 375 376 req = async_send_1(vfs_phone, VFS_IN_FSTAT, fildes, NULL); 377 rc = ipc_data_read_start(vfs_phone, (void *)stat, sizeof(struct stat)); 378 if (rc != EOK) { 379 async_wait_for(req, NULL); 380 async_serialize_end(); 381 futex_up(&vfs_phone_futex); 382 return (ssize_t) rc; 383 } 384 async_wait_for(req, &rc); 385 async_serialize_end(); 386 futex_up(&vfs_phone_futex); 387 388 return rc; 406 389 } 407 390 … … 599 582 } 600 583 584 int fd_phone(int fildes) 585 { 586 struct stat stat; 587 int rc; 588 589 rc = fstat(fildes, &stat); 590 591 if (!stat.devfs_stat.device) 592 return -1; 593 594 return devmap_device_connect(stat.devfs_stat.device, 0); 595 } 596 597 int fd_node(int fildes, fdi_node_t *node) 598 { 599 struct stat stat; 600 int rc; 601 602 rc = fstat(fildes, &stat); 603 604 if (rc == EOK) { 605 node->fs_handle = stat.fs_handle; 606 node->dev_handle = stat.dev_handle; 607 node->index = stat.index; 608 } 609 610 return rc; 611 } 612 601 613 /** @} 602 614 */ -
uspace/lib/libc/include/ipc/vfs.h
r4198f9c3 r852b801 64 64 VFS_IN_SEEK, 65 65 VFS_IN_TRUNCATE, 66 VFS_IN_FSTAT, 66 67 VFS_IN_CLOSE, 67 68 VFS_IN_MOUNT, … … 73 74 VFS_IN_UNLINK, 74 75 VFS_IN_RENAME, 76 VFS_IN_STAT, 75 77 VFS_IN_NODE 76 78 } vfs_in_request_t; … … 87 89 VFS_OUT_DEVICE, 88 90 VFS_OUT_SYNC, 91 VFS_OUT_STAT, 89 92 VFS_OUT_LOOKUP, 90 93 VFS_OUT_DESTROY, -
uspace/lib/libc/include/sys/stat.h
r4198f9c3 r852b801 37 37 38 38 #include <sys/types.h> 39 #include <bool.h> 40 #include <ipc/vfs.h> 41 #include <ipc/devmap.h> 39 42 43 struct stat { 44 fs_handle_t fs_handle; 45 dev_handle_t dev_handle; 46 fs_index_t index; 47 unsigned lnkcnt; 48 bool is_file; 49 off_t size; 50 union { 51 struct { 52 dev_handle_t device; 53 } devfs_stat; 54 }; 55 }; 56 57 extern int fstat(int, struct stat *); 40 58 extern int mkdir(const char *, mode_t); 41 59
Note:
See TracChangeset
for help on using the changeset viewer.