当前位置: 首页>>代码示例>>C++>>正文


C++ BVolume::IsShared方法代码示例

本文整理汇总了C++中BVolume::IsShared方法的典型用法代码示例。如果您正苦于以下问题:C++ BVolume::IsShared方法的具体用法?C++ BVolume::IsShared怎么用?C++ BVolume::IsShared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BVolume的用法示例。


在下文中一共展示了BVolume::IsShared方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: settingDeleter

status_t
Settings::ReadSwapSettings()
{
	void* settings = load_driver_settings(kVirtualMemorySettings);
	if (settings == NULL)
		return kErrorSettingsNotFound;
	CObjectDeleter<void, status_t> settingDeleter(settings,
		&unload_driver_settings);

	const char* enabled = get_driver_parameter(settings, "vm", NULL, NULL);
	const char* automatic = get_driver_parameter(settings, "swap_auto",
		NULL, NULL);
	const char* size = get_driver_parameter(settings, "swap_size", NULL, NULL);
	const char* volume = get_driver_parameter(settings, "swap_volume_name",
		NULL, NULL);
	const char* device = get_driver_parameter(settings,
		"swap_volume_device", NULL, NULL);
	const char* filesystem = get_driver_parameter(settings,
		"swap_volume_filesystem", NULL, NULL);
	const char* capacity = get_driver_parameter(settings,
		"swap_volume_capacity", NULL, NULL);

	if (enabled == NULL	|| automatic == NULL || size == NULL || device == NULL
		|| volume == NULL || capacity == NULL || filesystem == NULL)
		return kErrorSettingsInvalid;

	off_t volCapacity = atoll(capacity);

	SetSwapEnabled(get_driver_boolean_parameter(settings,
		"vm", true, false));
	SetSwapAutomatic(get_driver_boolean_parameter(settings,
		"swap_auto", true, false));
	SetSwapSize(atoll(size));

	int32 bestScore = -1;
	dev_t bestVol = -1;

	BVolume vol;
	fs_info volStat;
	BVolumeRoster roster;
	while (roster.GetNextVolume(&vol) == B_OK) {
		if (!vol.IsPersistent() || vol.IsReadOnly() || vol.IsRemovable()
			|| vol.IsShared())
			continue;
		if (fs_stat_dev(vol.Device(), &volStat) == 0) {
			int32 score = 0;
			if (strcmp(volume, volStat.volume_name) == 0)
				score += 4;
			if (strcmp(device, volStat.device_name) == 0)
				score += 3;
			if (volCapacity == volStat.total_blocks * volStat.block_size)
				score += 2;
			if (strcmp(filesystem, volStat.fsh_name) == 0)
				score += 1;
			if (score >= 4 && score > bestScore) {
				bestVol = vol.Device();
				bestScore = score;
			}
		}
	}

	SetSwapVolume(bestVol);
	fInitialSettings = fCurrentSettings;

	if (bestVol < 0)
		return kErrorVolumeNotFound;

	return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:69,代码来源:Settings.cpp


注:本文中的BVolume::IsShared方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。