Changeset 27b76ca in mainline
- Timestamp:
- 2011-08-18T14:05:10Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 44451ee
- Parents:
- b33ec43
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/vfs/vfs.c
rb33ec43 r27b76ca 815 815 } 816 816 817 int fd_wait(void) 818 { 819 async_exch_t *exch = vfs_exchange_begin(); 820 821 sysarg_t ret; 822 sysarg_t rc = async_req_0_1(exch, VFS_IN_WAIT_HANDLE, &ret); 823 824 vfs_exchange_end(exch); 825 826 if (rc == EOK) 827 return (int) ret; 828 829 return (int) rc; 830 } 831 817 832 /** @} 818 833 */ -
uspace/lib/c/include/ipc/vfs.h
rb33ec43 r27b76ca 77 77 VFS_IN_RENAME, 78 78 VFS_IN_STAT, 79 VFS_IN_DUP 79 VFS_IN_DUP, 80 VFS_IN_WAIT_HANDLE, 80 81 } vfs_in_request_t; 81 82 -
uspace/lib/c/include/vfs/vfs.h
rb33ec43 r27b76ca 55 55 extern int fhandle(FILE *, int *); 56 56 57 extern int fd_wait(void); 58 57 59 extern async_exch_t *vfs_exchange_begin(void); 58 60 extern void vfs_exchange_end(async_exch_t *); -
uspace/srv/loader/main.c
rb33ec43 r27b76ca 242 242 for (filc = 0; filc < count; filc++) { 243 243 ipc_callid_t callid; 244 int fd; 244 245 245 246 if (!async_state_change_receive(&callid, NULL, NULL, NULL)) { … … 248 249 } 249 250 async_state_change_finalize(callid, vfs_exch); 251 fd = fd_wait(); 252 assert(fd == (int) filc); 250 253 } 251 254 -
uspace/srv/vfs/vfs.c
rb33ec43 r27b76ca 118 118 case VFS_IN_DUP: 119 119 vfs_dup(callid, &call); 120 break; 121 case VFS_IN_WAIT_HANDLE: 122 vfs_wait_handle(callid, &call); 123 break; 120 124 default: 121 125 async_answer_0(callid, ENOTSUP); -
uspace/srv/vfs/vfs.h
rb33ec43 r27b76ca 189 189 190 190 extern void vfs_pass_handle(sysarg_t, sysarg_t, int); 191 extern int vfs_wait_handle_internal(void); 191 192 192 193 extern vfs_file_t *vfs_file_get(int); … … 215 216 extern void vfs_unlink(ipc_callid_t, ipc_call_t *); 216 217 extern void vfs_rename(ipc_callid_t, ipc_call_t *); 218 extern void vfs_wait_handle(ipc_callid_t, ipc_call_t *); 217 219 218 220 #endif -
uspace/srv/vfs/vfs_file.c
rb33ec43 r27b76ca 43 43 #include <fibril.h> 44 44 #include <fibril_synch.h> 45 #include <adt/list.h> 45 46 #include "vfs.h" 46 47 … … 50 51 typedef struct { 51 52 fibril_mutex_t lock; 53 fibril_condvar_t cv; 54 list_t passed_handles; 52 55 vfs_file_t **files; 53 56 } vfs_client_data_t; 57 58 typedef struct { 59 link_t link; 60 int handle; 61 } vfs_boxed_handle_t; 54 62 55 63 static int _vfs_fd_free(vfs_client_data_t *, int); … … 85 93 86 94 free(vfs_data->files); 95 96 while (!list_empty(&vfs_data->passed_handles)) { 97 link_t *lnk; 98 vfs_boxed_handle_t *bh; 99 100 lnk = list_first(&vfs_data->passed_handles); 101 list_remove(lnk); 102 103 bh = list_get_instance(lnk, vfs_boxed_handle_t, link); 104 free(bh); 105 } 87 106 } 88 107 … … 94 113 if (vfs_data) { 95 114 fibril_mutex_initialize(&vfs_data->lock); 115 fibril_condvar_initialize(&vfs_data->cv); 116 list_initialize(&vfs_data->passed_handles); 96 117 vfs_data->files = NULL; 97 118 } … … 331 352 vfs_file_t *donor_file = NULL; 332 353 vfs_file_t *acceptor_file = NULL; 354 vfs_boxed_handle_t *bh; 333 355 int acceptor_fd; 356 357 acceptor_data = async_get_client_data_by_hash(acceptor_hash); 358 if (!acceptor_data) 359 return; 360 361 bh = malloc(sizeof(vfs_boxed_handle_t)); 362 assert(bh); 363 364 link_initialize(&bh->link); 365 bh->handle = -1; 334 366 335 367 donor_data = async_get_client_data_by_hash(donor_hash); 336 368 if (!donor_data) 337 return;338 acceptor_data = async_get_client_data_by_hash(acceptor_hash);339 if (!acceptor_data)340 369 goto out; 341 370 … … 347 376 if (acceptor_fd < 0) 348 377 goto out; 378 379 bh->handle = acceptor_fd; 349 380 350 381 /* … … 364 395 365 396 out: 397 fibril_mutex_lock(&acceptor_data->lock); 398 list_append(&bh->link, &acceptor_data->passed_handles); 399 fibril_condvar_broadcast(&acceptor_data->cv); 400 fibril_mutex_unlock(&acceptor_data->lock); 401 366 402 if (donor_data) 367 403 async_put_client_data_by_hash(donor_hash); … … 372 408 if (acceptor_file) 373 409 _vfs_file_put(acceptor_data, acceptor_file); 410 411 } 412 413 int vfs_wait_handle_internal(void) 414 { 415 vfs_client_data_t *vfs_data = VFS_DATA; 416 int fd; 417 418 fibril_mutex_lock(&vfs_data->lock); 419 while (list_empty(&vfs_data->passed_handles)) 420 fibril_condvar_wait(&vfs_data->cv, &vfs_data->lock); 421 link_t *lnk = list_first(&vfs_data->passed_handles); 422 list_remove(lnk); 423 fibril_mutex_unlock(&vfs_data->lock); 424 425 vfs_boxed_handle_t *bh = list_get_instance(lnk, vfs_boxed_handle_t, link); 426 fd = bh->handle; 427 free(bh); 428 429 return fd; 374 430 } 375 431 -
uspace/srv/vfs/vfs_ops.c
rb33ec43 r27b76ca 1276 1276 } 1277 1277 1278 void vfs_wait_handle(ipc_callid_t rid, ipc_call_t *request) 1279 { 1280 int fd = vfs_wait_handle_internal(); 1281 async_answer_1(rid, EOK, fd); 1282 } 1283 1278 1284 /** 1279 1285 * @}
Note:
See TracChangeset
for help on using the changeset viewer.