Changeset 514108e in mainline
- Timestamp:
- 2024-10-15T08:31:11Z (3 months ago)
- Branches:
- master
- Children:
- 9d5cea6
- Parents:
- 6fbd1f9
- git-author:
- Jiri Svoboda <jiri@…> (2024-10-14 18:30:59)
- git-committer:
- Jiri Svoboda <jiri@…> (2024-10-15 08:31:11)
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
meson/part/initrd_manifest/meson.build
r6fbd1f9 r514108e 1 1 # 2 # Copyright (c) 2024 Jiri Svoboda 2 3 # Copyright (c) 2019 Jiří Zárevúcky 3 4 # All rights reserved. … … 57 58 'srv/hid/output', 58 59 'srv/klog', 60 'srv/system', 59 61 ] 60 62 -
uspace/app/init/init.c
r6fbd1f9 r514108e 35 35 */ 36 36 37 #include <fibril.h>38 #include <futil.h>39 37 #include <stdio.h> 40 38 #include <stdarg.h> … … 48 46 #include <loc.h> 49 47 #include <str_error.h> 50 #include <config.h>51 48 #include <io/logctl.h> 52 49 #include <vfs/vfs.h> 53 #include <vol.h>54 50 #include "untar.h" 55 51 #include "init.h" … … 61 57 #define ROOT_MOUNT_POINT "/" 62 58 63 #define LOCFS_FS_TYPE "locfs"64 #define LOCFS_MOUNT_POINT "/loc"65 66 #define TMPFS_FS_TYPE "tmpfs"67 #define TMPFS_MOUNT_POINT "/tmp"68 69 #define SRV_CONSOLE "/srv/hid/console"70 #define APP_GETTERM "/app/getterm"71 72 #define SRV_DISPLAY "/srv/hid/display"73 74 #define HID_INPUT "hid/input"75 #define HID_OUTPUT "hid/output"76 77 59 #define srv_start(path, ...) \ 78 60 srv_startl(path, path, ##__VA_ARGS__, NULL) 79 80 static const char *sys_dirs[] = {81 "/w/cfg",82 "/w/data",83 NULL,84 };85 61 86 62 /** Print banner */ … … 174 150 } 175 151 176 /** Mount locfs file system177 *178 * The operation blocks until the locfs file system179 * server is ready for mounting.180 *181 * @return True on success.182 * @return False on failure.183 *184 */185 static bool mount_locfs(void)186 {187 errno_t rc = vfs_mount_path(LOCFS_MOUNT_POINT, LOCFS_FS_TYPE, "", "",188 IPC_FLAG_BLOCKING, 0);189 return mount_report("Location service file system", LOCFS_MOUNT_POINT,190 LOCFS_FS_TYPE, NULL, rc);191 }192 193 152 static errno_t srv_startl(const char *path, ...) 194 153 { … … 253 212 } 254 213 255 static errno_t console(const char *isvc, const char *osvc)256 {257 /* Wait for the input service to be ready */258 service_id_t service_id;259 errno_t rc = loc_service_get_id(isvc, &service_id, IPC_FLAG_BLOCKING);260 if (rc != EOK) {261 printf("%s: Error waiting on %s (%s)\n", NAME, isvc,262 str_error(rc));263 return rc;264 }265 266 /* Wait for the output service to be ready */267 rc = loc_service_get_id(osvc, &service_id, IPC_FLAG_BLOCKING);268 if (rc != EOK) {269 printf("%s: Error waiting on %s (%s)\n", NAME, osvc,270 str_error(rc));271 return rc;272 }273 274 return srv_start(SRV_CONSOLE, isvc, osvc);275 }276 277 #ifdef CONFIG_WINSYS278 279 static errno_t display_server(void)280 {281 return srv_start(SRV_DISPLAY);282 }283 284 static int app_start(const char *app, const char *arg)285 {286 printf("%s: Spawning %s\n", NAME, app);287 288 task_id_t id;289 task_wait_t wait;290 errno_t rc = task_spawnl(&id, &wait, app, app, arg, NULL);291 if (rc != EOK) {292 oom_check(rc, app);293 printf("%s: Error spawning %s (%s)\n", NAME, app,294 str_error(rc));295 return -1;296 }297 298 task_exit_t texit;299 int retval;300 rc = task_wait(&wait, &texit, &retval);301 if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {302 printf("%s: Error retrieving retval from %s (%s)\n", NAME,303 app, str_error(rc));304 return rc;305 }306 307 return retval;308 }309 310 #endif311 312 static void getterm(const char *svc, const char *app, bool msg)313 {314 if (msg) {315 printf("%s: Spawning %s %s %s --msg --wait -- %s\n", NAME,316 APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);317 318 errno_t rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,319 LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);320 if (rc != EOK) {321 oom_check(rc, APP_GETTERM);322 printf("%s: Error spawning %s %s %s --msg --wait -- %s\n",323 NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);324 }325 } else {326 printf("%s: Spawning %s %s %s --wait -- %s\n", NAME,327 APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);328 329 errno_t rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,330 LOCFS_MOUNT_POINT, "--wait", "--", app, NULL);331 if (rc != EOK) {332 oom_check(rc, APP_GETTERM);333 printf("%s: Error spawning %s %s %s --wait -- %s\n",334 NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);335 }336 }337 }338 339 static bool mount_tmpfs(void)340 {341 errno_t rc = vfs_mount_path(TMPFS_MOUNT_POINT, TMPFS_FS_TYPE, "", "", 0, 0);342 return mount_report("Temporary file system", TMPFS_MOUNT_POINT,343 TMPFS_FS_TYPE, NULL, rc);344 }345 346 /** Init system volume.347 *348 * See if system volume is configured. If so, try to wait for it to become349 * available. If not, create basic directories for live image omde.350 */351 static errno_t init_sysvol(void)352 {353 vol_t *vol = NULL;354 vol_info_t vinfo;355 volume_id_t *volume_ids = NULL;356 service_id_t *part_ids = NULL;357 vol_part_info_t pinfo;358 size_t nvols;359 size_t nparts;360 bool sv_mounted;361 size_t i;362 errno_t rc;363 bool found_cfg;364 const char **cp;365 366 rc = vol_create(&vol);367 if (rc != EOK) {368 printf("Error contacting volume service.\n");369 goto error;370 }371 372 rc = vol_get_volumes(vol, &volume_ids, &nvols);373 if (rc != EOK) {374 printf("Error getting list of volumes.\n");375 goto error;376 }377 378 /* XXX This could be handled more efficiently by volsrv itself */379 found_cfg = false;380 for (i = 0; i < nvols; i++) {381 rc = vol_info(vol, volume_ids[i], &vinfo);382 if (rc != EOK) {383 printf("Error getting volume information.\n");384 rc = EIO;385 goto error;386 }387 388 if (str_cmp(vinfo.path, "/w") == 0) {389 found_cfg = true;390 break;391 }392 }393 394 free(volume_ids);395 volume_ids = NULL;396 397 if (!found_cfg) {398 /* Prepare directory structure for live image mode */399 printf("%s: Creating live image directory structure.\n", NAME);400 cp = sys_dirs;401 while (*cp != NULL) {402 rc = vfs_link_path(*cp, KIND_DIRECTORY, NULL);403 if (rc != EOK) {404 printf("%s: Error creating directory '%s'.\n",405 NAME, *cp);406 goto error;407 }408 409 ++cp;410 }411 412 /* Copy initial configuration files */413 rc = futil_rcopy_contents("/cfg", "/w/cfg");414 if (rc != EOK)415 goto error;416 } else {417 printf("%s: System volume is configured.\n", NAME);418 419 /* Wait until system volume is mounted */420 sv_mounted = false;421 422 while (true) {423 rc = vol_get_parts(vol, &part_ids, &nparts);424 if (rc != EOK) {425 printf("Error getting list of volumes.\n");426 goto error;427 }428 429 for (i = 0; i < nparts; i++) {430 rc = vol_part_info(vol, part_ids[i], &pinfo);431 if (rc != EOK) {432 printf("Error getting partition "433 "information.\n");434 rc = EIO;435 goto error;436 }437 438 if (str_cmp(pinfo.cur_mp, "/w") == 0) {439 sv_mounted = true;440 break;441 }442 }443 444 if (sv_mounted)445 break;446 447 free(part_ids);448 part_ids = NULL;449 450 fibril_sleep(1);451 printf("Sleeping(1) for system volume.\n");452 }453 }454 455 vol_destroy(vol);456 return EOK;457 error:458 vol_destroy(vol);459 if (volume_ids != NULL)460 free(volume_ids);461 if (part_ids != NULL)462 free(part_ids);463 464 return rc;465 }466 467 214 int main(int argc, char *argv[]) 468 215 { 469 errno_t rc;470 471 216 info_print(); 472 217 … … 476 221 } 477 222 478 /* Make sure file systems are running. */ 479 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) 480 srv_start("/srv/fs/tmpfs"); 481 if (str_cmp(STRING(RDFMT), "exfat") != 0) 482 srv_start("/srv/fs/exfat"); 483 if (str_cmp(STRING(RDFMT), "fat") != 0) 484 srv_start("/srv/fs/fat"); 485 srv_start("/srv/fs/cdfs"); 486 srv_start("/srv/fs/mfs"); 487 488 srv_start("/srv/klog"); 489 srv_start("/srv/fs/locfs"); 490 491 if (!mount_locfs()) { 492 printf("%s: Exiting\n", NAME); 493 return 2; 494 } 495 496 mount_tmpfs(); 497 498 srv_start("/srv/devman"); 499 srv_start("/srv/hid/s3c24xx_uart"); 500 srv_start("/srv/hid/s3c24xx_ts"); 501 502 srv_start("/srv/bd/vbd"); 503 srv_start("/srv/volsrv"); 504 505 init_sysvol(); 506 507 srv_start("/srv/taskmon"); 508 509 srv_start("/srv/net/loopip"); 510 srv_start("/srv/net/ethip"); 511 srv_start("/srv/net/dhcp"); 512 srv_start("/srv/net/inetsrv"); 513 srv_start("/srv/net/tcp"); 514 srv_start("/srv/net/udp"); 515 srv_start("/srv/net/dnsrsrv"); 516 517 srv_start("/srv/clipboard"); 518 srv_start("/srv/hid/remcons"); 519 520 srv_start("/srv/hid/input", HID_INPUT); 521 srv_start("/srv/hid/output", HID_OUTPUT); 522 srv_start("/srv/audio/hound"); 523 524 #ifdef CONFIG_WINSYS 525 if (!config_key_exists("console")) { 526 rc = display_server(); 527 if (rc == EOK) { 528 app_start("/app/taskbar", NULL); 529 app_start("/app/terminal", "-topleft"); 530 } 531 } 532 #endif 533 rc = console(HID_INPUT, HID_OUTPUT); 534 if (rc == EOK) { 535 getterm("term/vc0", "/app/bdsh", true); 536 getterm("term/vc1", "/app/bdsh", false); 537 getterm("term/vc2", "/app/bdsh", false); 538 getterm("term/vc3", "/app/bdsh", false); 539 getterm("term/vc4", "/app/bdsh", false); 540 getterm("term/vc5", "/app/bdsh", false); 541 } 542 223 /* System server takes over once root is mounted */ 224 srv_start("/srv/system"); 543 225 return 0; 544 226 } -
uspace/app/init/meson.build
r6fbd1f9 r514108e 1 1 # 2 # Copyright (c) 2024 Jiri Svoboda 2 3 # Copyright (c) 2005 Martin Decky 3 4 # Copyright (c) 2007 Jakub Jermar … … 28 29 # 29 30 30 deps = [ 'block', ' futil', 'untar' ]31 deps = [ 'block', 'untar' ] 31 32 link_args += '-static' 32 33 src = files('init.c', 'untar.c') -
uspace/srv/meson.build
r6fbd1f9 r514108e 1 1 # 2 # Copyright (c) 2024 Jiri Svoboda 2 3 # Copyright (c) 2019 Jiří Zárevúcky 3 4 # All rights reserved. … … 65 66 'net/udp', 66 67 'ns', 68 'system', 67 69 'taskmon', 68 70 'test/chardev-test',
Note:
See TracChangeset
for help on using the changeset viewer.