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 device_node::_AddPath(Stack<KPath*>& stack, const char* basePath, const char* subPath) { KPath* path = new(std::nothrow) KPath; if (path == NULL) return B_NO_MEMORY; status_t status = path->SetTo(basePath); if (status == B_OK && subPath != NULL && subPath[0]) status = path->Append(subPath); if (status == B_OK) status = stack.Push(path); TRACE((" add path: \"%s\", %" B_PRId32 "\n", path->Path(), status)); if (status != B_OK) delete path; return status; }
// SetTo status_t KFileDiskDevice::SetTo(const char *filePath, const char *devicePath) { // check params if (!filePath || strlen(filePath) > B_PATH_NAME_LENGTH || (devicePath && strlen(devicePath) > B_PATH_NAME_LENGTH)) { return B_BAD_VALUE; } // normalize the file path // (should actually not be necessary, since this method is only invoked // by the DDM, which has already normalized the path) KPath tmpFilePath; status_t error = tmpFilePath.SetTo(filePath, true); if (error != B_OK) return error; // check the file struct stat st; if (stat(filePath, &st) != 0) return errno; if (!S_ISREG(st.st_mode)) return B_BAD_VALUE; // create the device, if requested KPath tmpDevicePath; if (!devicePath) { // no device path: we shall create a new device entry if (tmpDevicePath.InitCheck() != B_OK) return tmpDevicePath.InitCheck(); // TODO: Cleanup. The directory creation is done automatically by the devfs. // // make the file devices dir // if (mkdir(kFileDevicesDir, 0777) != 0) { // if (errno != B_FILE_EXISTS) // return errno; // } // make the directory status_t error = _GetDirectoryPath(ID(), &tmpDevicePath); if (error != B_OK) return error; // if (mkdir(tmpDevicePath.Path(), 0777) != 0) // return errno; // get the device path name error = tmpDevicePath.Append("raw"); if (error != B_OK) return error; devicePath = tmpDevicePath.Path(); // register the file as virtual disk device error = _RegisterDevice(filePath, devicePath); if (error != B_OK) return error; } error = set_string(fFilePath, filePath); if (error != B_OK) return error; error = KDiskDevice::SetTo(devicePath); if (error != B_OK) return error; // reset the B_DISK_DEVICE_IS_FILE flag -- KDiskDevice::SetTo() has cleared // it SetDeviceFlags(DeviceFlags() | B_DISK_DEVICE_IS_FILE); 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; }