=== modified file 'kernel/generic/include/ipc/ipc.h'
|
|
|
43 | 43 | #define IPC_CALL_LEN 6 |
44 | 44 | |
45 | 45 | /** Maximum active async calls per phone */ |
46 | | #define IPC_MAX_ASYNC_CALLS 4 |
| 46 | #define IPC_MAX_ASYNC_CALLS 10 |
47 | 47 | |
48 | 48 | /* Flags for calls */ |
49 | 49 | |
=== modified file 'kernel/generic/src/ipc/ipc.c'
|
|
|
705 | 705 | printf("connecting "); |
706 | 706 | break; |
707 | 707 | case IPC_PHONE_CONNECTED: |
708 | | printf("connected to: %p ", |
709 | | task->phones[i].callee); |
| 708 | printf("connected to: %p (%" PRIu64 ") ", |
| 709 | task->phones[i].callee, |
| 710 | task->phones[i].callee->task->taskid); |
710 | 711 | break; |
711 | 712 | case IPC_PHONE_SLAMMED: |
712 | 713 | printf("slammed by: %p ", |
=== modified file 'uspace/lib/c/generic/io/vprintf.c'
|
|
|
36 | 36 | #include <stdio.h> |
37 | 37 | #include <unistd.h> |
38 | 38 | #include <io/printf_core.h> |
39 | | #include <futex.h> |
| 39 | #include <fibril_synch.h> |
40 | 40 | #include <async.h> |
41 | 41 | #include <str.h> |
42 | 42 | |
43 | | static atomic_t printf_futex = FUTEX_INITIALIZER; |
| 43 | static FIBRIL_MUTEX_INITIALIZE(printf_mutex); |
44 | 44 | |
45 | 45 | static int vprintf_str_write(const char *str, size_t size, void *stream) |
46 | 46 | { |
… |
… |
|
84 | 84 | /* |
85 | 85 | * Prevent other threads to execute printf_core() |
86 | 86 | */ |
87 | | futex_down(&printf_futex); |
88 | | |
89 | | /* |
90 | | * Prevent other fibrils of the same thread |
91 | | * to execute printf_core() |
92 | | */ |
93 | | async_serialize_start(); |
| 87 | fibril_mutex_lock(&printf_mutex); |
94 | 88 | |
95 | 89 | int ret = printf_core(fmt, &ps, ap); |
96 | 90 | |
97 | | async_serialize_end(); |
98 | | futex_up(&printf_futex); |
| 91 | fibril_mutex_unlock(&printf_mutex); |
99 | 92 | |
100 | 93 | return ret; |
101 | 94 | } |
=== modified file 'uspace/lib/c/generic/loader.c'
|
|
|
62 | 62 | |
63 | 63 | loader_t *loader_connect(void) |
64 | 64 | { |
65 | | int phone_id = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_LOAD, 0, 0); |
| 65 | int phone_id = async_connect_me_to_blocking(PHONE_NS, SERVICE_LOAD, 0, 0); |
66 | 66 | if (phone_id < 0) |
67 | 67 | return NULL; |
68 | 68 | |
=== modified file 'uspace/lib/c/generic/vfs/vfs.c'
|
|
|
45 | 45 | #include <ipc/ipc.h> |
46 | 46 | #include <ipc/services.h> |
47 | 47 | #include <async.h> |
48 | | #include <atomic.h> |
49 | | #include <futex.h> |
| 48 | #include <fibril_synch.h> |
50 | 49 | #include <errno.h> |
51 | 50 | #include <str.h> |
52 | 51 | #include <devmap.h> |
53 | 52 | #include <ipc/vfs.h> |
54 | 53 | #include <ipc/devmap.h> |
| 54 | #include <assert.h> |
55 | 55 | |
56 | 56 | static int vfs_phone = -1; |
57 | | static futex_t vfs_phone_futex = FUTEX_INITIALIZER; |
58 | | static futex_t cwd_futex = FUTEX_INITIALIZER; |
| 57 | static FIBRIL_MUTEX_INITIALIZE(vfs_phone_mutex); |
| 58 | static FIBRIL_MUTEX_INITIALIZE(cwd_mutex); |
59 | 59 | |
60 | 60 | static int cwd_fd = -1; |
61 | 61 | static char *cwd_path = NULL; |
62 | 62 | static size_t cwd_size = 0; |
63 | 63 | |
| 64 | static void vfs_serialize_start(void) |
| 65 | { |
| 66 | fibril_mutex_lock(&vfs_phone_mutex); |
| 67 | } |
| 68 | |
| 69 | static void vfs_serialize_end(void) |
| 70 | { |
| 71 | assert(fibril_mutex_is_locked(&vfs_phone_mutex)); |
| 72 | fibril_mutex_unlock(&vfs_phone_mutex); |
| 73 | } |
| 74 | |
64 | 75 | char *absolutize(const char *path, size_t *retlen) |
65 | 76 | { |
66 | 77 | char *ncwd_path; |
67 | 78 | char *ncwd_path_nc; |
68 | 79 | |
69 | | futex_down(&cwd_futex); |
| 80 | fibril_mutex_lock(&cwd_mutex); |
70 | 81 | size_t size = str_size(path); |
71 | 82 | if (*path != '/') { |
72 | 83 | if (!cwd_path) { |
73 | | futex_up(&cwd_futex); |
| 84 | fibril_mutex_unlock(&cwd_mutex); |
74 | 85 | return NULL; |
75 | 86 | } |
76 | 87 | ncwd_path_nc = malloc(cwd_size + 1 + size + 1); |
77 | 88 | if (!ncwd_path_nc) { |
78 | | futex_up(&cwd_futex); |
| 89 | fibril_mutex_unlock(&cwd_mutex); |
79 | 90 | return NULL; |
80 | 91 | } |
81 | 92 | str_cpy(ncwd_path_nc, cwd_size + 1 + size + 1, cwd_path); |
… |
… |
|
84 | 95 | } else { |
85 | 96 | ncwd_path_nc = malloc(size + 1); |
86 | 97 | if (!ncwd_path_nc) { |
87 | | futex_up(&cwd_futex); |
| 98 | fibril_mutex_unlock(&cwd_mutex); |
88 | 99 | return NULL; |
89 | 100 | } |
90 | 101 | ncwd_path_nc[0] = '\0'; |
… |
… |
|
92 | 103 | str_append(ncwd_path_nc, cwd_size + 1 + size + 1, path); |
93 | 104 | ncwd_path = canonify(ncwd_path_nc, retlen); |
94 | 105 | if (!ncwd_path) { |
95 | | futex_up(&cwd_futex); |
| 106 | fibril_mutex_unlock(&cwd_mutex); |
96 | 107 | free(ncwd_path_nc); |
97 | 108 | return NULL; |
98 | 109 | } |
… |
… |
|
104 | 115 | ncwd_path = str_dup(ncwd_path); |
105 | 116 | free(ncwd_path_nc); |
106 | 117 | if (!ncwd_path) { |
107 | | futex_up(&cwd_futex); |
| 118 | fibril_mutex_unlock(&cwd_mutex); |
108 | 119 | return NULL; |
109 | 120 | } |
110 | | futex_up(&cwd_futex); |
| 121 | fibril_mutex_unlock(&cwd_mutex); |
111 | 122 | return ncwd_path; |
112 | 123 | } |
113 | 124 | |
114 | 125 | static void vfs_connect(void) |
115 | 126 | { |
| 127 | assert(fibril_mutex_is_locked(&vfs_phone_mutex)); |
116 | 128 | while (vfs_phone < 0) |
117 | 129 | vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0); |
118 | 130 | } |
… |
… |
|
153 | 165 | return ENOMEM; |
154 | 166 | } |
155 | 167 | |
156 | | futex_down(&vfs_phone_futex); |
157 | | async_serialize_start(); |
| 168 | vfs_serialize_start(); |
158 | 169 | vfs_connect(); |
159 | 170 | |
160 | 171 | sysarg_t rc_orig; |
… |
… |
|
162 | 173 | sysarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); |
163 | 174 | if (rc != EOK) { |
164 | 175 | async_wait_for(req, &rc_orig); |
165 | | async_serialize_end(); |
166 | | futex_up(&vfs_phone_futex); |
| 176 | vfs_serialize_end(); |
167 | 177 | free(mpa); |
168 | 178 | |
169 | 179 | if (null_id != -1) |
… |
… |
|
178 | 188 | rc = async_data_write_start(vfs_phone, (void *) opts, str_size(opts)); |
179 | 189 | if (rc != EOK) { |
180 | 190 | async_wait_for(req, &rc_orig); |
181 | | async_serialize_end(); |
182 | | futex_up(&vfs_phone_futex); |
| 191 | vfs_serialize_end(); |
183 | 192 | free(mpa); |
184 | 193 | |
185 | 194 | if (null_id != -1) |
… |
… |
|
194 | 203 | rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); |
195 | 204 | if (rc != EOK) { |
196 | 205 | async_wait_for(req, &rc_orig); |
197 | | async_serialize_end(); |
198 | | futex_up(&vfs_phone_futex); |
| 206 | vfs_serialize_end(); |
199 | 207 | free(mpa); |
200 | 208 | |
201 | 209 | if (null_id != -1) |
… |
… |
|
211 | 219 | rc = async_req_0_0(vfs_phone, IPC_M_PING); |
212 | 220 | if (rc != EOK) { |
213 | 221 | async_wait_for(req, &rc_orig); |
214 | | async_serialize_end(); |
215 | | futex_up(&vfs_phone_futex); |
| 222 | vfs_serialize_end(); |
216 | 223 | free(mpa); |
217 | 224 | |
218 | 225 | if (null_id != -1) |
… |
… |
|
225 | 232 | } |
226 | 233 | |
227 | 234 | async_wait_for(req, &rc); |
228 | | async_serialize_end(); |
229 | | futex_up(&vfs_phone_futex); |
| 235 | vfs_serialize_end(); |
230 | 236 | free(mpa); |
231 | 237 | |
232 | 238 | if ((rc != EOK) && (null_id != -1)) |
… |
… |
|
247 | 253 | if (!mpa) |
248 | 254 | return ENOMEM; |
249 | 255 | |
250 | | futex_down(&vfs_phone_futex); |
251 | | async_serialize_start(); |
| 256 | vfs_serialize_start(); |
252 | 257 | vfs_connect(); |
253 | 258 | |
254 | 259 | req = async_send_0(vfs_phone, VFS_IN_UNMOUNT, NULL); |
255 | 260 | rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); |
256 | 261 | if (rc != EOK) { |
257 | 262 | async_wait_for(req, &rc_orig); |
258 | | async_serialize_end(); |
259 | | futex_up(&vfs_phone_futex); |
| 263 | vfs_serialize_end(); |
260 | 264 | free(mpa); |
261 | 265 | if (rc_orig == EOK) |
262 | 266 | return (int) rc; |
… |
… |
|
266 | 270 | |
267 | 271 | |
268 | 272 | async_wait_for(req, &rc); |
269 | | async_serialize_end(); |
270 | | futex_up(&vfs_phone_futex); |
| 273 | vfs_serialize_end(); |
271 | 274 | free(mpa); |
272 | 275 | |
273 | 276 | return (int) rc; |
… |
… |
|
275 | 278 | |
276 | 279 | static int open_internal(const char *abs, size_t abs_size, int lflag, int oflag) |
277 | 280 | { |
278 | | futex_down(&vfs_phone_futex); |
279 | | async_serialize_start(); |
| 281 | vfs_serialize_start(); |
280 | 282 | vfs_connect(); |
281 | 283 | |
282 | 284 | ipc_call_t answer; |
… |
… |
|
287 | 289 | sysarg_t rc_orig; |
288 | 290 | async_wait_for(req, &rc_orig); |
289 | 291 | |
290 | | async_serialize_end(); |
291 | | futex_up(&vfs_phone_futex); |
| 292 | vfs_serialize_end(); |
292 | 293 | |
293 | 294 | if (rc_orig == EOK) |
294 | 295 | return (int) rc; |
… |
… |
|
297 | 298 | } |
298 | 299 | |
299 | 300 | async_wait_for(req, &rc); |
300 | | async_serialize_end(); |
301 | | futex_up(&vfs_phone_futex); |
| 301 | vfs_serialize_end(); |
302 | 302 | |
303 | 303 | if (rc != EOK) |
304 | 304 | return (int) rc; |
… |
… |
|
321 | 321 | |
322 | 322 | int open_node(fdi_node_t *node, int oflag) |
323 | 323 | { |
324 | | futex_down(&vfs_phone_futex); |
325 | | async_serialize_start(); |
| 324 | vfs_serialize_start(); |
326 | 325 | vfs_connect(); |
327 | 326 | |
328 | 327 | ipc_call_t answer; |
… |
… |
|
331 | 330 | |
332 | 331 | sysarg_t rc; |
333 | 332 | async_wait_for(req, &rc); |
334 | | async_serialize_end(); |
335 | | futex_up(&vfs_phone_futex); |
| 333 | vfs_serialize_end(); |
336 | 334 | |
337 | 335 | if (rc != EOK) |
338 | 336 | return (int) rc; |
… |
… |
|
344 | 342 | { |
345 | 343 | sysarg_t rc; |
346 | 344 | |
347 | | futex_down(&vfs_phone_futex); |
348 | | async_serialize_start(); |
| 345 | vfs_serialize_start(); |
349 | 346 | vfs_connect(); |
350 | 347 | |
351 | 348 | rc = async_req_1_0(vfs_phone, VFS_IN_CLOSE, fildes); |
352 | 349 | |
353 | | async_serialize_end(); |
354 | | futex_up(&vfs_phone_futex); |
| 350 | vfs_serialize_end(); |
355 | 351 | |
356 | 352 | return (int)rc; |
357 | 353 | } |
… |
… |
|
362 | 358 | ipc_call_t answer; |
363 | 359 | aid_t req; |
364 | 360 | |
365 | | futex_down(&vfs_phone_futex); |
366 | | async_serialize_start(); |
| 361 | vfs_serialize_start(); |
367 | 362 | vfs_connect(); |
368 | 363 | |
369 | 364 | req = async_send_1(vfs_phone, VFS_IN_READ, fildes, &answer); |
… |
… |
|
372 | 367 | sysarg_t rc_orig; |
373 | 368 | |
374 | 369 | async_wait_for(req, &rc_orig); |
375 | | async_serialize_end(); |
376 | | futex_up(&vfs_phone_futex); |
| 370 | vfs_serialize_end(); |
377 | 371 | if (rc_orig == EOK) |
378 | 372 | return (ssize_t) rc; |
379 | 373 | else |
380 | 374 | return (ssize_t) rc_orig; |
381 | 375 | } |
382 | 376 | async_wait_for(req, &rc); |
383 | | async_serialize_end(); |
384 | | futex_up(&vfs_phone_futex); |
| 377 | vfs_serialize_end(); |
385 | 378 | if (rc == EOK) |
386 | 379 | return (ssize_t) IPC_GET_ARG1(answer); |
387 | 380 | else |
… |
… |
|
394 | 387 | ipc_call_t answer; |
395 | 388 | aid_t req; |
396 | 389 | |
397 | | futex_down(&vfs_phone_futex); |
398 | | async_serialize_start(); |
| 390 | vfs_serialize_start(); |
399 | 391 | vfs_connect(); |
400 | 392 | |
401 | 393 | req = async_send_1(vfs_phone, VFS_IN_WRITE, fildes, &answer); |
… |
… |
|
404 | 396 | sysarg_t rc_orig; |
405 | 397 | |
406 | 398 | async_wait_for(req, &rc_orig); |
407 | | async_serialize_end(); |
408 | | futex_up(&vfs_phone_futex); |
| 399 | vfs_serialize_end(); |
409 | 400 | if (rc_orig == EOK) |
410 | 401 | return (ssize_t) rc; |
411 | 402 | else |
412 | 403 | return (ssize_t) rc_orig; |
413 | 404 | } |
414 | 405 | async_wait_for(req, &rc); |
415 | | async_serialize_end(); |
416 | | futex_up(&vfs_phone_futex); |
| 406 | vfs_serialize_end(); |
417 | 407 | if (rc == EOK) |
418 | 408 | return (ssize_t) IPC_GET_ARG1(answer); |
419 | 409 | else |
… |
… |
|
422 | 412 | |
423 | 413 | int fsync(int fildes) |
424 | 414 | { |
425 | | futex_down(&vfs_phone_futex); |
426 | | async_serialize_start(); |
| 415 | vfs_serialize_start(); |
427 | 416 | vfs_connect(); |
428 | 417 | |
429 | 418 | sysarg_t rc = async_req_1_0(vfs_phone, VFS_IN_SYNC, fildes); |
430 | 419 | |
431 | | async_serialize_end(); |
432 | | futex_up(&vfs_phone_futex); |
| 420 | vfs_serialize_end(); |
433 | 421 | |
434 | 422 | return (int) rc; |
435 | 423 | } |
436 | 424 | |
437 | 425 | off64_t lseek(int fildes, off64_t offset, int whence) |
438 | 426 | { |
439 | | futex_down(&vfs_phone_futex); |
440 | | async_serialize_start(); |
| 427 | vfs_serialize_start(); |
441 | 428 | vfs_connect(); |
442 | 429 | |
443 | 430 | sysarg_t newoff_lo; |
… |
… |
|
446 | 433 | LOWER32(offset), UPPER32(offset), whence, |
447 | 434 | &newoff_lo, &newoff_hi); |
448 | 435 | |
449 | | async_serialize_end(); |
450 | | futex_up(&vfs_phone_futex); |
| 436 | vfs_serialize_end(); |
451 | 437 | |
452 | 438 | if (rc != EOK) |
453 | 439 | return (off64_t) -1; |
… |
… |
|
459 | 445 | { |
460 | 446 | sysarg_t rc; |
461 | 447 | |
462 | | futex_down(&vfs_phone_futex); |
463 | | async_serialize_start(); |
| 448 | vfs_serialize_start(); |
464 | 449 | vfs_connect(); |
465 | 450 | |
466 | 451 | rc = async_req_3_0(vfs_phone, VFS_IN_TRUNCATE, fildes, |
467 | 452 | LOWER32(length), UPPER32(length)); |
468 | | async_serialize_end(); |
469 | | futex_up(&vfs_phone_futex); |
| 453 | vfs_serialize_end(); |
470 | 454 | |
471 | 455 | return (int) rc; |
472 | 456 | } |
… |
… |
|
476 | 460 | sysarg_t rc; |
477 | 461 | aid_t req; |
478 | 462 | |
479 | | futex_down(&vfs_phone_futex); |
480 | | async_serialize_start(); |
| 463 | vfs_serialize_start(); |
481 | 464 | vfs_connect(); |
482 | 465 | |
483 | 466 | req = async_send_1(vfs_phone, VFS_IN_FSTAT, fildes, NULL); |
… |
… |
|
486 | 469 | sysarg_t rc_orig; |
487 | 470 | |
488 | 471 | async_wait_for(req, &rc_orig); |
489 | | async_serialize_end(); |
490 | | futex_up(&vfs_phone_futex); |
| 472 | vfs_serialize_end(); |
491 | 473 | if (rc_orig == EOK) |
492 | 474 | return (ssize_t) rc; |
493 | 475 | else |
494 | 476 | return (ssize_t) rc_orig; |
495 | 477 | } |
496 | 478 | async_wait_for(req, &rc); |
497 | | async_serialize_end(); |
498 | | futex_up(&vfs_phone_futex); |
| 479 | vfs_serialize_end(); |
499 | 480 | |
500 | 481 | return rc; |
501 | 482 | } |
… |
… |
|
511 | 492 | if (!pa) |
512 | 493 | return ENOMEM; |
513 | 494 | |
514 | | futex_down(&vfs_phone_futex); |
515 | | async_serialize_start(); |
| 495 | vfs_serialize_start(); |
516 | 496 | vfs_connect(); |
517 | 497 | |
518 | 498 | req = async_send_0(vfs_phone, VFS_IN_STAT, NULL); |
519 | 499 | rc = async_data_write_start(vfs_phone, pa, pa_size); |
520 | 500 | if (rc != EOK) { |
521 | 501 | async_wait_for(req, &rc_orig); |
522 | | async_serialize_end(); |
523 | | futex_up(&vfs_phone_futex); |
| 502 | vfs_serialize_end(); |
524 | 503 | free(pa); |
525 | 504 | if (rc_orig == EOK) |
526 | 505 | return (int) rc; |
… |
… |
|
530 | 509 | rc = async_data_read_start(vfs_phone, stat, sizeof(struct stat)); |
531 | 510 | if (rc != EOK) { |
532 | 511 | async_wait_for(req, &rc_orig); |
533 | | async_serialize_end(); |
534 | | futex_up(&vfs_phone_futex); |
| 512 | vfs_serialize_end(); |
535 | 513 | free(pa); |
536 | 514 | if (rc_orig == EOK) |
537 | 515 | return (int) rc; |
… |
… |
|
539 | 517 | return (int) rc_orig; |
540 | 518 | } |
541 | 519 | async_wait_for(req, &rc); |
542 | | async_serialize_end(); |
543 | | futex_up(&vfs_phone_futex); |
| 520 | vfs_serialize_end(); |
544 | 521 | free(pa); |
545 | 522 | return rc; |
546 | 523 | } |
… |
… |
|
600 | 577 | if (!pa) |
601 | 578 | return ENOMEM; |
602 | 579 | |
603 | | futex_down(&vfs_phone_futex); |
604 | | async_serialize_start(); |
| 580 | vfs_serialize_start(); |
605 | 581 | vfs_connect(); |
606 | 582 | |
607 | 583 | req = async_send_1(vfs_phone, VFS_IN_MKDIR, mode, NULL); |
… |
… |
|
610 | 586 | sysarg_t rc_orig; |
611 | 587 | |
612 | 588 | async_wait_for(req, &rc_orig); |
613 | | async_serialize_end(); |
614 | | futex_up(&vfs_phone_futex); |
| 589 | vfs_serialize_end(); |
615 | 590 | free(pa); |
616 | 591 | if (rc_orig == EOK) |
617 | 592 | return (int) rc; |
… |
… |
|
619 | 594 | return (int) rc_orig; |
620 | 595 | } |
621 | 596 | async_wait_for(req, &rc); |
622 | | async_serialize_end(); |
623 | | futex_up(&vfs_phone_futex); |
| 597 | vfs_serialize_end(); |
624 | 598 | free(pa); |
625 | 599 | return rc; |
626 | 600 | } |
… |
… |
|
635 | 609 | if (!pa) |
636 | 610 | return ENOMEM; |
637 | 611 | |
638 | | futex_down(&vfs_phone_futex); |
639 | | async_serialize_start(); |
| 612 | vfs_serialize_start(); |
640 | 613 | vfs_connect(); |
641 | 614 | |
642 | 615 | req = async_send_0(vfs_phone, VFS_IN_UNLINK, NULL); |
… |
… |
|
645 | 618 | sysarg_t rc_orig; |
646 | 619 | |
647 | 620 | async_wait_for(req, &rc_orig); |
648 | | async_serialize_end(); |
649 | | futex_up(&vfs_phone_futex); |
| 621 | vfs_serialize_end(); |
650 | 622 | free(pa); |
651 | 623 | if (rc_orig == EOK) |
652 | 624 | return (int) rc; |
… |
… |
|
654 | 626 | return (int) rc_orig; |
655 | 627 | } |
656 | 628 | async_wait_for(req, &rc); |
657 | | async_serialize_end(); |
658 | | futex_up(&vfs_phone_futex); |
| 629 | vfs_serialize_end(); |
659 | 630 | free(pa); |
660 | 631 | return rc; |
661 | 632 | } |
… |
… |
|
688 | 659 | return ENOMEM; |
689 | 660 | } |
690 | 661 | |
691 | | futex_down(&vfs_phone_futex); |
692 | | async_serialize_start(); |
| 662 | vfs_serialize_start(); |
693 | 663 | vfs_connect(); |
694 | 664 | |
695 | 665 | req = async_send_0(vfs_phone, VFS_IN_RENAME, NULL); |
696 | 666 | rc = async_data_write_start(vfs_phone, olda, olda_size); |
697 | 667 | if (rc != EOK) { |
698 | 668 | async_wait_for(req, &rc_orig); |
699 | | async_serialize_end(); |
700 | | futex_up(&vfs_phone_futex); |
| 669 | vfs_serialize_end(); |
701 | 670 | free(olda); |
702 | 671 | free(newa); |
703 | 672 | if (rc_orig == EOK) |
… |
… |
|
708 | 677 | rc = async_data_write_start(vfs_phone, newa, newa_size); |
709 | 678 | if (rc != EOK) { |
710 | 679 | async_wait_for(req, &rc_orig); |
711 | | async_serialize_end(); |
712 | | futex_up(&vfs_phone_futex); |
| 680 | vfs_serialize_end(); |
713 | 681 | free(olda); |
714 | 682 | free(newa); |
715 | 683 | if (rc_orig == EOK) |
… |
… |
|
718 | 686 | return (int) rc_orig; |
719 | 687 | } |
720 | 688 | async_wait_for(req, &rc); |
721 | | async_serialize_end(); |
722 | | futex_up(&vfs_phone_futex); |
| 689 | vfs_serialize_end(); |
723 | 690 | free(olda); |
724 | 691 | free(newa); |
725 | 692 | return rc; |
… |
… |
|
739 | 706 | return ENOENT; |
740 | 707 | } |
741 | 708 | |
742 | | futex_down(&cwd_futex); |
| 709 | fibril_mutex_lock(&cwd_mutex); |
743 | 710 | |
744 | 711 | if (cwd_fd >= 0) |
745 | 712 | close(cwd_fd); |
… |
… |
|
752 | 719 | cwd_path = abs; |
753 | 720 | cwd_size = abs_size; |
754 | 721 | |
755 | | futex_up(&cwd_futex); |
| 722 | fibril_mutex_unlock(&cwd_mutex); |
756 | 723 | return EOK; |
757 | 724 | } |
758 | 725 | |
… |
… |
|
761 | 728 | if (size == 0) |
762 | 729 | return NULL; |
763 | 730 | |
764 | | futex_down(&cwd_futex); |
| 731 | fibril_mutex_lock(&cwd_mutex); |
765 | 732 | |
766 | 733 | if ((cwd_size == 0) || (size < cwd_size + 1)) { |
767 | | futex_up(&cwd_futex); |
| 734 | fibril_mutex_unlock(&cwd_mutex); |
768 | 735 | return NULL; |
769 | 736 | } |
770 | 737 | |
771 | 738 | str_cpy(buf, size, cwd_path); |
772 | | futex_up(&cwd_futex); |
| 739 | fibril_mutex_unlock(&cwd_mutex); |
773 | 740 | |
774 | 741 | return buf; |
775 | 742 | } |
… |
… |
|
805 | 772 | |
806 | 773 | int dup2(int oldfd, int newfd) |
807 | 774 | { |
808 | | futex_down(&vfs_phone_futex); |
809 | | async_serialize_start(); |
| 775 | vfs_serialize_start(); |
810 | 776 | vfs_connect(); |
811 | 777 | |
812 | 778 | sysarg_t ret; |
813 | 779 | sysarg_t rc = async_req_2_1(vfs_phone, VFS_IN_DUP, oldfd, newfd, &ret); |
814 | 780 | |
815 | | async_serialize_end(); |
816 | | futex_up(&vfs_phone_futex); |
| 781 | vfs_serialize_end(); |
817 | 782 | |
818 | 783 | if (rc == EOK) |
819 | 784 | return (int) ret; |
=== modified file 'uspace/srv/devman/devman.c'
|
|
|
784 | 784 | if (is_running) { |
785 | 785 | /* Notify the driver about the new device. */ |
786 | 786 | int phone = async_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0); |
787 | | if (phone > 0) { |
| 787 | if (phone >= 0) { |
788 | 788 | add_device(phone, drv, node, tree); |
789 | 789 | ipc_hangup(phone); |
790 | 790 | } |