status_t PackageSettings::Load(dev_t mountPointDeviceID, ino_t mountPointNodeID, PackageFSMountType mountType) { status_t error = fPackageItems.Init(); if (error != B_OK) RETURN_ERROR(error); // get the mount point relative settings file path const char* settingsFilePath = mountType == PACKAGE_FS_MOUNT_TYPE_HOME ? kUserSettingsGlobalDirectory "/packages" + strlen(kUserConfigDirectory) + 1 : kSystemSettingsDirectory "/packages" + strlen(kSystemDirectory) + 1; // get an absolute path KPath path; if (path.InitCheck() != B_OK) RETURN_ERROR(path.InitCheck()); error = vfs_entry_ref_to_path(mountPointDeviceID, mountPointNodeID, NULL, true, path.LockBuffer(), path.BufferSize()); if (error != B_OK) return error; path.UnlockBuffer(); error = path.Append(settingsFilePath); if (error != B_OK) return error; // load the driver settings void* settingsHandle = load_driver_settings(path.Path()); if (settingsHandle == NULL) return B_ENTRY_NOT_FOUND; CObjectDeleter<void, status_t> settingsDeleter(settingsHandle, &unload_driver_settings); const driver_settings* settings = get_driver_settings(settingsHandle); for (int i = 0; i < settings->parameter_count; i++) { const driver_parameter& parameter = settings->parameters[i]; if (strcmp(parameter.name, "Package") != 0 || parameter.value_count < 1) { continue; } error = _AddPackageSettingsItem(parameter); // abort only in case of serious issues (memory shortage) if (error == B_NO_MEMORY) return error; } return B_OK; }
status_t PackagesDirectory::_Init(struct vnode* vnode, struct stat& _st) { fDirFD = vfs_open_vnode(vnode, O_RDONLY, true); if (fDirFD < 0) { ERROR("Failed to open packages directory \"%s\"\n", strerror(fDirFD)); vfs_put_vnode(vnode); RETURN_ERROR(fDirFD); } // Our vnode reference has been transferred to the FD. // Is it a directory at all? struct stat& st = _st; if (fstat(fDirFD, &st) < 0) RETURN_ERROR(errno); fNodeRef.device = st.st_dev; fNodeRef.node = st.st_ino; // get a normalized path KPath normalizedPath; if (normalizedPath.InitCheck() != B_OK) RETURN_ERROR(normalizedPath.InitCheck()); char* normalizedPathBuffer = normalizedPath.LockBuffer(); status_t error = vfs_entry_ref_to_path(fNodeRef.device, fNodeRef.node, NULL, true, normalizedPathBuffer, normalizedPath.BufferSize()); if (error != B_OK) RETURN_ERROR(error); fPath = strdup(normalizedPathBuffer); if (fPath == NULL) RETURN_ERROR(B_NO_MEMORY); return B_OK; }
static int32 main2(void *unused) { (void)(unused); TRACE("start of main2: initializing devices\n"); boot_splash_init(sKernelArgs.boot_splash); commpage_init_post_cpus(); TRACE("init ports\n"); port_init(&sKernelArgs); TRACE("init user mutex\n"); user_mutex_init(); TRACE("Init modules\n"); boot_splash_set_stage(BOOT_SPLASH_STAGE_1_INIT_MODULES); module_init_post_threads(); // init userland debugging TRACE("Init Userland debugging\n"); init_user_debug(); // init the messaging service TRACE("Init Messaging Service\n"); init_messaging_service(); /* bootstrap all the filesystems */ TRACE("Bootstrap file systems\n"); boot_splash_set_stage(BOOT_SPLASH_STAGE_2_BOOTSTRAP_FS); vfs_bootstrap_file_systems(); TRACE("Init Device Manager\n"); boot_splash_set_stage(BOOT_SPLASH_STAGE_3_INIT_DEVICES); device_manager_init(&sKernelArgs); TRACE("Add preloaded old-style drivers\n"); legacy_driver_add_preloaded(&sKernelArgs); int_init_post_device_manager(&sKernelArgs); TRACE("Mount boot file system\n"); boot_splash_set_stage(BOOT_SPLASH_STAGE_4_MOUNT_BOOT_FS); vfs_mount_boot_file_system(&sKernelArgs); #if ENABLE_SWAP_SUPPORT TRACE("swap_init_post_modules\n"); swap_init_post_modules(); #endif // CPU specific modules may now be available boot_splash_set_stage(BOOT_SPLASH_STAGE_5_INIT_CPU_MODULES); cpu_init_post_modules(&sKernelArgs); TRACE("vm_init_post_modules\n"); boot_splash_set_stage(BOOT_SPLASH_STAGE_6_INIT_VM_MODULES); vm_init_post_modules(&sKernelArgs); TRACE("debug_init_post_modules\n"); debug_init_post_modules(&sKernelArgs); TRACE("device_manager_init_post_modules\n"); device_manager_init_post_modules(&sKernelArgs); boot_splash_set_stage(BOOT_SPLASH_STAGE_7_RUN_BOOT_SCRIPT); boot_splash_uninit(); // NOTE: We could introduce a syscall to draw more icons indicating // stages in the boot script itself. Then we should not free the image. // In that case we should copy it over to the kernel heap, so that we // can still free the kernel args. // The boot splash screen is the last user of the kernel args. // Note: don't confuse the kernel_args structure (which is never freed) // with the kernel args ranges it contains (and which are freed here). vm_free_kernel_args(&sKernelArgs); // start the init process { KPath bootScriptPath; status_t status = find_directory(B_BEOS_SYSTEM_DIRECTORY, gBootDevice, false, bootScriptPath.LockBuffer(), bootScriptPath.BufferSize()); if (status != B_OK) dprintf("main2: find_directory() failed: %s\n", strerror(status)); bootScriptPath.UnlockBuffer(); status = bootScriptPath.Append("boot/Bootscript"); if (status != B_OK) { dprintf("main2: constructing path to Bootscript failed: " "%s\n", strerror(status)); } const char *args[] = { "/bin/sh", bootScriptPath.Path(), NULL }; int32 argc = 2; thread_id thread; thread = load_image(argc, args, NULL); if (thread >= B_OK) { resume_thread(thread); TRACE("Bootscript started\n"); } else dprintf("error starting \"%s\" error = %ld \n", args[0], thread); } return 0; }