當前位置: 首頁>>代碼示例>>C++>>正文


C++ OSBoolean::release方法代碼示例

本文整理匯總了C++中OSBoolean::release方法的典型用法代碼示例。如果您正苦於以下問題:C++ OSBoolean::release方法的具體用法?C++ OSBoolean::release怎麽用?C++ OSBoolean::release使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OSBoolean的用法示例。


在下文中一共展示了OSBoolean::release方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: OSDynamicCast

bool
net_lundman_zfs_zvol_device::attach(IOService* provider)
{
	OSDictionary *protocolCharacteristics = 0;
	OSDictionary *deviceCharacteristics = 0;
	OSDictionary *storageFeatures = 0;
	OSBoolean *unmapFeature = 0;
	OSString *dataString = 0;
	OSNumber *dataNumber = 0;

	if (super::attach(provider) == false)
		return (false);
	m_provider = OSDynamicCast(net_lundman_zfs_zvol, provider);
	if (m_provider == NULL)
		return (false);

	/*
	 * We want to set some additional properties for ZVOLs, in
	 * particular, "Virtual Device", and type "File"
	 * (or is Internal better?)
	 *
	 * Finally "Generic" type.
	 *
	 * These properties are defined in *protocol* characteristics
	 */

	protocolCharacteristics = OSDictionary::withCapacity(3);

	if (!protocolCharacteristics) {
		IOLog("failed to create dict for protocolCharacteristics.\n");
		return (true);
	}

	dataString = OSString::withCString(
	    kIOPropertyPhysicalInterconnectTypeVirtual);

	if (!dataString) {
		IOLog("could not create interconnect type string\n");
		return (true);
	}
	protocolCharacteristics->setObject(
	    kIOPropertyPhysicalInterconnectTypeKey, dataString);

	dataString->release();
	dataString = 0;

	dataString = OSString::withCString(kIOPropertyInterconnectFileKey);
	if (!dataString) {
		IOLog("could not create interconnect location string\n");
		return (true);
	}
	protocolCharacteristics->setObject(
	    kIOPropertyPhysicalInterconnectLocationKey, dataString);

	dataString->release();
	dataString = 0;

	setProperty(kIOPropertyProtocolCharacteristicsKey,
	    protocolCharacteristics);

	protocolCharacteristics->release();
	protocolCharacteristics = 0;

	/*
	 * We want to set some additional properties for ZVOLs, in
	 * particular, physical block size (volblocksize) of the
	 * underlying ZVOL, and 'logical' block size presented by
	 * the virtual disk. Also set physical bytes per sector.
	 *
	 * These properties are defined in *device* characteristics
	 */

	deviceCharacteristics = OSDictionary::withCapacity(3);

	if (!deviceCharacteristics) {
		IOLog("failed to create dict for deviceCharacteristics.\n");
		return (true);
	}

	/* Set logical block size to ZVOL_BSIZE (512b) */
	dataNumber =	OSNumber::withNumber(ZVOL_BSIZE,
	    8 * sizeof (ZVOL_BSIZE));

	deviceCharacteristics->setObject(kIOPropertyLogicalBlockSizeKey,
	    dataNumber);

	dprintf("logicalBlockSize %llu\n",
	    dataNumber->unsigned64BitValue());

	dataNumber->release();
	dataNumber	= 0;

	/* Set physical block size to match volblocksize property */
	dataNumber =	OSNumber::withNumber(zv->zv_volblocksize,
	    8 * sizeof (zv->zv_volblocksize));

	deviceCharacteristics->setObject(kIOPropertyPhysicalBlockSizeKey,
	    dataNumber);

	dprintf("physicalBlockSize %llu\n",
//.........這裏部分代碼省略.........
開發者ID:tokyovigilante,項目名稱:zfs,代碼行數:101,代碼來源:zvolIO.cpp


注:本文中的OSBoolean::release方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。