* Discarded the "parametersSize" parameter from various disk device manager
functions. * Since we now use UserStringParameter, this fixes the missing null termination of the parameter string, and thus bug #4045. * Removed UserMemoryParameter, as it's no longer in use. * Adjusted syscalls accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31779 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6ef35ef770
commit
f75b8de3fc
@ -8,6 +8,7 @@
|
||||
#ifndef _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
|
||||
#define _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <DiskDeviceDefs.h>
|
||||
@ -69,29 +70,26 @@ status_t _user_set_partition_type(partition_id partitionID,
|
||||
int32* childChangeCounter, const char* type);
|
||||
status_t _user_set_partition_parameters(partition_id partitionID,
|
||||
int32* changeCounter, partition_id childID,
|
||||
int32* childChangeCounter, const char* parameters,
|
||||
size_t parametersSize);
|
||||
int32* childChangeCounter, const char* parameters);
|
||||
status_t _user_set_partition_content_parameters(partition_id partitionID,
|
||||
int32* changeCounter, const char* parameters,
|
||||
size_t parametersSize);
|
||||
int32* changeCounter, const char* parameters);
|
||||
status_t _user_initialize_partition(partition_id partitionID,
|
||||
int32* changeCounter, const char* diskSystemName,
|
||||
const char* name, const char* parameters,
|
||||
size_t parametersSize);
|
||||
const char* name, const char* parameters);
|
||||
status_t _user_uninitialize_partition(partition_id partitionID,
|
||||
int32* changeCounter);
|
||||
|
||||
status_t _user_create_child_partition(partition_id partitionID,
|
||||
int32* changeCounter, off_t offset, off_t size,
|
||||
const char* type, const char* name, const char* parameters,
|
||||
size_t parametersSize, partition_id* childID,
|
||||
int32* childChangeCounter);
|
||||
partition_id* childID, int32* childChangeCounter);
|
||||
status_t _user_delete_child_partition(partition_id partitionID,
|
||||
int32* changeCounter, partition_id childID,
|
||||
int32 childChangeCounter);
|
||||
|
||||
// change notification
|
||||
status_t _user_start_watching_disks(uint32 eventMask, port_id port, int32 token);
|
||||
status_t _user_start_watching_disks(uint32 eventMask, port_id port,
|
||||
int32 token);
|
||||
status_t _user_stop_watching_disks(port_id port, int32 token);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -541,22 +541,20 @@ extern status_t _kern_set_partition_type(partition_id partitionID,
|
||||
int32* childChangeCounter, const char* type);
|
||||
extern status_t _kern_set_partition_parameters(partition_id partitionID,
|
||||
int32* changeCounter, partition_id childID,
|
||||
int32* childChangeCounter, const char* parameters,
|
||||
size_t parametersSize);
|
||||
int32* childChangeCounter, const char* parameters);
|
||||
extern status_t _kern_set_partition_content_parameters(
|
||||
partition_id partitionID, int32* changeCounter,
|
||||
const char* parameters, size_t parametersSize);
|
||||
const char* parameters);
|
||||
extern status_t _kern_initialize_partition(partition_id partitionID,
|
||||
int32* changeCounter, const char* diskSystemName,
|
||||
const char* name, const char* parameters,
|
||||
size_t parametersSize);
|
||||
const char* name, const char* parameters);
|
||||
extern status_t _kern_uninitialize_partition(partition_id partitionID,
|
||||
int32* changeCounter);
|
||||
extern status_t _kern_create_child_partition(partition_id partitionID,
|
||||
int32* changeCounter, off_t offset, off_t size,
|
||||
const char* type, const char* name,
|
||||
const char* parameters, size_t parametersSize,
|
||||
partition_id* childID, int32* childChangeCounter);
|
||||
const char* parameters, partition_id* childID,
|
||||
int32* childChangeCounter);
|
||||
extern status_t _kern_delete_child_partition(partition_id partitionID,
|
||||
int32* changeCounter, partition_id childID,
|
||||
int32 childChangeCounter);
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "CreateChildJob.h"
|
||||
|
||||
#include <syscalls.h>
|
||||
@ -14,12 +15,13 @@
|
||||
// constructor
|
||||
CreateChildJob::CreateChildJob(PartitionReference* partition,
|
||||
PartitionReference* child)
|
||||
: DiskDeviceJob(partition, child),
|
||||
fOffset(0),
|
||||
fSize(0),
|
||||
fType(NULL),
|
||||
fName(NULL),
|
||||
fParameters(NULL)
|
||||
:
|
||||
DiskDeviceJob(partition, child),
|
||||
fOffset(0),
|
||||
fSize(0),
|
||||
fType(NULL),
|
||||
fName(NULL),
|
||||
fParameters(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -57,8 +59,8 @@ CreateChildJob::Do()
|
||||
partition_id childID;
|
||||
int32 childChangeCounter;
|
||||
status_t error = _kern_create_child_partition(fPartition->PartitionID(),
|
||||
&changeCounter, fOffset, fSize, fType, fName, fParameters,
|
||||
fParameters ? strlen(fParameters) : 0, &childID, &childChangeCounter);
|
||||
&changeCounter, fOffset, fSize, fType, fName, fParameters, &childID,
|
||||
&childChangeCounter);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "InitializeJob.h"
|
||||
|
||||
#include <syscalls.h>
|
||||
@ -13,10 +14,11 @@
|
||||
|
||||
// constructor
|
||||
InitializeJob::InitializeJob(PartitionReference* partition)
|
||||
: DiskDeviceJob(partition),
|
||||
fDiskSystem(NULL),
|
||||
fName(NULL),
|
||||
fParameters(NULL)
|
||||
:
|
||||
DiskDeviceJob(partition),
|
||||
fDiskSystem(NULL),
|
||||
fName(NULL),
|
||||
fParameters(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -48,10 +50,9 @@ status_t
|
||||
InitializeJob::Do()
|
||||
{
|
||||
int32 changeCounter = fPartition->ChangeCounter();
|
||||
status_t error = _kern_initialize_partition(fPartition->PartitionID(),
|
||||
&changeCounter, fDiskSystem, fName, fParameters,
|
||||
fParameters ? strlen(fParameters) : 0);
|
||||
|
||||
status_t error = _kern_initialize_partition(fPartition->PartitionID(),
|
||||
&changeCounter, fDiskSystem, fName, fParameters);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "SetStringJob.h"
|
||||
|
||||
#include <syscalls.h>
|
||||
@ -14,8 +15,9 @@
|
||||
// constructor
|
||||
SetStringJob::SetStringJob(PartitionReference* partition,
|
||||
PartitionReference* child)
|
||||
: DiskDeviceJob(partition, child),
|
||||
fString(NULL)
|
||||
:
|
||||
DiskDeviceJob(partition, child),
|
||||
fString(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -78,13 +80,12 @@ SetStringJob::Do()
|
||||
case B_DISK_DEVICE_JOB_SET_PARAMETERS:
|
||||
error = _kern_set_partition_parameters(fPartition->PartitionID(),
|
||||
&changeCounter, fChild->PartitionID(), &childChangeCounter,
|
||||
fString, fString ? strlen(fString) : 0);
|
||||
fString);
|
||||
updateChildChangeCounter = true;
|
||||
break;
|
||||
case B_DISK_DEVICE_JOB_SET_CONTENT_PARAMETERS:
|
||||
error = _kern_set_partition_content_parameters(
|
||||
fPartition->PartitionID(), &changeCounter, fString,
|
||||
fString ? strlen(fString) : 0);
|
||||
fPartition->PartitionID(), &changeCounter, fString);
|
||||
break;
|
||||
default:
|
||||
return B_BAD_VALUE;
|
||||
|
@ -141,50 +141,6 @@ struct UserStringParameter {
|
||||
};
|
||||
|
||||
|
||||
template<typename Type, bool kAllowsNull>
|
||||
struct UserMemoryParameter {
|
||||
Type* value;
|
||||
|
||||
inline UserMemoryParameter()
|
||||
: value(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
inline ~UserMemoryParameter()
|
||||
{
|
||||
free(value);
|
||||
}
|
||||
|
||||
inline status_t Init(const Type* userValue, size_t size)
|
||||
{
|
||||
if (userValue == NULL) {
|
||||
if (!kAllowsNull)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
value = NULL;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
if (!IS_USER_ADDRESS(userValue))
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
value = (Type*)malloc(size);
|
||||
if (value == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
return user_memcpy(value, userValue, size);
|
||||
}
|
||||
|
||||
inline status_t Init(const Type* userValue, size_t size, size_t maxSize)
|
||||
{
|
||||
if (size > maxSize)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return Init(userValue, size);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
static void
|
||||
move_descendants(KPartition *partition, off_t moveBy)
|
||||
@ -1036,17 +992,16 @@ _user_set_partition_type(partition_id partitionID, int32* _changeCounter,
|
||||
|
||||
status_t
|
||||
_user_set_partition_parameters(partition_id partitionID, int32* _changeCounter,
|
||||
partition_id childID, int32* _childChangeCounter, const char* _parameters,
|
||||
size_t parametersSize)
|
||||
partition_id childID, int32* _childChangeCounter, const char* _parameters)
|
||||
{
|
||||
// copy parameters in
|
||||
UserMemoryParameter<char, true> parameters;
|
||||
UserStringParameter<true> parameters;
|
||||
int32 changeCounter;
|
||||
int32 childChangeCounter;
|
||||
|
||||
status_t error;
|
||||
if ((error = parameters.Init(_parameters, parametersSize,
|
||||
B_DISK_DEVICE_MAX_PARAMETER_SIZE)) != B_OK
|
||||
if ((error = parameters.Init(_parameters, B_DISK_DEVICE_MAX_PARAMETER_SIZE))
|
||||
!= B_OK
|
||||
|| (error = copy_from_user_value(changeCounter, _changeCounter))
|
||||
!= B_OK
|
||||
|| (error = copy_from_user_value(childChangeCounter,
|
||||
@ -1118,17 +1073,16 @@ _user_set_partition_parameters(partition_id partitionID, int32* _changeCounter,
|
||||
|
||||
status_t
|
||||
_user_set_partition_content_parameters(partition_id partitionID,
|
||||
int32* _changeCounter, const char* _parameters, size_t parametersSize)
|
||||
int32* _changeCounter, const char* _parameters)
|
||||
{
|
||||
// copy parameters in
|
||||
UserMemoryParameter<char, true> parameters;
|
||||
UserStringParameter<true> parameters;
|
||||
int32 changeCounter;
|
||||
|
||||
status_t error;
|
||||
if ((error = parameters.Init(_parameters, parametersSize,
|
||||
B_DISK_DEVICE_MAX_PARAMETER_SIZE)) != B_OK
|
||||
|| (error = copy_from_user_value(changeCounter, _changeCounter))
|
||||
!= B_OK) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1179,26 +1133,26 @@ _user_set_partition_content_parameters(partition_id partitionID,
|
||||
|
||||
status_t
|
||||
_user_initialize_partition(partition_id partitionID, int32* _changeCounter,
|
||||
const char* _diskSystemName, const char* _name, const char* _parameters,
|
||||
size_t parametersSize)
|
||||
const char* _diskSystemName, const char* _name, const char* _parameters)
|
||||
{
|
||||
// copy parameters in
|
||||
UserStringParameter<false> diskSystemName;
|
||||
UserStringParameter<true> name;
|
||||
UserMemoryParameter<char, true> parameters;
|
||||
UserStringParameter<true> parameters;
|
||||
int32 changeCounter;
|
||||
|
||||
status_t error;
|
||||
if ((error = diskSystemName.Init(_diskSystemName,
|
||||
B_DISK_SYSTEM_NAME_LENGTH)) != B_OK
|
||||
|| (error = name.Init(_name, B_DISK_DEVICE_NAME_LENGTH)) != B_OK
|
||||
|| (error = parameters.Init(_parameters, parametersSize,
|
||||
B_DISK_DEVICE_MAX_PARAMETER_SIZE)) != B_OK
|
||||
|| (error = parameters.Init(_parameters,
|
||||
B_DISK_DEVICE_MAX_PARAMETER_SIZE)) != B_OK
|
||||
|| (error = copy_from_user_value(changeCounter, _changeCounter))
|
||||
!= B_OK) {
|
||||
!= B_OK) {
|
||||
return error;
|
||||
}
|
||||
|
||||
dprintf("_parameters");
|
||||
// get the partition
|
||||
KDiskDeviceManager* manager = KDiskDeviceManager::Default();
|
||||
KPartition* partition = manager->WriteLockPartition(partitionID);
|
||||
@ -1305,22 +1259,21 @@ _user_uninitialize_partition(partition_id partitionID, int32* _changeCounter)
|
||||
status_t
|
||||
_user_create_child_partition(partition_id partitionID, int32* _changeCounter,
|
||||
off_t offset, off_t size, const char* _type, const char* _name,
|
||||
const char* _parameters, size_t parametersSize, partition_id* childID,
|
||||
int32* childChangeCounter)
|
||||
const char* _parameters, partition_id* childID, int32* childChangeCounter)
|
||||
{
|
||||
// copy parameters in
|
||||
UserStringParameter<false> type;
|
||||
UserStringParameter<true> name;
|
||||
UserMemoryParameter<char, true> parameters;
|
||||
UserStringParameter<true> parameters;
|
||||
int32 changeCounter;
|
||||
|
||||
status_t error;
|
||||
if ((error = type.Init(_type, B_DISK_DEVICE_TYPE_LENGTH)) != B_OK
|
||||
|| (error = name.Init(_name, B_DISK_DEVICE_NAME_LENGTH)) != B_OK
|
||||
|| (error = parameters.Init(_parameters, parametersSize,
|
||||
B_DISK_DEVICE_MAX_PARAMETER_SIZE)) != B_OK
|
||||
|| (error = parameters.Init(_parameters,
|
||||
B_DISK_DEVICE_MAX_PARAMETER_SIZE)) != B_OK
|
||||
|| (error = copy_from_user_value(changeCounter, _changeCounter))
|
||||
!= B_OK) {
|
||||
!= B_OK) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user