Changeset 2595dab in mainline for uspace/lib/libc/generic/vfs/vfs.c
- Timestamp:
- 2009-06-03T19:26:28Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d00ae4c
- Parents:
- ca3ba3a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/vfs/vfs.c
rca3ba3a r2595dab 50 50 #include <string.h> 51 51 #include <devmap.h> 52 #include "../../../srv/vfs/vfs.h" 53 54 int vfs_phone = -1; 55 futex_t vfs_phone_futex = FUTEX_INITIALIZER; 56 57 futex_t cwd_futex = FUTEX_INITIALIZER; 52 #include <ipc/vfs.h> 53 #include <ipc/devmap.h> 54 55 static int vfs_phone = -1; 56 static futex_t vfs_phone_futex = FUTEX_INITIALIZER; 57 static futex_t cwd_futex = FUTEX_INITIALIZER; 58 58 59 DIR *cwd_dir = NULL; 59 60 char *cwd_path = NULL; … … 211 212 futex_up(&vfs_phone_futex); 212 213 free(pa); 213 214 214 215 if (rc != EOK) 215 216 return (int) rc; 217 216 218 return (int) IPC_GET_ARG1(answer); 217 219 } … … 220 222 { 221 223 return _open(path, L_FILE, oflag); 224 } 225 226 int open_node(fs_node_t *node, int oflag) 227 { 228 futex_down(&vfs_phone_futex); 229 async_serialize_start(); 230 vfs_connect(); 231 232 ipc_call_t answer; 233 aid_t req = async_send_4(vfs_phone, VFS_OPEN_NODE, node->fs_handle, 234 node->dev_handle, node->index, oflag, &answer); 235 236 ipcarg_t rc; 237 async_wait_for(req, &rc); 238 async_serialize_end(); 239 futex_up(&vfs_phone_futex); 240 241 if (rc != EOK) 242 return (int) rc; 243 244 return (int) IPC_GET_ARG1(answer); 222 245 } 223 246 … … 290 313 else 291 314 return -1; 315 } 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_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 void fd_node(int fildes, fs_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_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 } else { 355 node->fs_handle = 0; 356 node->dev_handle = 0; 357 node->index = 0; 358 } 359 } 360 361 int fsync(int fildes) 362 { 363 futex_down(&vfs_phone_futex); 364 async_serialize_start(); 365 vfs_connect(); 366 367 ipcarg_t rc = async_req_1_0(vfs_phone, VFS_SYNC, fildes); 368 369 async_serialize_end(); 370 futex_up(&vfs_phone_futex); 371 372 return (int) rc; 292 373 } 293 374 … … 387 468 futex_up(&vfs_phone_futex); 388 469 free(pa); 389 return rc; 470 return rc; 390 471 } 391 472 … … 417 498 futex_up(&vfs_phone_futex); 418 499 free(pa); 419 return rc; 500 return rc; 420 501 } 421 502
Note:
See TracChangeset
for help on using the changeset viewer.