Changeset 629b480 in mainline for uspace/app
- Timestamp:
- 2025-04-25T20:48:07Z (10 months ago)
- Branches:
- master
- Children:
- 21cd0c8, 32cb7cd, a4f8c3f, cbaf408
- Parents:
- 4b9213d
- Location:
- uspace/app
- Files:
-
- 3 edited
-
sysinst/sysinst.c (modified) (19 diffs)
-
sysinst/sysinst.h (modified) (2 diffs)
-
vol/vol.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sysinst/sysinst.c
r4b9213d r629b480 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); 157 160 158 161 static futil_cb_t sysinst_futil_cb = { … … 424 427 } 425 428 426 /** Label the destination device.429 /** Label and mount the destination device. 427 430 * 428 431 * @param sysinst System installer … … 432 435 * @return EOK on success or an error code 433 436 */ 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; 437 static errno_t sysinst_label_dev(sysinst_t *sysinst, const char *dev) 438 { 439 fdisk_t *fdisk = NULL; 440 fdisk_dev_t *fdev = NULL; 439 441 fdisk_part_t *part; 440 442 fdisk_part_spec_t pspec; 441 443 fdisk_part_info_t pinfo; 444 bool dir_created = false; 445 bool label_created = false; 442 446 capa_spec_t capa; 443 447 service_id_t sid; … … 448 452 rc = loc_service_get_id(dev, &sid, 0); 449 453 if (rc != EOK) 450 return rc;454 goto error; 451 455 452 456 sysinst_debug(sysinst, "sysinst_label_dev(): open device"); … … 455 459 if (rc != EOK) { 456 460 sysinst_error(sysinst, "Error initializing fdisk."); 457 return rc;461 goto error; 458 462 } 459 463 … … 461 465 if (rc != EOK) { 462 466 sysinst_error(sysinst, "Error opening device."); 463 return rc;467 goto error; 464 468 } 465 469 … … 469 473 if (rc != EOK) { 470 474 sysinst_error(sysinst, "Error creating mount directory."); 471 return rc; 472 } 475 goto error; 476 } 477 478 dir_created = true; 473 479 474 480 sysinst_debug(sysinst, "sysinst_label_dev(): create label"); … … 477 483 if (rc != EOK) { 478 484 sysinst_error(sysinst, "Error creating label."); 479 return rc; 480 } 485 goto error; 486 } 487 488 label_created = true; 481 489 482 490 sysinst_debug(sysinst, "sysinst_label_dev(): create partition"); … … 486 494 sysinst_error(sysinst, 487 495 "Error getting available capacity."); 488 return rc;496 goto error; 489 497 } 490 498 … … 499 507 if (rc != EOK) { 500 508 sysinst_error(sysinst, "Error creating partition."); 501 return rc;509 goto error; 502 510 } 503 511 … … 505 513 if (rc != EOK) { 506 514 sysinst_error(sysinst, "Error getting partition information."); 507 return rc;515 goto error; 508 516 } 509 517 510 518 sysinst_debug(sysinst, "sysinst_label_dev(): OK"); 511 *psvc_id = pinfo.svc_id; 519 fdisk_dev_close(fdev); 520 fdisk_destroy(fdisk); 521 sysinst->psvc_id = pinfo.svc_id; 522 return EOK; 523 error: 524 if (label_created) 525 fdisk_label_destroy(fdev); 526 if (dir_created) 527 (void)vfs_unlink_path(MOUNT_POINT); 528 if (fdev != NULL) 529 fdisk_dev_close(fdev); 530 if (fdisk != NULL) 531 fdisk_destroy(fdisk); 532 return rc; 533 } 534 535 /** Finish/unmount destination device. 536 * 537 * @param sysinst System installer 538 * 539 * @return EOK on success or an error code 540 */ 541 static errno_t sysinst_finish_dev(sysinst_t *sysinst) 542 { 543 errno_t rc; 544 545 sysinst_debug(sysinst, "sysinst_finish_dev(): eject target volume"); 546 rc = sysinst_eject_dev(sysinst, sysinst->psvc_id); 547 if (rc != EOK) 548 return rc; 549 550 sysinst_debug(sysinst, "sysinst_finish_dev(): " 551 "deleting mount directory"); 552 (void)vfs_unlink_path(MOUNT_POINT); 553 512 554 return EOK; 513 555 } … … 811 853 * 812 854 * @param sysinst System installer 813 * @param p svc_id Partition service ID855 * @param part_id Partition service ID 814 856 * @return EOK on success or an error code 815 857 */ … … 825 867 } 826 868 827 rc = vol_part_eject(vol, part_id, vef_ physical);869 rc = vol_part_eject(vol, part_id, vef_none); 828 870 if (rc != EOK) { 829 871 sysinst_error(sysinst, "Error ejecting volume."); … … 837 879 } 838 880 881 /** Physically eject volume by mount point. 882 * 883 * @param sysinst System installer 884 * @param path Mount point 885 * @return EOK on success or an error code 886 */ 887 static errno_t sysinst_eject_phys_by_mp(sysinst_t *sysinst, const char *path) 888 { 889 vol_t *vol = NULL; 890 sysarg_t part_id; 891 errno_t rc; 892 893 rc = vol_create(&vol); 894 if (rc != EOK) { 895 sysinst_error(sysinst, "Error contacting volume service."); 896 goto out; 897 } 898 899 log_msg(LOG_DEFAULT, LVL_NOTE, "vol_part_by_mp: mp='%s'\n", 900 path); 901 rc = vol_part_by_mp(vol, path, &part_id); 902 if (rc != EOK) { 903 sysinst_error(sysinst, 904 "Error finding installation media mount point."); 905 goto out; 906 } 907 908 log_msg(LOG_DEFAULT, LVL_NOTE, "eject svc_id %lu", (unsigned long)part_id); 909 rc = vol_part_eject(vol, part_id, vef_physical); 910 if (rc != EOK) { 911 sysinst_error(sysinst, "Error ejecting volume."); 912 goto out; 913 } 914 915 rc = EOK; 916 out: 917 vol_destroy(vol); 918 return rc; 919 } 920 839 921 /** Restart the system. 840 922 * … … 901 983 { 902 984 errno_t rc; 903 service_id_t psvc_id;904 985 905 986 sysinst_action(sysinst, "Creating device label and file system."); 906 987 907 rc = sysinst_label_dev(sysinst, dev , &psvc_id);988 rc = sysinst_label_dev(sysinst, dev); 908 989 if (rc != EOK) 909 990 return rc; … … 924 1005 return rc; 925 1006 1007 sysinst_action(sysinst, "Finishing system volume."); 1008 rc = sysinst_finish_dev(sysinst); 1009 if (rc != EOK) 1010 return rc; 1011 926 1012 sysinst_action(sysinst, "Installing boot blocks."); 927 1013 rc = sysinst_copy_boot_blocks(sysinst, dev); … … 929 1015 return rc; 930 1016 931 sysinst_action(sysinst, "Ejecting device.");932 rc = sysinst_eject_ dev(sysinst, psvc_id);1017 sysinst_action(sysinst, "Ejecting installation media."); 1018 rc = sysinst_eject_phys_by_mp(sysinst, CD_MOUNT_POINT); 933 1019 if (rc != EOK) 934 1020 return rc; -
uspace/app/sysinst/sysinst.h
r4b9213d r629b480 39 39 #include <futil.h> 40 40 #include <gfx/color.h> 41 #include <loc.h> 41 42 #include <system.h> 42 43 #include <ui/fixed.h> … … 60 61 sysinst_progress_t *progress; 61 62 system_t *system; 63 /** Service ID of destination partition. */ 64 sysarg_t psvc_id; 62 65 futil_t *futil; 63 66 char errmsg[128]; -
uspace/app/vol/vol.c
r4b9213d r629b480 54 54 } vol_cmd_t; 55 55 56 /** Find volume by current mount point. */57 static errno_t vol_cmd_part_by_mp(vol_t *vol, const char *mp,58 service_id_t *rid)59 {60 vol_part_info_t vinfo;61 service_id_t *part_ids = NULL;62 char *canon_mp_buf = NULL;63 char *canon_mp;64 size_t nparts;65 size_t i;66 errno_t rc;67 68 canon_mp_buf = str_dup(mp);69 if (canon_mp_buf == NULL) {70 printf("Out of memory.\n");71 rc = ENOMEM;72 goto out;73 }74 75 canon_mp = vfs_absolutize(canon_mp_buf, NULL);76 if (canon_mp == NULL) {77 printf("Invalid volume path '%s'.\n", mp);78 rc = EINVAL;79 goto out;80 }81 82 rc = vol_get_parts(vol, &part_ids, &nparts);83 if (rc != EOK) {84 printf("Error getting list of volumes.\n");85 goto out;86 }87 88 for (i = 0; i < nparts; i++) {89 rc = vol_part_info(vol, part_ids[i], &vinfo);90 if (rc != EOK) {91 printf("Error getting volume information.\n");92 rc = EIO;93 goto out;94 }95 96 if (str_cmp(vinfo.cur_mp, canon_mp) == 0) {97 *rid = part_ids[i];98 rc = EOK;99 goto out;100 }101 }102 103 rc = ENOENT;104 out:105 free(part_ids);106 free(canon_mp_buf);107 return rc;108 }109 110 56 static errno_t vol_cmd_eject(const char *volspec, bool physical) 111 57 { … … 120 66 } 121 67 122 rc = vol_ cmd_part_by_mp(vol, volspec, &part_id);68 rc = vol_part_by_mp(vol, volspec, &part_id); 123 69 if (rc != EOK) { 124 70 printf("Error looking up volume '%s'.\n", volspec);
Note:
See TracChangeset
for help on using the changeset viewer.
