Changes in / [3acb63b5:9f945464] in mainline
- Location:
- uspace
- Files:
-
- 2 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/shutdown-dlg/shutdown-dlg.c
r3acb63b5 r9f945464 238 238 * 239 239 * @param dialog Message dialog 240 * @param arg Argument ( shutdown_dlg_t *)240 * @param arg Argument (ui_demo_t *) 241 241 * @param earg Entry argument 242 242 */ … … 254 254 * 255 255 * @param dialog Message dialog 256 * @param arg Argument ( shutdown_dlg_t *)256 * @param arg Argument (ui_demo_t *) 257 257 */ 258 258 static void shutdown_confirm_bcancel(ui_select_dialog_t *dialog, void *arg) … … 267 267 * 268 268 * @param dialog Message dialog 269 * @param arg Argument ( shutdown_dlg_t *)269 * @param arg Argument (ui_demo_t *) 270 270 */ 271 271 static void shutdown_confirm_close(ui_select_dialog_t *dialog, void *arg) … … 280 280 * 281 281 * @param dialog Message dialog 282 * @param arg Argument ( shutdown_dlg_t *)282 * @param arg Argument (ui_demo_t *) 283 283 * @param bnum Button number 284 284 */ … … 295 295 * 296 296 * @param dialog Message dialog 297 * @param arg Argument ( shutdown_dlg_t *)297 * @param arg Argument (ui_demo_t *) 298 298 */ 299 299 static void shutdown_failed_msg_close(ui_msg_dialog_t *dialog, void *arg) … … 480 480 481 481 ui_wnd_params_init(¶ms); 482 params.caption = "Shut down";482 params.caption = "Shut down background"; 483 483 params.style &= ~ui_wds_decorated; 484 484 params.placement = ui_wnd_place_full_screen; 485 485 params.flags |= ui_wndf_topmost | ui_wndf_nofocus; 486 /* 487 * params.rect.p0.x = 0; 488 * params.rect.p0.y = 0; 489 * params.rect.p1.x = 1; 490 * params.rect.p1.y = 1; 491 */ 486 492 487 493 rc = ui_window_create(sddlg.ui, ¶ms, &sddlg.bgwindow); -
uspace/app/shutdown-dlg/shutdown-dlg.h
r3acb63b5 r9f945464 27 27 */ 28 28 29 /** @addtogroup shutdown-dlg29 /** @addtogroup hello 30 30 * @{ 31 31 */ -
uspace/app/sysinst/meson.build
r3acb63b5 r9f945464 1 1 # 2 # Copyright (c) 20 25Jiri Svoboda2 # Copyright (c) 2014 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 deps = [ 'block', 'fdisk', 'futil', 'sif', 'system' , 'ui']29 deps = [ 'block', 'fdisk', 'futil', 'sif', 'system' ] 30 30 src = files( 31 31 'rdimg.c', -
uspace/app/sysinst/rdimg.c
r3acb63b5 r9f945464 35 35 #include <errno.h> 36 36 #include <fibril.h> 37 #include <io/log.h>38 37 #include <stdio.h> 39 38 #include <stdlib.h> … … 61 60 rc = vol_get_parts(vol, &part_ids, &nparts); 62 61 if (rc != EOK) { 63 log_msg(LOG_DEFAULT, LVL_ERROR, 64 "Error getting list of volumes."); 62 printf("Error getting list of volumes.\n"); 65 63 goto out; 66 64 } … … 69 67 rc = vol_part_info(vol, part_ids[i], &vinfo); 70 68 if (rc != EOK) { 71 log_msg(LOG_DEFAULT, LVL_ERROR, 72 "Error getting volume information."); 69 printf("Error getting volume information.\n"); 73 70 rc = EIO; 74 71 goto out; … … 109 106 int cnt; 110 107 111 log_msg(LOG_DEFAULT, LVL_NOTE, "rd_img_open: begin"); 112 108 printf("rd_img_open: begin\n"); 113 109 rdpath = str_dup("/vol/" RD_LABEL); 114 110 if (rdpath == NULL) { … … 123 119 } 124 120 125 log_msg(LOG_DEFAULT, LVL_NOTE, "rd_img_open: spawn file_bd");121 printf("rd_img_open: spawn file_bd\n"); 126 122 rc = task_spawnl(&id, &wait, FILE_BD, FILE_BD, imgpath, RD_SVC, NULL); 127 123 if (rc != EOK) { … … 130 126 } 131 127 132 log_msg(LOG_DEFAULT, LVL_NOTE, "rd_img_open: wait for file_bd");128 printf("rd_img_open: wait for file_bd\n"); 133 129 rc = task_wait(&wait, &texit, &retval); 134 130 if (rc != EOK || texit != TASK_EXIT_NORMAL) { … … 138 134 139 135 /* Wait for the RAM disk to become available */ 140 log_msg(LOG_DEFAULT, LVL_NOTE, 141 "rd_img_open: wait for RAM disk to be mounted"); 136 printf("rd_img_open: wait for RAM disk to be mounted\n"); 142 137 cnt = 10; 143 138 while (cnt > 0) { … … 151 146 152 147 if (cnt == 0) { 153 log_msg(LOG_DEFAULT, LVL_ERROR, "rd_img_open: ran out of time");148 printf("rd_img_open: ran out of time\n"); 154 149 rc = EIO; 155 150 goto error; … … 159 154 *rimg = img; 160 155 *rpath = rdpath; 161 log_msg(LOG_DEFAULT, LVL_NOTE, "rd_img_open: success");156 printf("rd_img_open: success\n"); 162 157 return EOK; 163 158 error: … … 178 173 vol_t *vol = NULL; 179 174 180 log_msg(LOG_DEFAULT, LVL_NOTE, "rd_img_close: begin");175 printf("rd_img_close: begin\n"); 181 176 182 177 rc = vol_create(&vol); 183 178 if (rc != EOK) { 184 log_msg(LOG_DEFAULT, LVL_ERROR, 185 "Error opening volume management service."); 186 rc = EIO; 187 goto error; 188 } 189 190 log_msg(LOG_DEFAULT, LVL_NOTE, "rd_img_close: Find RAM disk volume."); 179 printf("Error opening volume management service.\n"); 180 rc = EIO; 181 goto error; 182 } 183 184 printf("rd_img_close: Find RAM disk volume.\n"); 191 185 rc = rd_img_part_by_label(vol, RD_LABEL, &rd_svcid); 192 186 if (rc != EOK) { 193 log_msg(LOG_DEFAULT, LVL_ERROR, 194 "Error getting RAM disk service ID."); 195 rc = EIO; 196 goto error; 197 } 198 199 log_msg(LOG_DEFAULT, LVL_NOTE, "rd_img_close: eject RAM disk volume"); 187 printf("Error getting RAM disk service ID.\n"); 188 rc = EIO; 189 goto error; 190 } 191 192 printf("rd_img_close: eject RAM disk volume\n"); 200 193 rc = vol_part_eject(vol, rd_svcid, vef_none); 201 194 if (rc != EOK) { 202 log_msg(LOG_DEFAULT, LVL_ERROR, 203 "Error ejecting RAM disk volume."); 195 printf("Error ejecting RAM disk volume.\n"); 204 196 rc = EIO; 205 197 goto error; … … 210 202 rc = task_kill(img->filebd_tid); 211 203 if (rc != EOK) { 212 log_msg(LOG_DEFAULT, LVL_ERROR, "Error killing file_bd.");204 printf("Error killing file_bd.\n"); 213 205 rc = EIO; 214 206 goto error; … … 216 208 217 209 free(img); 218 log_msg(LOG_DEFAULT, LVL_NOTE, "rd_img_close: success");210 printf("rd_img_close: success\n"); 219 211 return EOK; 220 212 error: -
uspace/app/sysinst/sysinst.c
r3acb63b5 r9f945464 42 42 #include <fdisk.h> 43 43 #include <futil.h> 44 #include <gfx/render.h>45 #include <io/log.h>46 44 #include <loc.h> 47 45 #include <stdio.h> … … 50 48 #include <str_error.h> 51 49 #include <system.h> 52 #include <ui/msgdialog.h>53 #include <ui/ui.h>54 #include <ui/window.h>55 50 #include <vfs/vfs.h> 56 51 #include <vol.h> … … 59 54 #include "rdimg.h" 60 55 #include "volume.h" 61 #include "sysinst.h"62 63 #define NAME "sysinst"64 56 65 57 /** Device to install to … … 104 96 }; 105 97 98 static bool restart = false; 99 106 100 static fibril_mutex_t shutdown_lock; 107 101 static fibril_condvar_t shutdown_cv; … … 116 110 .shutdown_failed = sysinst_shutdown_failed 117 111 }; 118 119 static void wnd_close(ui_window_t *, void *);120 static errno_t bg_wnd_paint(ui_window_t *, void *);121 122 static ui_window_cb_t bg_window_cb = {123 .close = wnd_close,124 .paint = bg_wnd_paint125 };126 127 static ui_window_cb_t progress_window_cb = {128 .close = wnd_close129 };130 131 static void sysinst_confirm_button(ui_msg_dialog_t *, void *, unsigned);132 static void sysinst_confirm_close(ui_msg_dialog_t *, void *);133 134 static ui_msg_dialog_cb_t sysinst_confirm_cb = {135 .button = sysinst_confirm_button,136 .close = sysinst_confirm_close137 };138 139 static errno_t sysinst_restart_dlg_create(sysinst_t *);140 static void sysinst_restart_dlg_button(ui_msg_dialog_t *, void *, unsigned);141 static void sysinst_restart_dlg_close(ui_msg_dialog_t *, void *);142 143 static ui_msg_dialog_cb_t sysinst_restart_dlg_cb = {144 .button = sysinst_restart_dlg_button,145 .close = sysinst_restart_dlg_close146 };147 148 static int sysinst_start(sysinst_t *);149 static errno_t sysinst_restart(sysinst_t *);150 static void sysinst_progress_destroy(sysinst_progress_t *);151 static void sysinst_action(sysinst_t *, const char *);152 static void sysinst_error(sysinst_t *, const char *);153 static void sysinst_debug(sysinst_t *, const char *);154 155 static void sysinst_futil_copy_file(void *, const char *, const char *);156 static void sysinst_futil_create_dir(void *, const char *);157 158 static futil_cb_t sysinst_futil_cb = {159 .copy_file = sysinst_futil_copy_file,160 .create_dir = sysinst_futil_create_dir161 };162 163 static void sysinst_error_msg_button(ui_msg_dialog_t *, void *, unsigned);164 static void sysinst_error_msg_close(ui_msg_dialog_t *, void *);165 166 static ui_msg_dialog_cb_t sysinst_error_msg_cb = {167 .button = sysinst_error_msg_button,168 .close = sysinst_error_msg_close169 };170 171 /** Close window.172 *173 * @param window Window174 * @param arg Argument (sysinst_t *)175 */176 static void wnd_close(ui_window_t *window, void *arg)177 {178 (void)window;179 (void)arg;180 }181 182 /** Paint background window.183 *184 * @param window Window185 * @param arg Argument (sysinst_t *)186 */187 static errno_t bg_wnd_paint(ui_window_t *window, void *arg)188 {189 sysinst_t *sysinst = (sysinst_t *)arg;190 gfx_rect_t app_rect;191 gfx_context_t *gc;192 errno_t rc;193 194 gc = ui_window_get_gc(window);195 196 rc = gfx_set_color(gc, sysinst->bg_color);197 if (rc != EOK)198 return rc;199 200 ui_window_get_app_rect(window, &app_rect);201 202 rc = gfx_fill_rect(gc, &app_rect);203 if (rc != EOK)204 return rc;205 206 rc = gfx_update(gc);207 if (rc != EOK)208 return rc;209 210 return EOK;211 }212 213 /** Installation confirm dialog OK button press.214 *215 * @param dialog Message dialog216 * @param arg Argument (sysinst_t *)217 * @param btn Button number218 * @param earg Entry argument219 */220 static void sysinst_confirm_button(ui_msg_dialog_t *dialog, void *arg,221 unsigned btn)222 {223 sysinst_t *sysinst = (sysinst_t *) arg;224 225 ui_msg_dialog_destroy(dialog);226 227 switch (btn) {228 case 0:229 /* OK */230 sysinst_start(sysinst);231 break;232 default:233 /* Cancel */234 ui_quit(sysinst->ui);235 break;236 }237 }238 239 /** Installation confirm dialog close request.240 *241 * @param dialog Message dialog242 * @param arg Argument (sysinst_t *)243 */244 static void sysinst_confirm_close(ui_msg_dialog_t *dialog, void *arg)245 {246 sysinst_t *sysinst = (sysinst_t *) arg;247 248 ui_msg_dialog_destroy(dialog);249 ui_quit(sysinst->ui);250 }251 252 /** Restart system dialog OK button press.253 *254 * @param dialog Message dialog255 * @param arg Argument (sysinst_t *)256 * @param btn Button number257 * @param earg Entry argument258 */259 static void sysinst_restart_dlg_button(ui_msg_dialog_t *dialog, void *arg,260 unsigned btn)261 {262 sysinst_t *sysinst = (sysinst_t *) arg;263 264 ui_msg_dialog_destroy(dialog);265 266 (void)sysinst;267 268 switch (btn) {269 case 0:270 /* OK */271 (void)sysinst_restart(sysinst);272 break;273 default:274 /* Cancel */275 ui_quit(sysinst->ui);276 break;277 }278 }279 280 /** Restat system dialog close request.281 *282 * @param dialog Message dialog283 * @param arg Argument (sysinst_t *)284 */285 static void sysinst_restart_dlg_close(ui_msg_dialog_t *dialog, void *arg)286 {287 sysinst_t *sysinst = (sysinst_t *) arg;288 289 ui_msg_dialog_destroy(dialog);290 ui_quit(sysinst->ui);291 }292 293 /** Installation error message dialog button press.294 *295 * @param dialog Message dialog296 * @param arg Argument (sysinst_t *)297 * @param bnum Button number298 */299 static void sysinst_error_msg_button(ui_msg_dialog_t *dialog,300 void *arg, unsigned bnum)301 {302 sysinst_t *sysinst = (sysinst_t *) arg;303 304 ui_msg_dialog_destroy(dialog);305 ui_quit(sysinst->ui);306 }307 308 /** Installation error message dialog close request.309 *310 * @param dialog Message dialog311 * @param arg Argument (shutdown_dlg_t *)312 */313 static void sysinst_error_msg_close(ui_msg_dialog_t *dialog, void *arg)314 {315 sysinst_t *sysinst = (sysinst_t *) arg;316 317 ui_msg_dialog_destroy(dialog);318 ui_quit(sysinst->ui);319 }320 321 /** Create error message dialog.322 *323 * @param sysinst System installer324 * @return EOK on success or an error code325 */326 static errno_t sysinst_error_msg_create(sysinst_t *sysinst)327 {328 ui_msg_dialog_params_t params;329 ui_msg_dialog_t *dialog;330 errno_t rc;331 332 ui_msg_dialog_params_init(¶ms);333 params.caption = "Error";334 params.text = sysinst->errmsg;335 params.flags |= umdf_topmost | umdf_center;336 337 rc = ui_msg_dialog_create(sysinst->ui, ¶ms, &dialog);338 if (rc != EOK)339 return rc;340 341 ui_msg_dialog_set_cb(dialog, &sysinst_error_msg_cb, (void *)sysinst);342 343 return EOK;344 }345 346 /** Called when futil is starting to copy a file.347 *348 * @param arg Argument (sysinst_t *)349 * @param src Source path350 * @param dest Destination path351 */352 static void sysinst_futil_copy_file(void *arg, const char *src,353 const char *dest)354 {355 sysinst_t *sysinst = (sysinst_t *)arg;356 char buf[128];357 358 (void)src;359 snprintf(buf, sizeof(buf), "Copying %s.", dest);360 sysinst_action(sysinst, buf);361 }362 363 /** Called when futil is about to create a directory.364 *365 * @param arg Argument (sysinst_t *)366 * @param dest Destination path367 */368 static void sysinst_futil_create_dir(void *arg, const char *dest)369 {370 sysinst_t *sysinst = (sysinst_t *)arg;371 char buf[128];372 373 snprintf(buf, sizeof(buf), "Creating %s.", dest);374 sysinst_action(sysinst, buf);375 }376 112 377 113 /** System shutdown complete. … … 426 162 /** Label the destination device. 427 163 * 428 * @param sysinst System installer429 164 * @param dev Disk device to label 430 165 * @param psvc_id Place to store service ID of the created partition … … 432 167 * @return EOK on success or an error code 433 168 */ 434 static errno_t sysinst_label_dev(sysinst_t *sysinst, const char *dev, 435 service_id_t *psvc_id) 169 static errno_t sysinst_label_dev(const char *dev, service_id_t *psvc_id) 436 170 { 437 171 fdisk_t *fdisk; … … 444 178 errno_t rc; 445 179 446 sysinst_debug(sysinst, "sysinst_label_dev(): get service ID"); 447 180 printf("sysinst_label_dev(): get service ID '%s'\n", dev); 448 181 rc = loc_service_get_id(dev, &sid, 0); 449 182 if (rc != EOK) 450 183 return rc; 451 184 452 sysinst_debug(sysinst, "sysinst_label_dev(): open device");185 printf("sysinst_label_dev(): open device\n"); 453 186 454 187 rc = fdisk_create(&fdisk); 455 188 if (rc != EOK) { 456 sysinst_error(sysinst, "Error initializing fdisk.");189 printf("Error initializing fdisk.\n"); 457 190 return rc; 458 191 } … … 460 193 rc = fdisk_dev_open(fdisk, sid, &fdev); 461 194 if (rc != EOK) { 462 sysinst_error(sysinst, "Error opening device.");463 return rc; 464 } 465 466 sysinst_debug(sysinst, "sysinst_label_dev(): create mount directory");195 printf("Error opening device.\n"); 196 return rc; 197 } 198 199 printf("sysinst_label_dev(): create mount directory\n"); 467 200 468 201 rc = vfs_link_path(MOUNT_POINT, KIND_DIRECTORY, NULL); 469 if (rc != EOK) { 470 sysinst_error(sysinst, "Error creating mount directory."); 471 return rc; 472 } 473 474 sysinst_debug(sysinst, "sysinst_label_dev(): create label"); 202 if (rc != EOK) 203 return rc; 204 205 printf("sysinst_label_dev(): create label\n"); 475 206 476 207 rc = fdisk_label_create(fdev, lt_mbr); 477 208 if (rc != EOK) { 478 sysinst_error(sysinst, "Error creating label.");479 return rc; 480 } 481 482 sysinst_debug(sysinst, "sysinst_label_dev(): create partition");209 printf("Error creating label: %s.\n", str_error(rc)); 210 return rc; 211 } 212 213 printf("sysinst_label_dev(): create partition\n"); 483 214 484 215 rc = fdisk_part_get_max_avail(fdev, spc_pri, &capa); 485 216 if (rc != EOK) { 486 sysinst_error(sysinst, 487 "Error getting available capacity."); 217 printf("Error getting available capacity: %s.\n", str_error(rc)); 488 218 return rc; 489 219 } … … 498 228 rc = fdisk_part_create(fdev, &pspec, &part); 499 229 if (rc != EOK) { 500 sysinst_error(sysinst, "Error creating partition.");230 printf("Error creating partition.\n"); 501 231 return rc; 502 232 } … … 504 234 rc = fdisk_part_get_info(part, &pinfo); 505 235 if (rc != EOK) { 506 sysinst_error(sysinst, "Error getting partition information.");507 return rc; 508 } 509 510 sysinst_debug(sysinst, "sysinst_label_dev(): OK");236 printf("Error getting partition information.\n"); 237 return rc; 238 } 239 240 printf("sysinst_label_dev(): OK\n"); 511 241 *psvc_id = pinfo.svc_id; 512 242 return EOK; … … 515 245 /** Set up system volume structure. 516 246 * 517 * @param sysinst System installer 518 * @return EOK on success or an error code 519 */ 520 static errno_t sysinst_setup_sysvol(sysinst_t *sysinst) 247 * @return EOK on success or an error code 248 */ 249 static errno_t sysinst_setup_sysvol(void) 521 250 { 522 251 errno_t rc; … … 535 264 rc = vfs_link_path(path, KIND_DIRECTORY, NULL); 536 265 if (rc != EOK) { 537 sysinst_error(sysinst, "Error creating directory.");266 printf("Error creating directory '%s'.\n", path); 538 267 goto error; 539 268 } … … 548 277 549 278 /* Copy initial configuration files */ 550 rc = futil_rcopy_contents(sysinst->futil, CFG_FILES_SRC, 551 CFG_FILES_DEST); 279 rc = futil_rcopy_contents(CFG_FILES_SRC, CFG_FILES_DEST); 552 280 if (rc != EOK) 553 281 return rc; … … 564 292 * @return EOK on success or an error code 565 293 */ 566 static errno_t sysinst_copy_boot_files(sysinst_t *sysinst) 567 { 568 errno_t rc; 569 570 log_msg(LOG_DEFAULT, LVL_NOTE, 571 "sysinst_copy_boot_files(): copy bootloader files"); 572 rc = futil_rcopy_contents(sysinst->futil, BOOT_FILES_SRC, MOUNT_POINT); 573 if (rc != EOK) 574 return rc; 575 576 sysinst_debug(sysinst, "sysinst_copy_boot_files(): OK"); 294 static errno_t sysinst_copy_boot_files(void) 295 { 296 errno_t rc; 297 298 printf("sysinst_copy_boot_files(): copy bootloader files\n"); 299 rc = futil_rcopy_contents(BOOT_FILES_SRC, MOUNT_POINT); 300 if (rc != EOK) 301 return rc; 302 303 printf("sysinst_copy_boot_files(): OK\n"); 577 304 return EOK; 578 305 } … … 580 307 /** Set up configuration in the initial RAM disk. 581 308 * 582 * @param sysinst System installer 583 * @return EOK on success or an error code 584 */ 585 static errno_t sysinst_customize_initrd(sysinst_t *sysinst) 309 * @return EOK on success or an error code 310 */ 311 static errno_t sysinst_customize_initrd(void) 586 312 { 587 313 errno_t rc; … … 595 321 rc = rd_img_open(MOUNT_POINT "/boot/initrd.img", &rdpath, &rd); 596 322 if (rc != EOK) { 597 sysinst_error(sysinst, "Error opening initial RAM disk image.");323 printf("Error opening initial RAM disk image.\n"); 598 324 goto error; 599 325 } … … 605 331 } 606 332 607 sysinst_debug(sysinst, "Configuring volume server."); 608 333 printf("Configuring volume server.\n"); 609 334 rc = vol_volumes_create(path, &volumes); 610 335 if (rc != EOK) { 611 sysinst_error(sysinst, 612 "Error creating volume server configuration."); 336 printf("Error creating volume server configuration.\n"); 613 337 rc = EIO; 614 338 goto error; 615 339 } 616 340 617 sysinst_debug(sysinst, "Configuring volume server: look up volume");341 printf("Configuring volume server: look up volume\n"); 618 342 rc = vol_volume_lookup_ref(volumes, INST_VOL_LABEL, &volume); 619 343 if (rc != EOK) { 620 sysinst_error(sysinst, 621 "Error creating volume server configuration."); 344 printf("Error creating volume server configuration.\n"); 622 345 rc = EIO; 623 346 goto error; 624 347 } 625 348 626 sysinst_debug(sysinst, "Configuring volume server: set mount point");349 printf("Configuring volume server: set mount point\n"); 627 350 rc = vol_volume_set_mountp(volume, INST_VOL_MP); 628 351 if (rc != EOK) { 629 sysinst_error(sysinst, 630 "Error creating system partition configuration."); 352 printf("Error creating system partition configuration.\n"); 631 353 rc = EIO; 632 354 goto error; … … 635 357 rc = vol_volumes_sync(volumes); 636 358 if (rc != EOK) { 637 sysinst_error(sysinst, "Error saving volume confiuration.");359 printf("Error saving volume confiuration.\n"); 638 360 goto error; 639 361 } 640 362 641 log_msg(LOG_DEFAULT, LVL_NOTE, 642 "Configuring volume server: delete reference"); 363 printf("Configuring volume server: delete reference\n"); 643 364 vol_volume_del_ref(volume); 644 365 volume = NULL; 645 log_msg(LOG_DEFAULT, LVL_NOTE, 646 "Configuring volume server: destroy volumes object"); 366 printf("Configuring volume server: destroy volumes object\n"); 647 367 vol_volumes_destroy(volumes); 648 368 volumes = NULL; … … 650 370 rc = rd_img_close(rd); 651 371 if (rc != EOK) { 652 sysinst_error(sysinst, "Error closing initial RAM disk image.");372 printf("Error closing initial RAM disk image.\n"); 653 373 rc = EIO; 654 374 goto error; … … 693 413 * Install Grub's boot blocks. 694 414 * 695 * @param sysinst System installer696 415 * @param devp Disk device 697 416 * @return EOK on success or an error code 698 417 */ 699 static errno_t sysinst_copy_boot_blocks( sysinst_t *sysinst,const char *devp)418 static errno_t sysinst_copy_boot_blocks(const char *devp) 700 419 { 701 420 void *boot_img; … … 711 430 errno_t rc; 712 431 713 log_msg(LOG_DEFAULT, LVL_NOTE, 714 "sysinst_copy_boot_blocks: Read boot block image."); 715 716 rc = futil_get_file(sysinst->futil, 717 BOOT_FILES_SRC "/boot/grub/i386-pc/boot.img", 432 printf("sysinst_copy_boot_blocks: Read boot block image.\n"); 433 rc = futil_get_file(BOOT_FILES_SRC "/boot/grub/i386-pc/boot.img", 718 434 &boot_img, &boot_img_size); 719 435 if (rc != EOK || boot_img_size != 512) 720 436 return EIO; 721 437 722 log_msg(LOG_DEFAULT, LVL_NOTE, 723 "sysinst_copy_boot_blocks: Read GRUB core image."); 724 725 rc = futil_get_file(sysinst->futil, 726 BOOT_FILES_SRC "/boot/grub/i386-pc/core.img", 438 printf("sysinst_copy_boot_blocks: Read GRUB core image.\n"); 439 rc = futil_get_file(BOOT_FILES_SRC "/boot/grub/i386-pc/core.img", 727 440 &core_img, &core_img_size); 728 441 if (rc != EOK) 729 442 return EIO; 730 443 731 log_msg(LOG_DEFAULT, LVL_NOTE, 732 "sysinst_copy_boot_blocks: get service ID."); 733 444 printf("sysinst_copy_boot_blocks: get service ID.\n"); 734 445 rc = loc_service_get_id(devp, &sid, 0); 735 446 if (rc != EOK) 736 447 return rc; 737 448 738 log_msg(LOG_DEFAULT, LVL_NOTE, 739 "sysinst_copy_boot_blocks: block_init."); 740 449 printf("sysinst_copy_boot_blocks: block_init.\n"); 741 450 rc = block_init(sid); 742 451 if (rc != EOK) 743 452 return rc; 744 453 745 log_msg(LOG_DEFAULT, LVL_NOTE, 746 "sysinst_copy_boot_blocks: get block size"); 747 454 printf("sysinst_copy_boot_blocks: get block size\n"); 748 455 rc = block_get_bsize(sid, &bsize); 749 456 if (rc != EOK) … … 751 458 752 459 if (bsize != 512) { 753 sysinst_error(sysinst, "Device block size != 512.");460 printf("Device block size != 512.\n"); 754 461 return EIO; 755 462 } 756 463 757 log_msg(LOG_DEFAULT, LVL_NOTE, 758 "sysinst_copy_boot_blocks: read boot block"); 759 464 printf("sysinst_copy_boot_blocks: read boot block\n"); 760 465 rc = block_read_direct(sid, BOOT_BLOCK_IDX, 1, bbuf); 761 466 if (rc != EOK) … … 772 477 --bl; 773 478 if ((void *)bl < core_img) { 774 sysinst_error(sysinst, 775 "No block terminator in core image."); 479 printf("No block terminator in core image.\n"); 776 480 return EIO; 777 481 } … … 787 491 set_unaligned_u64le(bbuf + grub_boot_machine_kernel_sector, core_start); 788 492 789 log_msg(LOG_DEFAULT, LVL_NOTE, 790 "sysinst_copy_boot_blocks: write boot block"); 791 493 printf("sysinst_copy_boot_blocks: write boot block\n"); 792 494 rc = block_write_direct(sid, BOOT_BLOCK_IDX, 1, bbuf); 793 495 if (rc != EOK) 794 496 return EIO; 795 497 796 log_msg(LOG_DEFAULT, LVL_NOTE, 797 "sysinst_copy_boot_blocks: write core blocks"); 798 498 printf("sysinst_copy_boot_blocks: write core blocks\n"); 799 499 /* XXX Must pad last block with zeros */ 800 500 rc = block_write_direct(sid, core_start, core_blocks, core_img); … … 802 502 return EIO; 803 503 804 log_msg(LOG_DEFAULT, LVL_NOTE, 805 "sysinst_copy_boot_blocks: OK."); 806 504 printf("sysinst_copy_boot_blocks: OK.\n"); 807 505 return EOK; 808 506 } … … 810 508 /** Eject installation volume. 811 509 * 812 * @param sysinst System installer813 510 * @param psvc_id Partition service ID 814 * @return EOK on success or an error code 815 */ 816 static errno_t sysinst_eject_dev(sysinst_t *sysinst, service_id_t part_id) 511 */ 512 static errno_t sysinst_eject_dev(service_id_t part_id) 817 513 { 818 514 vol_t *vol = NULL; … … 821 517 rc = vol_create(&vol); 822 518 if (rc != EOK) { 823 sysinst_error(sysinst, "Error contacting volume service.");519 printf("Error contacting volume service.\n"); 824 520 goto out; 825 521 } … … 827 523 rc = vol_part_eject(vol, part_id, vef_physical); 828 524 if (rc != EOK) { 829 sysinst_error(sysinst, "Error ejecting volume.");525 printf("Error ejecting volume.\n"); 830 526 goto out; 831 527 } … … 839 535 /** Restart the system. 840 536 * 841 * @param sysinst System installer 842 * @return EOK on success or an error code 843 */ 844 static errno_t sysinst_restart(sysinst_t *sysinst) 537 * @return EOK on success or an error code 538 */ 539 static errno_t sysinst_restart(void) 845 540 { 846 541 errno_t rc; … … 854 549 rc = system_open(SYSTEM_DEFAULT, &sysinst_system_cb, NULL, &system); 855 550 if (rc != EOK) { 856 sysinst_error(sysinst, 857 "Failed opening system control service."); 551 printf("Failed opening system control service.\n"); 858 552 return rc; 859 553 } … … 862 556 if (rc != EOK) { 863 557 system_close(system); 864 sysinst_error(sysinst, "Failed requesting system restart.");558 printf("Failed requesting system restart.\n"); 865 559 return rc; 866 560 } 867 561 868 562 fibril_mutex_lock(&shutdown_lock); 869 sysinst_debug(sysinst, "The system is shutting down..."); 870 563 printf("The system is shutting down...\n"); 871 564 while (!shutdown_stopped) 872 565 fibril_condvar_wait(&shutdown_cv, &shutdown_lock); 873 566 874 567 if (shutdown_failed) { 875 sysinst_error(sysinst, "Shutdown failed.");568 printf("Shutdown failed.\n"); 876 569 system_close(system); 877 570 return rc; 878 571 } 879 572 880 log_msg(LOG_DEFAULT, LVL_NOTE, 881 "Shutdown complete. It is now safe to remove power."); 573 printf("Shutdown complete. It is now safe to remove power.\n"); 882 574 883 575 /* Sleep forever */ … … 894 586 /** Install system to a device. 895 587 * 896 * @parma sysinst System installer897 588 * @param dev Device to install to. 898 589 * @return EOK on success or an error code 899 590 */ 900 static errno_t sysinst_install( sysinst_t *sysinst,const char *dev)591 static errno_t sysinst_install(const char *dev) 901 592 { 902 593 errno_t rc; 903 594 service_id_t psvc_id; 904 595 905 sysinst_action(sysinst, "Creating device label and file system."); 906 907 rc = sysinst_label_dev(sysinst, dev, &psvc_id); 908 if (rc != EOK) 909 return rc; 910 911 sysinst_action(sysinst, "Creating system directory structure."); 912 rc = sysinst_setup_sysvol(sysinst); 913 if (rc != EOK) 914 return rc; 915 916 sysinst_action(sysinst, "Copying boot files."); 917 rc = sysinst_copy_boot_files(sysinst); 918 if (rc != EOK) 919 return rc; 920 921 sysinst_action(sysinst, "Configuring the system."); 922 rc = sysinst_customize_initrd(sysinst); 923 if (rc != EOK) 924 return rc; 925 926 sysinst_action(sysinst, "Installing boot blocks."); 927 rc = sysinst_copy_boot_blocks(sysinst, dev); 928 if (rc != EOK) 929 return rc; 930 931 sysinst_action(sysinst, "Ejecting device."); 932 rc = sysinst_eject_dev(sysinst, psvc_id); 596 rc = sysinst_label_dev(dev, &psvc_id); 597 if (rc != EOK) 598 return rc; 599 600 printf("FS created and mounted. Creating system directory structure.\n"); 601 rc = sysinst_setup_sysvol(); 602 if (rc != EOK) 603 return rc; 604 605 printf("Directories created. Copying boot files.\n"); 606 rc = sysinst_copy_boot_files(); 607 if (rc != EOK) 608 return rc; 609 610 printf("Boot files done. Configuring the system.\n"); 611 rc = sysinst_customize_initrd(); 612 if (rc != EOK) 613 return rc; 614 615 printf("Boot files done. Installing boot blocks.\n"); 616 rc = sysinst_copy_boot_blocks(dev); 617 if (rc != EOK) 618 return rc; 619 620 printf("Ejecting device.\n"); 621 rc = sysinst_eject_dev(psvc_id); 622 if (rc != EOK) 623 return rc; 624 625 rc = sysinst_restart(); 933 626 if (rc != EOK) 934 627 return rc; … … 937 630 } 938 631 939 /** Installation fibril. 940 * 941 * @param arg Argument (sysinst_t *) 942 * @return EOK on success or an error code 943 */ 944 static errno_t sysinst_install_fibril(void *arg) 945 { 946 sysinst_t *sysinst = (sysinst_t *)arg; 632 int main(int argc, char *argv[]) 633 { 947 634 unsigned i; 948 635 errno_t rc; 949 636 950 (void)sysinst; 637 if (argc > 1 && str_cmp(argv[1], "-r") == 0) 638 restart = true; 951 639 952 640 i = 0; … … 959 647 960 648 if (default_devs[i] == NULL) { 961 sysinst_error(sysinst, "Cannot determine installation device."); 962 rc = ENOENT; 963 goto error; 964 } 965 966 rc = sysinst_install(sysinst, default_devs[i]); 967 if (rc != EOK) 968 goto error; 969 970 sysinst_progress_destroy(sysinst->progress); 971 rc = sysinst_restart_dlg_create(sysinst); 972 if (rc != EOK) 973 goto error; 974 975 return EOK; 976 error: 977 ui_lock(sysinst->ui); 978 sysinst_progress_destroy(sysinst->progress); 979 (void)sysinst_error_msg_create(sysinst); 980 ui_unlock(sysinst->ui); 981 return rc; 982 } 983 984 /** Create installation progress window. 985 * 986 * @param sysinst System installer 987 * @param rprogress Place to store pointer to new progress window 988 * @return EOK on success or an error code 989 */ 990 static errno_t sysinst_progress_create(sysinst_t *sysinst, 991 sysinst_progress_t **rprogress) 992 { 993 ui_wnd_params_t params; 994 ui_window_t *window = NULL; 995 gfx_rect_t rect; 996 gfx_rect_t arect; 997 ui_resource_t *ui_res; 998 sysinst_progress_t *progress; 999 ui_fixed_t *fixed = NULL; 1000 errno_t rc; 1001 1002 ui_wnd_params_init(¶ms); 1003 params.caption = "System Installation"; 1004 params.style &= ~ui_wds_titlebar; 1005 params.flags |= ui_wndf_topmost; 1006 params.placement = ui_wnd_place_center; 1007 if (ui_is_textmode(sysinst->ui)) { 1008 params.rect.p0.x = 0; 1009 params.rect.p0.y = 0; 1010 params.rect.p1.x = 64; 1011 params.rect.p1.y = 5; 1012 } else { 1013 params.rect.p0.x = 0; 1014 params.rect.p0.y = 0; 1015 params.rect.p1.x = 500; 1016 params.rect.p1.y = 60; 1017 } 1018 1019 progress = calloc(1, sizeof(sysinst_progress_t)); 1020 if (progress == NULL) { 1021 rc = ENOMEM; 1022 sysinst_error(sysinst, "Out of memory."); 1023 goto error; 1024 } 1025 1026 rc = ui_window_create(sysinst->ui, ¶ms, &window); 1027 if (rc != EOK) { 1028 sysinst_error(sysinst, "Error creating window."); 1029 goto error; 1030 } 1031 1032 ui_window_set_cb(window, &progress_window_cb, (void *)sysinst); 1033 1034 ui_res = ui_window_get_res(window); 1035 1036 rc = ui_fixed_create(&fixed); 1037 if (rc != EOK) { 1038 sysinst_error(sysinst, "Error creating fixed layout."); 1039 goto error; 1040 } 1041 1042 rc = ui_label_create(ui_res, "Installing system. Please wait...", 1043 &progress->label); 1044 if (rc != EOK) { 1045 sysinst_error(sysinst, "Error creating label."); 1046 goto error; 1047 } 1048 1049 ui_window_get_app_rect(window, &arect); 1050 1051 if (ui_is_textmode(sysinst->ui)) { 1052 rect.p0.x = arect.p0.x; 1053 rect.p0.y = arect.p0.y; 1054 rect.p1.x = arect.p1.x; 1055 rect.p1.y = 2; 1056 } else { 1057 rect.p0.x = arect.p0.x; 1058 rect.p0.y = arect.p0.y; 1059 rect.p1.x = arect.p1.x; 1060 rect.p1.y = 30; 1061 } 1062 ui_label_set_rect(progress->label, &rect); 1063 ui_label_set_halign(progress->label, gfx_halign_center); 1064 ui_label_set_valign(progress->label, gfx_valign_center); 1065 1066 rc = ui_fixed_add(fixed, ui_label_ctl(progress->label)); 1067 if (rc != EOK) { 1068 sysinst_error(sysinst, "Error adding control to layout."); 1069 ui_label_destroy(progress->label); 1070 progress->label = NULL; 1071 goto error; 1072 } 1073 1074 rc = ui_label_create(ui_res, "", 1075 &progress->action); 1076 if (rc != EOK) { 1077 sysinst_error(sysinst, "Error creating label."); 1078 goto error; 1079 } 1080 1081 if (ui_is_textmode(sysinst->ui)) { 1082 rect.p0.x = arect.p0.x; 1083 rect.p0.y = 3; 1084 rect.p1.x = arect.p1.x; 1085 rect.p1.y = arect.p1.y; 1086 } else { 1087 rect.p0.x = arect.p0.x; 1088 rect.p0.y = 30; 1089 rect.p1.x = arect.p1.x; 1090 rect.p1.y = arect.p1.y; 1091 } 1092 ui_label_set_rect(progress->action, &rect); 1093 ui_label_set_halign(progress->action, gfx_halign_center); 1094 ui_label_set_valign(progress->action, gfx_valign_center); 1095 1096 rc = ui_fixed_add(fixed, ui_label_ctl(progress->action)); 1097 if (rc != EOK) { 1098 sysinst_error(sysinst, "Error adding control to layout."); 1099 ui_label_destroy(progress->label); 1100 progress->label = NULL; 1101 goto error; 1102 } 1103 1104 ui_window_add(window, ui_fixed_ctl(fixed)); 1105 fixed = NULL; 1106 1107 rc = ui_window_paint(window); 1108 if (rc != EOK) { 1109 sysinst_error(sysinst, "Error painting window."); 1110 goto error; 1111 } 1112 1113 progress->window = window; 1114 progress->fixed = fixed; 1115 *rprogress = progress; 1116 return EOK; 1117 error: 1118 if (progress != NULL && progress->fixed != NULL) 1119 ui_fixed_destroy(progress->fixed); 1120 if (window != NULL) 1121 ui_window_destroy(window); 1122 if (progress != NULL) 1123 free(progress); 1124 return rc; 1125 } 1126 1127 /** Destroy installation progress window. 1128 * 1129 * @param sysinst System installer 1130 * @param rprogress Place to store pointer to new progress window 1131 * @return EOK on success or an error code 1132 */ 1133 static void sysinst_progress_destroy(sysinst_progress_t *progress) 1134 { 1135 if (progress == NULL) 1136 return; 1137 1138 ui_window_destroy(progress->window); 1139 free(progress); 1140 } 1141 1142 /** Set current action message. 1143 * 1144 * @param sysinst System installer 1145 * @param action Action text 1146 */ 1147 static void sysinst_action(sysinst_t *sysinst, const char *action) 1148 { 1149 if (sysinst->progress == NULL) 1150 return; 1151 1152 ui_label_set_text(sysinst->progress->action, action); 1153 ui_label_paint(sysinst->progress->action); 1154 log_msg(LOG_DEFAULT, LVL_NOTE, "%s", action); 1155 } 1156 1157 /** Set current error message. 1158 * 1159 * @param sysinst System installer 1160 * @param errmsg Error message 1161 */ 1162 static void sysinst_error(sysinst_t *sysinst, const char *errmsg) 1163 { 1164 str_cpy(sysinst->errmsg, sizeof(sysinst->errmsg), errmsg); 1165 log_msg(LOG_DEFAULT, LVL_ERROR, errmsg); 1166 } 1167 1168 /** Log a debug message. 1169 * 1170 * @param sysinst System installer 1171 * @param errmsg Error message 1172 */ 1173 static void sysinst_debug(sysinst_t *sysinst, const char *msg) 1174 { 1175 log_msg(LOG_DEFAULT, LVL_ERROR, msg); 1176 } 1177 1178 /** Start system installation. 1179 * 1180 * @param sysinst System installer 1181 * @return EOK on success or an error code 1182 */ 1183 static int sysinst_start(sysinst_t *sysinst) 1184 { 1185 errno_t rc; 1186 fid_t fid; 1187 1188 rc = sysinst_progress_create(sysinst, &sysinst->progress); 1189 if (rc != EOK) 1190 return rc; 1191 1192 fid = fibril_create(sysinst_install_fibril, (void *)sysinst); 1193 if (fid == 0) { 1194 sysinst_error(sysinst, "Out of memory."); 1195 return ENOMEM; 1196 } 1197 1198 fibril_add_ready(fid); 1199 return EOK; 1200 } 1201 1202 /** Create installation confirmation dialog. 1203 * 1204 * @param sysinst System installer 1205 * @return EOK on success or an error code 1206 */ 1207 static errno_t sysinst_confirm_create(sysinst_t *sysinst) 1208 { 1209 ui_msg_dialog_params_t params; 1210 ui_msg_dialog_t *dialog; 1211 errno_t rc; 1212 1213 ui_msg_dialog_params_init(¶ms); 1214 params.caption = "System installation"; 1215 params.text = "This will install HelenOS to your computer. Continue?"; 1216 params.choice = umdc_ok_cancel; 1217 params.flags |= umdf_topmost | umdf_center; 1218 1219 rc = ui_msg_dialog_create(sysinst->ui, ¶ms, &dialog); 1220 if (rc != EOK) 1221 return rc; 1222 1223 ui_msg_dialog_set_cb(dialog, &sysinst_confirm_cb, sysinst); 1224 return EOK; 1225 } 1226 1227 /** Create restart dialog. 1228 * 1229 * @param sysinst System installer 1230 * @return EOK on success or an error code 1231 */ 1232 static errno_t sysinst_restart_dlg_create(sysinst_t *sysinst) 1233 { 1234 ui_msg_dialog_params_t params; 1235 ui_msg_dialog_t *dialog; 1236 errno_t rc; 1237 1238 ui_msg_dialog_params_init(¶ms); 1239 params.caption = "Restart System"; 1240 params.text = "Installation complete. Restart the system?"; 1241 params.choice = umdc_ok_cancel; 1242 params.flags |= umdf_topmost | umdf_center; 1243 1244 rc = ui_msg_dialog_create(sysinst->ui, ¶ms, &dialog); 1245 if (rc != EOK) 1246 return rc; 1247 1248 ui_msg_dialog_set_cb(dialog, &sysinst_restart_dlg_cb, sysinst); 1249 return EOK; 1250 } 1251 1252 /** Run system installer on display. 1253 * 1254 * @param display_spec Display specification 1255 * @return EOK on success or an error code 1256 */ 1257 static errno_t sysinst_run(const char *display_spec) 1258 { 1259 ui_t *ui = NULL; 1260 sysinst_t *sysinst; 1261 ui_wnd_params_t params; 1262 errno_t rc; 1263 1264 sysinst = calloc(1, sizeof(sysinst_t)); 1265 if (sysinst == NULL) 1266 return ENOMEM; 1267 1268 rc = futil_create(&sysinst_futil_cb, (void *)sysinst, &sysinst->futil); 1269 if (rc != EOK) { 1270 printf("Out of memory.\n"); 1271 goto error; 1272 } 1273 1274 rc = ui_create(display_spec, &ui); 1275 if (rc != EOK) { 1276 printf("Error creating UI on display %s.\n", display_spec); 1277 goto error; 1278 } 1279 1280 sysinst->ui = ui; 1281 1282 ui_wnd_params_init(¶ms); 1283 params.caption = "System Installation"; 1284 params.style &= ~ui_wds_decorated; 1285 params.placement = ui_wnd_place_full_screen; 1286 params.flags |= ui_wndf_topmost | ui_wndf_nofocus; 1287 1288 rc = ui_window_create(sysinst->ui, ¶ms, &sysinst->bgwindow); 1289 if (rc != EOK) { 1290 printf("Error creating window.\n"); 1291 goto error; 1292 } 1293 1294 ui_window_set_cb(sysinst->bgwindow, &bg_window_cb, (void *)sysinst); 1295 1296 if (ui_is_textmode(sysinst->ui)) { 1297 rc = gfx_color_new_ega(0x17, &sysinst->bg_color); 1298 if (rc != EOK) { 1299 printf("Error allocating color.\n"); 1300 goto error; 1301 } 1302 } else { 1303 rc = gfx_color_new_rgb_i16(0x8000, 0xc800, 0xffff, &sysinst->bg_color); 1304 if (rc != EOK) { 1305 printf("Error allocating color.\n"); 1306 goto error; 1307 } 1308 } 1309 1310 rc = ui_window_paint(sysinst->bgwindow); 1311 if (rc != EOK) { 1312 printf("Error painting window.\n"); 1313 goto error; 1314 } 1315 1316 (void)sysinst_confirm_create(sysinst); 1317 1318 ui_run(ui); 1319 1320 if (sysinst->bgwindow != NULL) 1321 ui_window_destroy(sysinst->bgwindow); 1322 if (sysinst->system != NULL) 1323 system_close(sysinst->system); 1324 gfx_color_delete(sysinst->bg_color); 1325 ui_destroy(ui); 1326 free(sysinst); 1327 return EOK; 1328 error: 1329 if (sysinst->futil != NULL) 1330 futil_destroy(sysinst->futil); 1331 if (sysinst->system != NULL) 1332 system_close(sysinst->system); 1333 if (sysinst->bg_color != NULL) 1334 gfx_color_delete(sysinst->bg_color); 1335 if (sysinst->bgwindow != NULL) 1336 ui_window_destroy(sysinst->bgwindow); 1337 if (ui != NULL) 1338 ui_destroy(ui); 1339 free(sysinst); 1340 return rc; 1341 } 1342 1343 static void print_syntax(void) 1344 { 1345 printf("Syntax: " NAME " [-d <display-spec>]\n"); 1346 } 1347 1348 int main(int argc, char *argv[]) 1349 { 1350 const char *display_spec = UI_ANY_DEFAULT; 1351 errno_t rc; 1352 int i; 1353 1354 i = 1; 1355 while (i < argc && argv[i][0] == '-') { 1356 if (str_cmp(argv[i], "-d") == 0) { 1357 ++i; 1358 if (i >= argc) { 1359 printf("Argument missing.\n"); 1360 print_syntax(); 1361 return 1; 1362 } 1363 1364 display_spec = argv[i++]; 1365 } else { 1366 printf("Invalid option '%s'.\n", argv[i]); 1367 print_syntax(); 1368 return 1; 1369 } 1370 } 1371 1372 if (i < argc) { 1373 print_syntax(); 649 printf("Cannot determine installation device.\n"); 1374 650 return 1; 1375 651 } 1376 652 1377 if (log_init(NAME) != EOK) { 1378 printf(NAME ": Failed to initialize logging.\n"); 1379 return 1; 1380 } 1381 1382 rc = sysinst_run(display_spec); 1383 if (rc != EOK) 1384 return 1; 1385 1386 return 0; 653 return sysinst_install(default_devs[i]); 1387 654 } 1388 655 -
uspace/app/taskbar/taskbar.sif
r3acb63b5 r9f945464 33 33 <entry caption="~F~disk Disk Editor" cmd="/app/fdisk" terminal="y"> 34 34 </entry> 35 <entry caption="Insta~l~l HelenOS to Disk" cmd="/app/sysinst -d %d" terminal="n">36 </entry>37 35 <entry separator="y"> 38 36 </entry> -
uspace/lib/futil/include/futil.h
r3acb63b5 r9f945464 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 38 38 #define FUTIL_H 39 39 40 #include <errno.h>41 40 #include <stddef.h> 42 #include "types/futil.h"43 41 44 extern errno_t futil_create(futil_cb_t *, void *, futil_t **); 45 extern void futil_destroy(futil_t *); 46 extern errno_t futil_copy_file(futil_t *, const char *, const char *); 47 extern errno_t futil_rcopy_contents(futil_t *, const char *, const char *); 48 extern errno_t futil_get_file(futil_t *, const char *, void **, size_t *); 42 extern errno_t futil_copy_file(const char *, const char *); 43 extern errno_t futil_rcopy_contents(const char *, const char *); 44 extern errno_t futil_get_file(const char *, void **, size_t *); 49 45 50 46 #endif -
uspace/lib/futil/src/futil.c
r3acb63b5 r9f945464 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 47 47 static char buf[BUF_SIZE]; 48 48 49 /** Create file utility instance.50 *51 * @param cb Callback functions52 * @param arg Argument to callback functions53 * @param rfutil Place to store pointer to new file utility instance54 * @return EOK on succcess, ENOMEM if out of memory.55 */56 errno_t futil_create(futil_cb_t *cb, void *arg, futil_t **rfutil)57 {58 futil_t *futil;59 60 futil = calloc(1, sizeof(futil_t));61 if (futil == NULL)62 return ENOMEM;63 64 futil->cb = cb;65 futil->cb_arg = arg;66 *rfutil = futil;67 return EOK;68 }69 70 /** Destroy file utility instance.71 *72 * @param futil File utility instance73 */74 void futil_destroy(futil_t *futil)75 {76 free(futil);77 }78 79 49 /** Copy file. 80 50 * 81 * @param futil File utility instance82 51 * @param srcp Source path 83 52 * @param dstp Destination path … … 85 54 * @return EOK on success, EIO on I/O error 86 55 */ 87 errno_t futil_copy_file( futil_t *futil,const char *srcp, const char *destp)56 errno_t futil_copy_file(const char *srcp, const char *destp) 88 57 { 89 58 int sf, df; … … 92 61 aoff64_t posr = 0, posw = 0; 93 62 94 if (futil->cb != NULL && futil->cb->copy_file != NULL) 95 futil->cb->copy_file(futil->cb_arg, srcp, destp); 63 printf("Copy '%s' to '%s'.\n", srcp, destp); 96 64 97 65 rc = vfs_lookup_open(srcp, WALK_REGULAR, MODE_READ, &sf); … … 131 99 /** Copy contents of srcdir (recursively) into destdir. 132 100 * 133 * @param futil File utility instance134 101 * @param srcdir Source directory 135 102 * @param destdir Destination directory … … 137 104 * @return EOK on success, ENOMEM if out of memory, EIO on I/O error 138 105 */ 139 errno_t futil_rcopy_contents(futil_t *futil, const char *srcdir, 140 const char *destdir) 106 errno_t futil_rcopy_contents(const char *srcdir, const char *destdir) 141 107 { 142 108 DIR *dir; … … 162 128 163 129 if (s.is_file) { 164 rc = futil_copy_file( futil,srcp, destp);130 rc = futil_copy_file(srcp, destp); 165 131 if (rc != EOK) 166 132 return EIO; 167 133 } else if (s.is_directory) { 168 if (futil->cb != NULL && futil->cb->create_dir != NULL) 169 futil->cb->create_dir(futil->cb_arg, destp); 134 printf("Create directory '%s'\n", destp); 170 135 rc = vfs_link_path(destp, KIND_DIRECTORY, NULL); 171 136 if (rc != EOK) 172 137 return EIO; 173 rc = futil_rcopy_contents( futil,srcp, destp);138 rc = futil_rcopy_contents(srcp, destp); 174 139 if (rc != EOK) 175 140 return EIO; … … 186 151 /** Return file contents as a heap-allocated block of bytes. 187 152 * 188 * @param futil File utility instance189 153 * @param srcp File path 190 154 * @param rdata Place to store pointer to data … … 194 158 * I/O error, ENOMEM if out of memory 195 159 */ 196 errno_t futil_get_file(futil_t *futil, const char *srcp, void **rdata, 197 size_t *rsize) 160 errno_t futil_get_file(const char *srcp, void **rdata, size_t *rsize) 198 161 { 199 162 int sf; -
uspace/lib/ui/src/msgdialog.c
r3acb63b5 r9f945464 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 125 125 wparams.rect.p0.x = 0; 126 126 wparams.rect.p0.y = 0; 127 wparams.rect.p1.x = 4 40;127 wparams.rect.p1.x = 400; 128 128 wparams.rect.p1.y = 110; 129 129 } … … 154 154 rect.p0.x = 10; 155 155 rect.p0.y = 35; 156 rect.p1.x = 430;156 rect.p1.x = 390; 157 157 rect.p1.y = 50; 158 158 } -
uspace/srv/system/system.c
r3acb63b5 r9f945464 328 328 size_t nparts; 329 329 bool sv_mounted; 330 futil_t *futil = NULL;331 330 size_t i; 332 331 errno_t rc; … … 381 380 382 381 /* Copy initial configuration files */ 383 rc = futil_ create(NULL, NULL, &futil);382 rc = futil_rcopy_contents("/cfg", "/w/cfg"); 384 383 if (rc != EOK) 385 384 goto error; 386 387 rc = futil_rcopy_contents(futil, "/cfg", "/w/cfg");388 if (rc != EOK)389 goto error;390 391 futil_destroy(futil);392 futil = NULL;393 385 } else { 394 386 printf("%s: System volume is configured.\n", NAME); … … 437 429 if (part_ids != NULL) 438 430 free(part_ids); 439 if (futil != NULL)440 futil_destroy(futil);441 431 442 432 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.