Changeset aca1777 in mainline for uspace/app/sysinst/sysinst.c
- Timestamp:
- 2025-05-08T17:12:05Z (2 months ago)
- Children:
- 2f21cd4
- Parents:
- 1cfce3f (diff), 61f28c4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sysinst/sysinst.c
r1cfce3f raca1777 73 73 #define DEFAULT_DEV_0 "devices/\\hw\\sys\\00:01.1\\c0d0" 74 74 #define DEFAULT_DEV_1 "devices/\\hw\\sys\\ide1\\c0d0" 75 #define DEFAULT_DEV_2 "devices/\\hw\\sys\\00:01.0\\ide1\\c0d0" 75 76 //#define DEFAULT_DEV "devices/\\hw\\pci0\\00:01.2\\uhci_rh\\usb01_a1\\mass-storage0\\l0" 76 77 /** Volume label for the new file system */ … … 95 96 DEFAULT_DEV_0, 96 97 DEFAULT_DEV_1, 98 DEFAULT_DEV_2, 97 99 NULL 98 100 }; … … 155 157 static void sysinst_futil_copy_file(void *, const char *, const char *); 156 158 static void sysinst_futil_create_dir(void *, const char *); 159 static errno_t sysinst_eject_dev(sysinst_t *, service_id_t); 160 static errno_t sysinst_eject_phys_by_mp(sysinst_t *, const char *); 157 161 158 162 static futil_cb_t sysinst_futil_cb = { … … 269 273 case 0: 270 274 /* OK */ 275 sysinst_action(sysinst, "Ejecting installation media."); 276 (void)sysinst_eject_phys_by_mp(sysinst, CD_MOUNT_POINT); 271 277 (void)sysinst_restart(sysinst); 272 278 break; … … 424 430 } 425 431 426 /** Label the destination device.432 /** Label and mount the destination device. 427 433 * 428 434 * @param sysinst System installer … … 432 438 * @return EOK on success or an error code 433 439 */ 434 static errno_t sysinst_label_dev(sysinst_t *sysinst, const char *dev, 435 service_id_t *psvc_id) 436 { 437 fdisk_t *fdisk; 438 fdisk_dev_t *fdev; 440 static errno_t sysinst_label_dev(sysinst_t *sysinst, const char *dev) 441 { 442 fdisk_t *fdisk = NULL; 443 fdisk_dev_t *fdev = NULL; 439 444 fdisk_part_t *part; 440 445 fdisk_part_spec_t pspec; 441 446 fdisk_part_info_t pinfo; 447 bool dir_created = false; 448 bool label_created = false; 442 449 capa_spec_t capa; 443 450 service_id_t sid; … … 448 455 rc = loc_service_get_id(dev, &sid, 0); 449 456 if (rc != EOK) 450 return rc;457 goto error; 451 458 452 459 sysinst_debug(sysinst, "sysinst_label_dev(): open device"); … … 455 462 if (rc != EOK) { 456 463 sysinst_error(sysinst, "Error initializing fdisk."); 457 return rc;464 goto error; 458 465 } 459 466 … … 461 468 if (rc != EOK) { 462 469 sysinst_error(sysinst, "Error opening device."); 463 return rc;470 goto error; 464 471 } 465 472 … … 469 476 if (rc != EOK) { 470 477 sysinst_error(sysinst, "Error creating mount directory."); 471 return rc; 472 } 478 goto error; 479 } 480 481 dir_created = true; 473 482 474 483 sysinst_debug(sysinst, "sysinst_label_dev(): create label"); … … 477 486 if (rc != EOK) { 478 487 sysinst_error(sysinst, "Error creating label."); 479 return rc; 480 } 488 goto error; 489 } 490 491 label_created = true; 481 492 482 493 sysinst_debug(sysinst, "sysinst_label_dev(): create partition"); … … 486 497 sysinst_error(sysinst, 487 498 "Error getting available capacity."); 488 return rc;499 goto error; 489 500 } 490 501 … … 499 510 if (rc != EOK) { 500 511 sysinst_error(sysinst, "Error creating partition."); 501 return rc;512 goto error; 502 513 } 503 514 … … 505 516 if (rc != EOK) { 506 517 sysinst_error(sysinst, "Error getting partition information."); 507 return rc;518 goto error; 508 519 } 509 520 510 521 sysinst_debug(sysinst, "sysinst_label_dev(): OK"); 511 *psvc_id = pinfo.svc_id; 522 fdisk_dev_close(fdev); 523 fdisk_destroy(fdisk); 524 sysinst->psvc_id = pinfo.svc_id; 525 return EOK; 526 error: 527 if (label_created) 528 fdisk_label_destroy(fdev); 529 if (dir_created) 530 (void)vfs_unlink_path(MOUNT_POINT); 531 if (fdev != NULL) 532 fdisk_dev_close(fdev); 533 if (fdisk != NULL) 534 fdisk_destroy(fdisk); 535 return rc; 536 } 537 538 /** Finish/unmount destination device. 539 * 540 * @param sysinst System installer 541 * 542 * @return EOK on success or an error code 543 */ 544 static errno_t sysinst_finish_dev(sysinst_t *sysinst) 545 { 546 errno_t rc; 547 548 sysinst_debug(sysinst, "sysinst_finish_dev(): eject target volume"); 549 rc = sysinst_eject_dev(sysinst, sysinst->psvc_id); 550 if (rc != EOK) 551 return rc; 552 553 sysinst_debug(sysinst, "sysinst_finish_dev(): " 554 "deleting mount directory"); 555 (void)vfs_unlink_path(MOUNT_POINT); 556 512 557 return EOK; 513 558 } … … 550 595 rc = futil_rcopy_contents(sysinst->futil, CFG_FILES_SRC, 551 596 CFG_FILES_DEST); 552 if (rc != EOK) 553 return rc; 597 if (rc != EOK) { 598 sysinst_error(sysinst, "Error copying initial configuration " 599 "files."); 600 return rc; 601 } 554 602 555 603 return EOK; … … 571 619 "sysinst_copy_boot_files(): copy bootloader files"); 572 620 rc = futil_rcopy_contents(sysinst->futil, BOOT_FILES_SRC, MOUNT_POINT); 573 if (rc != EOK) 574 return rc; 621 if (rc != EOK) { 622 sysinst_error(sysinst, "Error copying bootloader " 623 "files."); 624 return rc; 625 } 575 626 576 627 sysinst_debug(sysinst, "sysinst_copy_boot_files(): OK"); … … 811 862 * 812 863 * @param sysinst System installer 813 * @param p svc_id Partition service ID864 * @param part_id Partition service ID 814 865 * @return EOK on success or an error code 815 866 */ … … 825 876 } 826 877 827 rc = vol_part_eject(vol, part_id, vef_ physical);878 rc = vol_part_eject(vol, part_id, vef_none); 828 879 if (rc != EOK) { 829 880 sysinst_error(sysinst, "Error ejecting volume."); … … 837 888 } 838 889 890 /** Physically eject volume by mount point. 891 * 892 * @param sysinst System installer 893 * @param path Mount point 894 * @return EOK on success or an error code 895 */ 896 static errno_t sysinst_eject_phys_by_mp(sysinst_t *sysinst, const char *path) 897 { 898 vol_t *vol = NULL; 899 sysarg_t part_id; 900 errno_t rc; 901 902 log_msg(LOG_DEFAULT, LVL_NOTE, 903 "sysinst_eject_phys_by_mp(%s)", path); 904 905 rc = vol_create(&vol); 906 if (rc != EOK) { 907 sysinst_error(sysinst, "Error contacting volume service."); 908 goto out; 909 } 910 911 log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_by_mp: mp='%s'\n", 912 path); 913 rc = vol_part_by_mp(vol, path, &part_id); 914 if (rc != EOK) { 915 sysinst_error(sysinst, 916 "Error finding installation media mount point."); 917 goto out; 918 } 919 920 log_msg(LOG_DEFAULT, LVL_NOTE, "eject svc_id %lu", (unsigned long)part_id); 921 rc = vol_part_eject(vol, part_id, vef_physical); 922 if (rc != EOK) { 923 sysinst_error(sysinst, "Error ejecting volume."); 924 goto out; 925 } 926 927 rc = EOK; 928 out: 929 vol_destroy(vol); 930 return rc; 931 } 932 839 933 /** Restart the system. 840 934 * … … 852 946 shutdown_failed = false; 853 947 948 sysinst_action(sysinst, "Restarting the system."); 949 854 950 rc = system_open(SYSTEM_DEFAULT, &sysinst_system_cb, NULL, &system); 855 951 if (rc != EOK) { … … 901 997 { 902 998 errno_t rc; 903 service_id_t psvc_id;999 bool clean_dev = false; 904 1000 905 1001 sysinst_action(sysinst, "Creating device label and file system."); 906 1002 907 rc = sysinst_label_dev(sysinst, dev, &psvc_id); 908 if (rc != EOK) 909 return rc; 1003 rc = sysinst_label_dev(sysinst, dev); 1004 if (rc != EOK) 1005 goto error; 1006 1007 clean_dev = true; 910 1008 911 1009 sysinst_action(sysinst, "Creating system directory structure."); 912 1010 rc = sysinst_setup_sysvol(sysinst); 913 1011 if (rc != EOK) 914 return rc;1012 goto error; 915 1013 916 1014 sysinst_action(sysinst, "Copying boot files."); 917 1015 rc = sysinst_copy_boot_files(sysinst); 918 1016 if (rc != EOK) 919 return rc;1017 goto error; 920 1018 921 1019 sysinst_action(sysinst, "Configuring the system."); 922 1020 rc = sysinst_customize_initrd(sysinst); 923 1021 if (rc != EOK) 924 return rc; 1022 goto error; 1023 1024 sysinst_action(sysinst, "Finishing system volume."); 1025 rc = sysinst_finish_dev(sysinst); 1026 if (rc != EOK) 1027 goto error; 1028 1029 clean_dev = false; 925 1030 926 1031 sysinst_action(sysinst, "Installing boot blocks."); … … 929 1034 return rc; 930 1035 931 sysinst_action(sysinst, "Ejecting device."); 932 rc = sysinst_eject_dev(sysinst, psvc_id); 933 if (rc != EOK) 934 return rc; 935 936 return EOK; 1036 return EOK; 1037 error: 1038 if (clean_dev) 1039 (void)sysinst_finish_dev(sysinst); 1040 return rc; 937 1041 } 938 1042 … … 969 1073 970 1074 sysinst_progress_destroy(sysinst->progress); 1075 sysinst->progress = NULL; 1076 971 1077 rc = sysinst_restart_dlg_create(sysinst); 972 1078 if (rc != EOK) … … 1147 1253 static void sysinst_action(sysinst_t *sysinst, const char *action) 1148 1254 { 1255 log_msg(LOG_DEFAULT, LVL_NOTE, "%s", action); 1256 1149 1257 if (sysinst->progress == NULL) 1150 1258 return; … … 1152 1260 ui_label_set_text(sysinst->progress->action, action); 1153 1261 ui_label_paint(sysinst->progress->action); 1154 log_msg(LOG_DEFAULT, LVL_NOTE, "%s", action);1155 1262 } 1156 1263
Note:
See TracChangeset
for help on using the changeset viewer.