Several changes to the _kern_{supports,validate}_*() calls:
* Removed the disk_system_id parameter where superfluous.
* Got rid of the `child' variants of the _kern_{supports,validate}_*()
syscalls for moving and resizing. Reimplemented the real ones to do the
the right thing, i.e. they check all concerned disk systems now.
* Added _kern_supports_setting[_content]_parameters().
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4020 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -96,73 +96,49 @@ status_t _kern_get_next_disk_system_info(int32 *cookie,
|
||||
user_disk_system_info *info);
|
||||
status_t _kern_find_disk_system(const char *name, user_disk_system_info *info);
|
||||
|
||||
bool _kern_supports_defragmenting_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
bool _kern_supports_defragmenting_partition(partition_id partitionID,
|
||||
bool *whileMounted);
|
||||
bool _kern_supports_repairing_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
bool _kern_supports_repairing_partition(partition_id partitionID,
|
||||
bool checkOnly, bool *whileMounted);
|
||||
bool _kern_supports_resizing_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
bool _kern_supports_resizing_partition(partition_id partitionID,
|
||||
bool *canResizeContents,
|
||||
bool *whileMounted);
|
||||
bool _kern_supports_resizing_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID);
|
||||
bool _kern_supports_moving_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
bool _kern_supports_moving_partition(partition_id partitionID,
|
||||
partition_id *buffer, size_t bufferSize,
|
||||
bool *whileMounted);
|
||||
bool _kern_supports_moving_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID);
|
||||
bool _kern_supports_setting_partition_name(disk_system_id diskSystemID,
|
||||
partition_id partitionID);
|
||||
bool _kern_supports_setting_partition_content_name(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
bool _kern_supports_setting_partition_name(partition_id partitionID);
|
||||
bool _kern_supports_setting_partition_content_name(partition_id partitionID,
|
||||
bool *whileMounted);
|
||||
bool _kern_supports_setting_partition_type(disk_system_id diskSystemID,
|
||||
partition_id partitionID);
|
||||
bool _kern_supports_creating_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID);
|
||||
bool _kern_supports_deleting_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID);
|
||||
bool _kern_supports_initializing_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID);
|
||||
bool _kern_supports_initializing_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
const char *childSystem);
|
||||
bool _kern_supports_setting_partition_type(partition_id partitionID);
|
||||
bool _kern_supports_setting_partition_parameters(partition_id partitionID);
|
||||
bool _kern_supports_setting_partition_content_parameters(
|
||||
partition_id partitionID, bool *whileMounted);
|
||||
bool _kern_supports_initializing_partition(partition_id partitionID,
|
||||
const char *diskSystemName);
|
||||
bool _kern_supports_creating_child_partition(partition_id partitionID);
|
||||
bool _kern_supports_deleting_child_partition(partition_id partitionID);
|
||||
bool _kern_is_sub_disk_system_for(disk_system_id diskSystemID,
|
||||
partition_id partitionID);
|
||||
|
||||
status_t _kern_validate_resize_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
off_t *size);
|
||||
status_t _kern_validate_resize_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
off_t *size);
|
||||
status_t _kern_validate_move_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
off_t *offset);
|
||||
status_t _kern_validate_move_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
off_t *offset);
|
||||
status_t _kern_validate_set_partition_name(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
status_t _kern_validate_resize_partition(partition_id partitionID,
|
||||
off_t *size, bool resizeContents);
|
||||
status_t _kern_validate_move_partition(partition_id partitionID,
|
||||
off_t *newOffset, bool force);
|
||||
status_t _kern_validate_set_partition_name(partition_id partitionID,
|
||||
char *name);
|
||||
status_t _kern_validate_set_partition_content_name(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
status_t _kern_validate_set_partition_content_name(partition_id partitionID,
|
||||
char *name);
|
||||
status_t _kern_validate_set_partition_type(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
status_t _kern_validate_set_partition_type(partition_id partitionID,
|
||||
const char *type);
|
||||
status_t _kern_validate_initialize_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
status_t _kern_validate_initialize_partition(partition_id partitionID,
|
||||
const char *diskSystemName,
|
||||
char *name,
|
||||
const char *parameters);
|
||||
status_t _kern_validate_create_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
status_t _kern_validate_create_child_partition(partition_id partitionID,
|
||||
off_t *offset, off_t *size,
|
||||
const char *type,
|
||||
const char *parameters);
|
||||
status_t _kern_get_next_supported_partition_type(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
status_t _kern_get_next_supported_partition_type(partition_id partitionID,
|
||||
int32 *cookie, char *type);
|
||||
status_t _kern_get_partition_type_for_content_type(disk_system_id diskSystemID,
|
||||
const char *contentType,
|
||||
|
||||
@@ -29,6 +29,60 @@ check_shadow_partition(const KPartition *partition)
|
||||
&& partition->Device()->ShadowOwner() == get_current_team());
|
||||
}
|
||||
|
||||
// get_unmovable_descendants
|
||||
static
|
||||
bool
|
||||
get_unmovable_descendants(KPartition *partition, partition_id *&buffer,
|
||||
size_t &bufferSize, bool &whileMounted)
|
||||
{
|
||||
// check parameters
|
||||
if (!partition || !buffer || bufferSize == 0)
|
||||
return false;
|
||||
// check partition
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->SupportsMoving(partition, &whileMounted)) {
|
||||
buffer[0] = partition->ID();
|
||||
bufferSize--;
|
||||
}
|
||||
// check child partitions
|
||||
for (int32 i = 0; KPartition *child = partition->ChildAt(i); i++) {
|
||||
bool whileChildMounted = false;
|
||||
if (!get_unmovable_descendants(child, buffer, bufferSize,
|
||||
whileChildMounted)) {
|
||||
return false;
|
||||
}
|
||||
whileMounted &= whileChildMounted;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// validate_move_descendants
|
||||
static
|
||||
status_t
|
||||
validate_move_descendants(KPartition *partition, off_t moveBy, bool force)
|
||||
{
|
||||
if (!partition)
|
||||
return B_BAD_VALUE;
|
||||
// check partition
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (diskSystem || diskSystem->SupportsMoving(partition, NULL)) {
|
||||
off_t offset = partition->Offset() + moveBy;
|
||||
off_t newOffset = offset;
|
||||
if (!diskSystem->ValidateMove(partition, &newOffset)
|
||||
|| newOffset != offset) {
|
||||
return B_ERROR;
|
||||
}
|
||||
} else if (!force)
|
||||
return B_ERROR;
|
||||
// check children
|
||||
for (int32 i = 0; KPartition *child = partition->ChildAt(i); i++) {
|
||||
status_t error = validate_move_descendants(child, moveBy, force);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// _kern_get_next_disk_device_id
|
||||
partition_id
|
||||
_kern_get_next_disk_device_id(int32 *cookie, size_t *neededSize)
|
||||
@@ -215,8 +269,7 @@ _kern_find_disk_system(const char *name, user_disk_system_info *info)
|
||||
|
||||
// _kern_supports_defragmenting_partition
|
||||
bool
|
||||
_kern_supports_defragmenting_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
_kern_supports_defragmenting_partition(partition_id partitionID,
|
||||
bool *whileMounted)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
@@ -231,7 +284,7 @@ _kern_supports_defragmenting_partition(disk_system_id diskSystemID,
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsDefragmenting(partition, whileMounted);
|
||||
@@ -239,8 +292,7 @@ _kern_supports_defragmenting_partition(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_supports_repairing_partition
|
||||
bool
|
||||
_kern_supports_repairing_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID, bool checkOnly,
|
||||
_kern_supports_repairing_partition(partition_id partitionID, bool checkOnly,
|
||||
bool *whileMounted)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
@@ -255,7 +307,7 @@ _kern_supports_repairing_partition(disk_system_id diskSystemID,
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsRepairing(partition, checkOnly, whileMounted);
|
||||
@@ -263,9 +315,12 @@ _kern_supports_repairing_partition(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_supports_resizing_partition
|
||||
bool
|
||||
_kern_supports_resizing_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID, bool *whileMounted)
|
||||
_kern_supports_resizing_partition(partition_id partitionID,
|
||||
bool *canResizeContents,
|
||||
bool *whileMounted)
|
||||
{
|
||||
if (!canResizeContents)
|
||||
return false;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
@@ -274,46 +329,35 @@ _kern_supports_resizing_partition(disk_system_id diskSystemID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
// get the parent disk system
|
||||
KDiskSystem *parentDiskSystem = partition->Parent()->DiskSystem();
|
||||
if (!parentDiskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsResizing(partition, whileMounted);
|
||||
}
|
||||
|
||||
// _kern_supports_resizing_child_partition
|
||||
bool
|
||||
_kern_supports_resizing_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
if (!partition)
|
||||
bool result = parentDiskSystem->SupportsResizingChild(partition);
|
||||
if (!result)
|
||||
return false;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
return false;
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsResizingChild(partition);
|
||||
// get the child disk system
|
||||
KDiskSystem *childDiskSystem = partition->DiskSystem();
|
||||
*canResizeContents = (childDiskSystem
|
||||
&& childDiskSystem->SupportsResizing(partition, whileMounted));
|
||||
// TODO: Currently we report that we cannot resize the contents, if the
|
||||
// partition's disk system is unknown. I found this more logical. It doesn't
|
||||
// really matter, though, since the API user can check for this situation.
|
||||
return result;
|
||||
}
|
||||
|
||||
// _kern_supports_moving_partition
|
||||
bool
|
||||
_kern_supports_moving_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID, bool *whileMounted)
|
||||
_kern_supports_moving_partition(partition_id partitionID, partition_id *buffer,
|
||||
size_t bufferSize, bool *whileMounted)
|
||||
{
|
||||
if (!buffer && bufferSize > 0)
|
||||
return false;
|
||||
bool _whileMounted;
|
||||
if (!whileMounted)
|
||||
_whileMounted = &_whileMounted;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
@@ -322,45 +366,27 @@ _kern_supports_moving_partition(disk_system_id diskSystemID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
// get the parent disk system
|
||||
KDiskSystem *parentDiskSystem = partition->Parent()->DiskSystem();
|
||||
if (!parentDiskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsMoving(partition, whileMounted);
|
||||
}
|
||||
|
||||
// _kern_supports_moving_child_partition
|
||||
bool
|
||||
_kern_supports_moving_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
if (!partition)
|
||||
bool result = parentDiskSystem->SupportsMovingChild(partition);
|
||||
if (!result)
|
||||
return false;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
// check the movability of the descendants' contents
|
||||
*whileMounted = true;
|
||||
if (!get_unmovable_descendants(partition, buffer, bufferSize,
|
||||
*whileMounted)) {
|
||||
return false;
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsMovingChild(partition);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// _kern_supports_setting_partition_name
|
||||
bool
|
||||
_kern_supports_setting_partition_name(disk_system_id diskSystemID,
|
||||
partition_id partitionID)
|
||||
_kern_supports_setting_partition_name(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@@ -376,7 +402,7 @@ _kern_supports_setting_partition_name(disk_system_id diskSystemID,
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsSettingName(partition);
|
||||
@@ -384,8 +410,7 @@ _kern_supports_setting_partition_name(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_supports_setting_partition_content_name
|
||||
bool
|
||||
_kern_supports_setting_partition_content_name(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
_kern_supports_setting_partition_content_name(partition_id partitionID,
|
||||
bool *whileMounted)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
@@ -400,7 +425,7 @@ _kern_supports_setting_partition_content_name(disk_system_id diskSystemID,
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsSettingContentName(partition, whileMounted);
|
||||
@@ -408,8 +433,7 @@ _kern_supports_setting_partition_content_name(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_supports_setting_partition_type
|
||||
bool
|
||||
_kern_supports_setting_partition_type(disk_system_id diskSystemID,
|
||||
partition_id partitionID)
|
||||
_kern_supports_setting_partition_type(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@@ -425,16 +449,40 @@ _kern_supports_setting_partition_type(disk_system_id diskSystemID,
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsSettingType(partition);
|
||||
}
|
||||
|
||||
// _kern_supports_creating_child_partition
|
||||
// _kern_supports_setting_partition_parameters
|
||||
bool
|
||||
_kern_supports_creating_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID)
|
||||
_kern_supports_setting_partition_parameters(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
if (!partition)
|
||||
return false;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
return false;
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsSettingParameters(partition);
|
||||
}
|
||||
|
||||
// _kern_supports_setting_partition_content_parameters
|
||||
bool
|
||||
_kern_supports_setting_partition_content_parameters(partition_id partitionID,
|
||||
bool *whileMounted)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@@ -448,7 +496,55 @@ _kern_supports_creating_child_partition(disk_system_id diskSystemID,
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsSettingContentParameters(partition,
|
||||
whileMounted);
|
||||
}
|
||||
|
||||
// _kern_supports_initializing_partition
|
||||
bool
|
||||
_kern_supports_initializing_partition(partition_id partitionID,
|
||||
const char *diskSystemName)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
if (!partition)
|
||||
return false;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = manager->LoadDiskSystem(diskSystemName);
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
DiskSystemLoader loader(diskSystem, true);
|
||||
// get the info
|
||||
return diskSystem->SupportsInitializing(partition);
|
||||
// TODO: Ask the parent partitioning system as well.
|
||||
}
|
||||
|
||||
// _kern_supports_creating_child_partition
|
||||
bool
|
||||
_kern_supports_creating_child_partition(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
if (!partition)
|
||||
return false;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsCreatingChild(partition);
|
||||
@@ -456,8 +552,7 @@ _kern_supports_creating_child_partition(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_supports_deleting_child_partition
|
||||
bool
|
||||
_kern_supports_deleting_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID)
|
||||
_kern_supports_deleting_child_partition(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@@ -473,62 +568,12 @@ _kern_supports_deleting_child_partition(disk_system_id diskSystemID,
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsDeletingChild(partition);
|
||||
}
|
||||
|
||||
// _kern_supports_initializing_partition
|
||||
bool
|
||||
_kern_supports_initializing_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
if (!partition)
|
||||
return false;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
return false;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = manager->LoadDiskSystem(diskSystemID);
|
||||
if (!diskSystem)
|
||||
return false;
|
||||
DiskSystemLoader loader(diskSystem, true);
|
||||
// get the info
|
||||
return diskSystem->SupportsInitializing(partition);
|
||||
}
|
||||
|
||||
// _kern_supports_initializing_child_partition
|
||||
bool
|
||||
_kern_supports_initializing_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
const char *childSystem)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
if (!partition)
|
||||
return false;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
return false;
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return false;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
return false;
|
||||
// get the info
|
||||
return diskSystem->SupportsInitializingChild(partition, childSystem);
|
||||
}
|
||||
|
||||
// _kern_is_sub_disk_system_for
|
||||
bool
|
||||
_kern_is_sub_disk_system_for(disk_system_id diskSystemID,
|
||||
@@ -554,8 +599,8 @@ _kern_is_sub_disk_system_for(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_validate_resize_partition
|
||||
status_t
|
||||
_kern_validate_resize_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID, off_t *size)
|
||||
_kern_validate_resize_partition(partition_id partitionID, off_t *size,
|
||||
bool resizeContents)
|
||||
{
|
||||
if (!size)
|
||||
return B_BAD_VALUE;
|
||||
@@ -567,53 +612,35 @@ _kern_validate_resize_partition(disk_system_id diskSystemID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
// get the parent disk system and let it check the value
|
||||
KDiskSystem *parentDiskSystem = partition->Parent()->DiskSystem();
|
||||
if (!parentDiskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
// get the info
|
||||
if (diskSystem->ValidateResize(partition, size))
|
||||
return B_OK;
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// _kern_validate_resize_child_partition
|
||||
status_t
|
||||
_kern_validate_resize_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID, off_t *size)
|
||||
{
|
||||
if (!size)
|
||||
return B_BAD_VALUE;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
if (!partition)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return B_BAD_VALUE;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
// get the info
|
||||
if (diskSystem->ValidateResizeChild(partition, size))
|
||||
return B_OK;
|
||||
return B_ERROR;
|
||||
status_t error = parentDiskSystem->ValidateResizeChild(partition, size);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
// get the child disk system and let it check the value
|
||||
if (resizeContents) {
|
||||
KDiskSystem *childDiskSystem = partition->DiskSystem();
|
||||
if (!childDiskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
off_t childSize = *size;
|
||||
error = childDiskSystem->ValidateResize(partition, &childSize);
|
||||
// don't worry, if the content system desires to be smaller
|
||||
if (error == B_OK && childSize > *size)
|
||||
error = B_ERROR;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
// _kern_validate_move_partition
|
||||
status_t
|
||||
_kern_validate_move_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID, off_t *offset)
|
||||
_kern_validate_move_partition(partition_id partitionID, off_t *newOffset,
|
||||
bool force)
|
||||
{
|
||||
if (!offset)
|
||||
if (!newOffset)
|
||||
return B_BAD_VALUE;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
@@ -623,54 +650,25 @@ _kern_validate_move_partition(disk_system_id diskSystemID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
// get the parent disk system and let it check the value
|
||||
KDiskSystem *parentDiskSystem = partition->Parent()->DiskSystem();
|
||||
if (!parentDiskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
// get the info
|
||||
if (diskSystem->ValidateMove(partition, offset))
|
||||
return B_OK;
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// _kern_validate_move_child_partition
|
||||
status_t
|
||||
_kern_validate_move_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID, off_t *offset)
|
||||
{
|
||||
if (!offset)
|
||||
return B_BAD_VALUE;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
if (!partition)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return B_BAD_VALUE;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
// get the info
|
||||
if (diskSystem->ValidateMoveChild(partition, offset))
|
||||
return B_OK;
|
||||
return B_ERROR;
|
||||
status_t error = parentDiskSystem->ValidateMoveChild(partition, newOffset);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
// let the concerned content disk systems check the value
|
||||
error = validate_move_descendants(partition,
|
||||
partition->Offset() - *newOffset, force);
|
||||
return error;
|
||||
}
|
||||
|
||||
// _kern_validate_set_partition_name
|
||||
status_t
|
||||
_kern_validate_set_partition_name(disk_system_id diskSystemID,
|
||||
partition_id partitionID, char *name)
|
||||
_kern_validate_set_partition_name(partition_id partitionID, char *name)
|
||||
{
|
||||
if (!name)
|
||||
return B_BAD_VALUE;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
@@ -679,13 +677,11 @@ _kern_validate_set_partition_name(disk_system_id diskSystemID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return B_BAD_VALUE;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
// get the info
|
||||
if (diskSystem->ValidateSetName(partition, name))
|
||||
@@ -695,11 +691,8 @@ _kern_validate_set_partition_name(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_validate_set_partition_content_name
|
||||
status_t
|
||||
_kern_validate_set_partition_content_name(disk_system_id diskSystemID,
|
||||
partition_id partitionID, char *name)
|
||||
_kern_validate_set_partition_content_name(partition_id partitionID, char *name)
|
||||
{
|
||||
if (!name)
|
||||
return B_BAD_VALUE;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
@@ -712,7 +705,7 @@ _kern_validate_set_partition_content_name(disk_system_id diskSystemID,
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
// get the info
|
||||
if (diskSystem->ValidateSetContentName(partition, name))
|
||||
@@ -722,8 +715,7 @@ _kern_validate_set_partition_content_name(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_validate_set_partition_type
|
||||
status_t
|
||||
_kern_validate_set_partition_type(disk_system_id diskSystemID,
|
||||
partition_id partitionID, const char *type)
|
||||
_kern_validate_set_partition_type(partition_id partitionID, const char *type)
|
||||
{
|
||||
if (!type)
|
||||
return B_BAD_VALUE;
|
||||
@@ -735,13 +727,11 @@ _kern_validate_set_partition_type(disk_system_id diskSystemID,
|
||||
PartitionRegistrar registrar1(partition, true);
|
||||
PartitionRegistrar registrar2(partition->Device(), true);
|
||||
DeviceReadLocker locker(partition->Device(), true);
|
||||
if (!check_shadow_partition(partition))
|
||||
if (!check_shadow_partition(partition) || !partition->Parent())
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
if (!partition->Parent())
|
||||
return B_BAD_VALUE;
|
||||
KDiskSystem *diskSystem = partition->Parent()->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
// get the info
|
||||
if (diskSystem->ValidateSetType(partition, type))
|
||||
@@ -751,10 +741,12 @@ _kern_validate_set_partition_type(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_validate_initialize_partition
|
||||
status_t
|
||||
_kern_validate_initialize_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID, char *name,
|
||||
_kern_validate_initialize_partition(partition_id partitionID,
|
||||
const char *diskSystemName, char *name,
|
||||
const char *parameters)
|
||||
{
|
||||
if (!diskSystemName)
|
||||
return B_BAD_VALUE;
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
// get the partition
|
||||
KPartition *partition = manager->ReadLockPartition(partitionID);
|
||||
@@ -766,7 +758,7 @@ _kern_validate_initialize_partition(disk_system_id diskSystemID,
|
||||
if (!check_shadow_partition(partition))
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = manager->LoadDiskSystem(diskSystemID);
|
||||
KDiskSystem *diskSystem = manager->LoadDiskSystem(diskSystemName);
|
||||
if (!diskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
DiskSystemLoader loader(diskSystem, true);
|
||||
@@ -776,8 +768,7 @@ _kern_validate_initialize_partition(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_validate_create_child_partition
|
||||
status_t
|
||||
_kern_validate_create_child_partition(disk_system_id diskSystemID,
|
||||
partition_id partitionID, off_t *offset,
|
||||
_kern_validate_create_child_partition(partition_id partitionID, off_t *offset,
|
||||
off_t *size, const char *type,
|
||||
const char *parameters)
|
||||
{
|
||||
@@ -795,7 +786,7 @@ _kern_validate_create_child_partition(disk_system_id diskSystemID,
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
// get the info
|
||||
if (diskSystem->ValidateCreateChild(partition, offset, size, type,
|
||||
@@ -807,8 +798,7 @@ _kern_validate_create_child_partition(disk_system_id diskSystemID,
|
||||
|
||||
// _kern_get_next_supported_partition_type
|
||||
status_t
|
||||
_kern_get_next_supported_partition_type(disk_system_id diskSystemID,
|
||||
partition_id partitionID,
|
||||
_kern_get_next_supported_partition_type(partition_id partitionID,
|
||||
int32 *cookie, char *type)
|
||||
{
|
||||
if (!cookie || !type)
|
||||
@@ -825,7 +815,7 @@ _kern_get_next_supported_partition_type(disk_system_id diskSystemID,
|
||||
return B_BAD_VALUE;
|
||||
// get the disk system
|
||||
KDiskSystem *diskSystem = partition->DiskSystem();
|
||||
if (!diskSystem || diskSystem->ID() != diskSystemID)
|
||||
if (!diskSystem)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
// get the info
|
||||
if (diskSystem->GetNextSupportedType(partition, cookie, type))
|
||||
|
||||
Reference in New Issue
Block a user