Changeset 3cdd876 in mainline for uspace/app/sysinst/sysinst.c
- Timestamp:
- 2018-08-08T16:34:47Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 21a0d8a
- Parents:
- 44428bb
- git-author:
- Jiri Svoboda <jiri@…> (2018-08-07 18:34:24)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-08-08 16:34:47)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sysinst/sysinst.c
r44428bb r3cdd876 44 44 #include <stdio.h> 45 45 #include <stdlib.h> 46 #include <str.h> 46 47 #include <str_error.h> 47 48 #include <task.h> 48 49 #include <vfs/vfs.h> 49 #include < str.h>50 #include <vol.h> 50 51 51 52 #include "futil.h" … … 63 64 //#define DEFAULT_DEV "devices/\\hw\\pci0\\00:01.2\\uhci_rh\\usb01_a1\\mass-storage0\\l0" 64 65 65 /** Filysystem type. Cannot be changed without building a custom core.img */66 #define FS_TYPE "mfs"67 68 #define FS_SRV "/srv/mfs"69 66 #define MOUNT_POINT "/inst" 70 67 … … 79 76 * 80 77 * @param dev Disk device to label 81 * @param p dev Place to store partition device name78 * @param psvc_id Place to store service ID of the created partition 82 79 * 83 80 * @return EOK on success or an error code 84 81 */ 85 static errno_t sysinst_label_dev(const char *dev, char **pdev)82 static errno_t sysinst_label_dev(const char *dev, service_id_t *psvc_id) 86 83 { 87 84 fdisk_t *fdisk; … … 89 86 fdisk_part_t *part; 90 87 fdisk_part_spec_t pspec; 88 fdisk_part_info_t pinfo; 91 89 cap_spec_t cap; 92 90 service_id_t sid; … … 111 109 return rc; 112 110 } 111 112 printf("sysinst_label_dev(): create mount directory\n"); 113 114 rc = vfs_link_path(MOUNT_POINT, KIND_DIRECTORY, NULL); 115 if (rc != EOK) 116 return rc; 113 117 114 118 printf("sysinst_label_dev(): create label\n"); … … 131 135 pspec.capacity = cap; 132 136 pspec.pkind = lpk_primary; 133 pspec.fstype = fs_minix; 134 pspec.mountp = "";137 pspec.fstype = fs_minix; /* Cannot be changed without modifying core.img */ 138 pspec.mountp = MOUNT_POINT; 135 139 136 140 rc = fdisk_part_create(fdev, &pspec, &part); … … 140 144 } 141 145 142 /* XXX libfdisk should give us the service name */ 143 if (asprintf(pdev, "%sp1", dev) < 0) 144 return ENOMEM; 146 rc = fdisk_part_get_info(part, &pinfo); 147 if (rc != EOK) { 148 printf("Error getting partition information.\n"); 149 return rc; 150 } 145 151 146 152 printf("sysinst_label_dev(): OK\n"); 147 return EOK; 148 } 149 150 /** Mount target file system. 151 * 152 * @param dev Partition device 153 * @return EOK on success or an error code 154 */ 155 static errno_t sysinst_fs_mount(const char *dev) 156 { 157 task_wait_t twait; 158 task_exit_t texit; 159 errno_t rc; 160 int trc; 161 162 printf("sysinst_fs_mount(): start filesystem server\n"); 163 rc = task_spawnl(NULL, &twait, FS_SRV, FS_SRV, NULL); 164 if (rc != EOK) 165 return rc; 166 167 printf("sysinst_fs_mount(): wait for filesystem server\n"); 168 rc = task_wait(&twait, &texit, &trc); 169 if (rc != EOK) 170 return rc; 171 172 printf("sysinst_fs_mount(): verify filesystem server result\n"); 173 if (texit != TASK_EXIT_NORMAL || trc != 0) { 174 printf("sysinst_fs_mount(): not successful, but could be already loaded.\n"); 175 } 176 177 rc = vfs_link_path(MOUNT_POINT, KIND_DIRECTORY, NULL); 178 if (rc != EOK) 179 return rc; 180 181 printf("sysinst_fs_mount(): mount filesystem\n"); 182 rc = vfs_mount_path(MOUNT_POINT, FS_TYPE, dev, "", 0, 0); 183 if (rc != EOK) 184 return rc; 185 186 printf("sysinst_fs_mount(): OK\n"); 153 *psvc_id = pinfo.svc_id; 187 154 return EOK; 188 155 } … … 198 165 printf("sysinst_copy_boot_files(): copy bootloader files\n"); 199 166 rc = futil_rcopy_contents(BOOT_FILES_SRC, MOUNT_POINT); 200 if (rc != EOK)201 return rc;202 203 printf("sysinst_copy_boot_files(): unmount %s\n", MOUNT_POINT);204 rc = vfs_unmount_path(MOUNT_POINT);205 167 if (rc != EOK) 206 168 return rc; … … 321 283 } 322 284 285 /** Eject installation volume. 286 * 287 * @param psvc_id Partition service ID 288 */ 289 static errno_t sysinst_eject_dev(service_id_t part_id) 290 { 291 vol_t *vol = NULL; 292 errno_t rc; 293 294 rc = vol_create(&vol); 295 if (rc != EOK) { 296 printf("Error contacting volume service.\n"); 297 goto out; 298 } 299 300 rc = vol_part_eject(vol, part_id); 301 if (rc != EOK) { 302 printf("Error ejecting volume.\n"); 303 goto out; 304 } 305 306 rc = EOK; 307 out: 308 vol_destroy(vol); 309 return rc; 310 } 311 323 312 /** Install system to a device. 324 313 * … … 329 318 { 330 319 errno_t rc; 331 char *pdev; 332 333 rc = sysinst_label_dev(dev, &pdev); 334 if (rc != EOK) 335 return rc; 336 337 printf("Partition '%s'. Mount it.\n", pdev); 338 rc = sysinst_fs_mount(pdev); 339 if (rc != EOK) 340 return rc; 341 342 free(pdev); 320 service_id_t psvc_id; 321 322 rc = sysinst_label_dev(dev, &psvc_id); 323 if (rc != EOK) 324 return rc; 343 325 344 326 printf("FS created and mounted. Copying boot files.\n"); … … 352 334 return rc; 353 335 336 printf("Ejecting device.\n"); 337 rc = sysinst_eject_dev(psvc_id); 338 if (rc != EOK) 339 return rc; 340 354 341 return EOK; 355 342 }
Note:
See TracChangeset
for help on using the changeset viewer.