Changes in uspace/srv/system/system.c [77a0119:ad9e225] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/system/system.c
r77a0119 rad9e225 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2005 Martin Decky 4 4 * All rights reserved. … … 35 35 */ 36 36 37 #include <devman.h>38 37 #include <fibril.h> 39 38 #include <futil.h> … … 49 48 #include <str.h> 50 49 #include <loc.h> 51 #include <shutdown.h>52 50 #include <str_error.h> 53 51 #include <config.h> … … 86 84 87 85 static void system_srv_conn(ipc_call_t *, void *); 88 static errno_t system_srv_poweroff(void *); 89 static errno_t system_srv_restart(void *); 86 static errno_t system_srv_shutdown(void *); 90 87 91 88 system_ops_t system_srv_ops = { 92 .poweroff = system_srv_poweroff, 93 .restart = system_srv_restart 89 .shutdown = system_srv_shutdown 94 90 }; 95 91 … … 386 382 printf("%s: System volume is configured.\n", NAME); 387 383 388 /* Verify thatsystem volume is mounted */384 /* Wait until system volume is mounted */ 389 385 sv_mounted = false; 390 386 391 rc = vol_get_parts(vol, &part_ids, &nparts); 392 if (rc != EOK) { 393 printf("Error getting list of volumes.\n"); 394 goto error; 395 } 396 397 for (i = 0; i < nparts; i++) { 398 rc = vol_part_info(vol, part_ids[i], &pinfo); 387 while (true) { 388 rc = vol_get_parts(vol, &part_ids, &nparts); 399 389 if (rc != EOK) { 400 printf("Error getting partition " 401 "information.\n"); 402 rc = EIO; 390 printf("Error getting list of volumes.\n"); 403 391 goto error; 404 392 } 405 393 406 if (str_cmp(pinfo.cur_mp, "/w") == 0) { 407 sv_mounted = true; 394 for (i = 0; i < nparts; i++) { 395 rc = vol_part_info(vol, part_ids[i], &pinfo); 396 if (rc != EOK) { 397 printf("Error getting partition " 398 "information.\n"); 399 rc = EIO; 400 goto error; 401 } 402 403 if (str_cmp(pinfo.cur_mp, "/w") == 0) { 404 sv_mounted = true; 405 break; 406 } 407 } 408 409 if (sv_mounted) 408 410 break; 409 } 410 } 411 412 if (sv_mounted == false) { 413 printf("System volume not found.\n"); 414 rc = EIO; 415 goto error; 416 } 417 418 free(part_ids); 419 part_ids = NULL; 420 411 412 free(part_ids); 413 part_ids = NULL; 414 415 fibril_sleep(1); 416 printf("Sleeping(1) for system volume.\n"); 417 } 421 418 } 422 419 … … 523 520 /* Eject all volumes. */ 524 521 525 log_msg(LOG_DEFAULT, LVL_NOTE, "Ejecting volumes.");526 527 522 rc = vol_create(&vol); 528 523 if (rc != EOK) { … … 539 534 540 535 for (i = 0; i < nparts; i++) { 541 rc = vol_part_eject(vol, part_ids[i] , vef_none);536 rc = vol_part_eject(vol, part_ids[i]); 542 537 if (rc != EOK) { 543 538 log_msg(LOG_DEFAULT, LVL_ERROR, "Error ejecting " … … 549 544 free(part_ids); 550 545 vol_destroy(vol); 551 552 546 return EOK; 553 547 error: … … 616 610 } 617 611 618 /** System poweroffrequest.612 /** System shutdown request. 619 613 * 620 614 * @param arg Argument (sys_srv_t *) 621 615 */ 622 static errno_t system_srv_ poweroff(void *arg)616 static errno_t system_srv_shutdown(void *arg) 623 617 { 624 618 sys_srv_t *syssrv = (sys_srv_t *)arg; 625 619 errno_t rc; 626 620 627 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_ poweroff");621 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown"); 628 622 629 623 rc = system_sys_shutdown(); 630 624 if (rc != EOK) { 631 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_ powerofffailed");625 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown failed"); 632 626 system_srv_shutdown_failed(&syssrv->srv); 633 627 } 634 628 635 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff complete"); 636 system_srv_shutdown_complete(&syssrv->srv); 637 return EOK; 638 } 639 640 /** System restart request. 641 * 642 * @param arg Argument (sys_srv_t *) 643 */ 644 static errno_t system_srv_restart(void *arg) 645 { 646 sys_srv_t *syssrv = (sys_srv_t *)arg; 647 errno_t rc; 648 649 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart"); 650 651 rc = system_sys_shutdown(); 652 if (rc != EOK) { 653 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart failed"); 654 system_srv_shutdown_failed(&syssrv->srv); 655 } 656 657 /* Quiesce the device tree. */ 658 659 log_msg(LOG_DEFAULT, LVL_NOTE, "Quiescing devices."); 660 661 rc = devman_quiesce_devices("/hw"); 662 if (rc != EOK) { 663 log_msg(LOG_DEFAULT, LVL_ERROR, 664 "Failed to quiesce device tree."); 665 return rc; 666 } 667 668 sys_reboot(); 669 670 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart complete"); 629 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown complete"); 671 630 system_srv_shutdown_complete(&syssrv->srv); 672 631 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.