本文整理汇总了C++中KDiskDeviceManager::WriteLockPartition方法的典型用法代码示例。如果您正苦于以下问题:C++ KDiskDeviceManager::WriteLockPartition方法的具体用法?C++ KDiskDeviceManager::WriteLockPartition怎么用?C++ KDiskDeviceManager::WriteLockPartition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDiskDeviceManager
的用法示例。
在下文中一共展示了KDiskDeviceManager::WriteLockPartition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
status_t
_user_set_partition_content_parameters(partition_id partitionID,
int32* _changeCounter, const char* _parameters)
{
// copy parameters in
UserStringParameter<true> parameters;
int32 changeCounter;
status_t error
= parameters.Init(_parameters, B_DISK_DEVICE_MAX_PARAMETER_SIZE);
if (error != B_OK || (error = copy_from_user_value(changeCounter,
_changeCounter)) != B_OK) {
return error;
}
// get the partition
KDiskDeviceManager* manager = KDiskDeviceManager::Default();
KPartition* partition = manager->WriteLockPartition(partitionID);
if (!partition)
return B_ENTRY_NOT_FOUND;
PartitionRegistrar registrar1(partition, true);
PartitionRegistrar registrar2(partition->Device(), true);
DeviceWriteLocker locker(partition->Device(), true);
// check change counter
if (changeCounter != partition->ChangeCounter())
return B_BAD_VALUE;
// the partition must be initialized
KDiskSystem* diskSystem = partition->DiskSystem();
if (!diskSystem)
return B_BAD_VALUE;
// mark the partition busy and unlock
if (!partition->CheckAndMarkBusy(true))
return B_BUSY;
locker.Unlock();
// set content parameters
error = diskSystem->SetContentParameters(partition, parameters.value,
DUMMY_JOB_ID);
// re-lock and unmark busy
locker.Lock();
partition->UnmarkBusy(true);
if (error != B_OK)
return error;
// return change counter
if ((error = copy_to_user_value(_changeCounter, partition->ChangeCounter()))
!= B_OK) {
return error;
}
return B_OK;
}
示例2: locker
status_t
_user_set_partition_content_name(partition_id partitionID,
int32* _changeCounter, const char* _name)
{
// copy parameters in
UserStringParameter<true> name;
int32 changeCounter;
status_t error = name.Init(_name, B_DISK_DEVICE_NAME_LENGTH);
if (error == B_OK)
error = copy_from_user_value(changeCounter, _changeCounter);
if (error != B_OK)
return error;
// get the partition
KDiskDeviceManager* manager = KDiskDeviceManager::Default();
KPartition* partition = manager->WriteLockPartition(partitionID);
if (partition == NULL)
return B_ENTRY_NOT_FOUND;
PartitionRegistrar registrar1(partition, true);
PartitionRegistrar registrar2(partition->Device(), true);
DeviceWriteLocker locker(partition->Device(), true);
// check change counter
if (changeCounter != partition->ChangeCounter())
return B_BAD_VALUE;
// the partition must be initialized
KDiskSystem* diskSystem = partition->DiskSystem();
if (diskSystem == NULL)
return B_BAD_VALUE;
// mark the partition busy and unlock
if (!partition->CheckAndMarkBusy(false))
return B_BUSY;
locker.Unlock();
// set content parameters
error = diskSystem->SetContentName(partition, name.value, DUMMY_JOB_ID);
// re-lock and unmark busy
locker.Lock();
partition->UnmarkBusy(false);
if (error != B_OK)
return error;
// return change counter
return copy_to_user_value(_changeCounter, partition->ChangeCounter());
}