* Style cleanup.
* Moved method documentation from headers to source files. * Fixed small problems (memory leaks, unsafe string duplication,...). * Added TODOs where I spotted problems. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21721 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
// KDiskDeviceJob.h
|
||||
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
* Lubos Kulic
|
||||
*/
|
||||
#ifndef _K_DISK_DEVICE_JOB_H
|
||||
#define _K_DISK_DEVICE_JOB_H
|
||||
|
||||
@@ -15,38 +21,19 @@ class KDiskDeviceJobQueue;
|
||||
|
||||
/**
|
||||
* Represents some action executed on the disk device.
|
||||
*
|
||||
* -
|
||||
*/
|
||||
class KDiskDeviceJob {
|
||||
public:
|
||||
/**
|
||||
* Creates a new job
|
||||
*
|
||||
* \param type actual type of the job (see DiskDeviceDefs.h for details)
|
||||
* \param partitionID the partition/device on which the action should be executed
|
||||
* \param scopeID partition/device which is the highest in the hierarchy (i.e. closest
|
||||
* to the root) that can be affected by the action
|
||||
* - every descendant of this partition is marked busy and all ancestors are marked descendant-
|
||||
busy
|
||||
*/
|
||||
KDiskDeviceJob(uint32 type, partition_id partitionID,
|
||||
partition_id scopeID = -1);
|
||||
virtual ~KDiskDeviceJob();
|
||||
|
||||
/**
|
||||
* Unique identification of the job
|
||||
*/
|
||||
disk_job_id ID() const;
|
||||
|
||||
void SetJobQueue(KDiskDeviceJobQueue *queue);
|
||||
KDiskDeviceJobQueue *JobQueue() const;
|
||||
|
||||
/**
|
||||
* Gets actual type of the action
|
||||
*/
|
||||
uint32 Type() const;
|
||||
|
||||
|
||||
void SetStatus(uint32 status);
|
||||
uint32 Status() const;
|
||||
@@ -81,21 +68,6 @@ public:
|
||||
status_t GetInfo(user_disk_device_job_info *info);
|
||||
status_t GetProgressInfo(disk_device_job_progress_info *info);
|
||||
|
||||
/**
|
||||
* Do the actual work of the job.
|
||||
*
|
||||
* - is supposed to be implemented in descendants
|
||||
* - doesn't have any parameter - every operation needs different ones -> they're passed
|
||||
* to the constructor
|
||||
* - the implementations will
|
||||
* - check the parameters given in constructor (e.g. if given partition exists...)
|
||||
* - check whether the partition has needed disk system (its own or parent - depends
|
||||
* on the operation)
|
||||
* - using the disk system, validate the operation for given params
|
||||
* - finally execute the action
|
||||
*
|
||||
* \return B_OK when everything went OK, some error otherwise
|
||||
*/
|
||||
virtual status_t Do() = 0;
|
||||
|
||||
private:
|
||||
@@ -116,27 +88,10 @@ private:
|
||||
|
||||
static disk_job_id fNextID;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Visitor which checks if every descendant of given partition is busy or descendant-busy
|
||||
*/
|
||||
struct IsNotBusyVisitor : KPartitionVisitor {
|
||||
virtual bool VisitPre(KPartition * partition);
|
||||
};
|
||||
IsNotBusyVisitor fNotBusyVisitor;
|
||||
|
||||
protected:
|
||||
//some stuff useful for all descendants
|
||||
// some stuff useful for all descendants
|
||||
|
||||
/**
|
||||
* Checks if there's any descendant which is not busy/descendant-busy.
|
||||
*
|
||||
* - the condition of busy descendant is common for many disk device operations ->
|
||||
* many jobs can use this
|
||||
*
|
||||
* \param partition the root of checked subtree of the whole partition hieararchy
|
||||
*/
|
||||
bool isPartitionNotBusy( KPartition * partition );
|
||||
bool IsPartitionNotBusy(KPartition* partition);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// KDiskSystem.h
|
||||
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
*/
|
||||
#ifndef _K_DISK_DEVICE_SYSTEM_H
|
||||
#define _K_DISK_DEVICE_SYSTEM_H
|
||||
|
||||
@@ -13,7 +18,7 @@ namespace DiskDevice {
|
||||
class KDiskDeviceJob;
|
||||
class KPartition;
|
||||
|
||||
/// \brief Common ancestor for disk system add-on wrappers
|
||||
//! \brief Common ancestor for disk system add-on wrappers
|
||||
class KDiskSystem {
|
||||
public:
|
||||
KDiskSystem(const char *name);
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
// KFileSystem.h
|
||||
//
|
||||
// KFileSystem implements the KDiskSystem interface for file systems.
|
||||
// It works with the FS API.
|
||||
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
*
|
||||
* KFileSystem implements the KDiskSystem interface for file systems.
|
||||
* It works with the FS API.
|
||||
*/
|
||||
#ifndef _K_FILE_DISK_DEVICE_SYSTEM_H
|
||||
#define _K_FILE_DISK_DEVICE_SYSTEM_H
|
||||
|
||||
@@ -13,7 +18,7 @@ struct file_system_module_info;
|
||||
namespace BPrivate {
|
||||
namespace DiskDevice {
|
||||
|
||||
/// \brief Wrapper for the C interface of a filesystem add-on.
|
||||
//! \brief Wrapper for the C interface of a filesystem add-on.
|
||||
class KFileSystem : public KDiskSystem {
|
||||
public:
|
||||
KFileSystem(const char *name);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// KPartition.h
|
||||
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
*/
|
||||
#ifndef _K_DISK_DEVICE_PARTITION_H
|
||||
#define _K_DISK_DEVICE_PARTITION_H
|
||||
|
||||
@@ -21,7 +26,7 @@ class KPath;
|
||||
class KPhysicalPartition;
|
||||
class KShadowPartition;
|
||||
|
||||
/// \brief Class representing a single partition.
|
||||
//! \brief Class representing a single partition.
|
||||
class KPartition {
|
||||
public:
|
||||
KPartition(partition_id id = -1);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// KPartitioningSystem.h
|
||||
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
*/
|
||||
#ifndef _K_PARTITIONING_DISK_DEVICE_SYSTEM_H
|
||||
#define _K_PARTITIONING_DISK_DEVICE_SYSTEM_H
|
||||
|
||||
@@ -24,9 +29,9 @@ public:
|
||||
|
||||
// Scanning
|
||||
|
||||
/// Try to identify a given partition
|
||||
//! Try to identify a given partition
|
||||
virtual float Identify(KPartition *partition, void **cookie);
|
||||
/// Scan the partition
|
||||
//! Scan the partition
|
||||
virtual status_t Scan(KPartition *partition, void *cookie);
|
||||
virtual void FreeIdentifyCookie(KPartition *partition, void *cookie);
|
||||
virtual void FreeCookie(KPartition *partition);
|
||||
@@ -34,132 +39,132 @@ public:
|
||||
|
||||
// Querying
|
||||
|
||||
/// Check whether the add-on supports repairing this partition.
|
||||
//! Check whether the add-on supports repairing this partition.
|
||||
virtual bool SupportsRepairing(KPartition *partition, bool checkOnly,
|
||||
bool *whileMounted);
|
||||
/// Check whether the add-on supports resizing this partition.
|
||||
//! Check whether the add-on supports resizing this partition.
|
||||
virtual bool SupportsResizing(KPartition *partition, bool *whileMounted);
|
||||
/// Check whether the add-on supports resizing children of this partition.
|
||||
//! Check whether the add-on supports resizing children of this partition.
|
||||
virtual bool SupportsResizingChild(KPartition *child);
|
||||
/// Check whether the add-on supports moving this partition.
|
||||
//! Check whether the add-on supports moving this partition.
|
||||
virtual bool SupportsMoving(KPartition *partition, bool *isNoOp);
|
||||
/// Check whether the add-on supports moving children of this partition.
|
||||
//! Check whether the add-on supports moving children of this partition.
|
||||
virtual bool SupportsMovingChild(KPartition *child);
|
||||
/// Check whether the add-on supports setting name of this partition.
|
||||
//! Check whether the add-on supports setting name of this partition.
|
||||
virtual bool SupportsSettingName(KPartition *partition);
|
||||
/// Check whether the add-on supports setting name to content of this partition.
|
||||
//! Check whether the add-on supports setting name to content of this partition.
|
||||
virtual bool SupportsSettingContentName(KPartition *partition,
|
||||
bool *whileMounted);
|
||||
/// Check whether the add-on supports setting type of this partition.
|
||||
//! Check whether the add-on supports setting type of this partition.
|
||||
virtual bool SupportsSettingType(KPartition *partition);
|
||||
/// Check whether the add-on supports setting parameters of this partition.
|
||||
//! Check whether the add-on supports setting parameters of this partition.
|
||||
virtual bool SupportsSettingParameters(KPartition *partition);
|
||||
/// Check whether the add-on supports setting parameters to content of this partition.
|
||||
//! Check whether the add-on supports setting parameters to content of this partition.
|
||||
virtual bool SupportsSettingContentParameters(KPartition *partition,
|
||||
bool *whileMounted);
|
||||
/// Check whether the add-on supports initializing this partition.
|
||||
//! Check whether the add-on supports initializing this partition.
|
||||
virtual bool SupportsInitializing(KPartition *partition);
|
||||
/// Check whether the add-on supports initializing a child of this partition.
|
||||
//! Check whether the add-on supports initializing a child of this partition.
|
||||
virtual bool SupportsInitializingChild(KPartition *child,
|
||||
const char *diskSystem);
|
||||
/// Check whether the add-on supports creating children of this partition.
|
||||
//! Check whether the add-on supports creating children of this partition.
|
||||
virtual bool SupportsCreatingChild(KPartition *partition);
|
||||
/// Check whether the add-on supports deleting children of this partition.
|
||||
//! Check whether the add-on supports deleting children of this partition.
|
||||
virtual bool SupportsDeletingChild(KPartition *child);
|
||||
/// Check whether the add-on is a subsystem for a given partition.
|
||||
//! Check whether the add-on is a subsystem for a given partition.
|
||||
virtual bool IsSubSystemFor(KPartition *partition);
|
||||
|
||||
/// Validates parameters for resizing a partition
|
||||
//! Validates parameters for resizing a partition
|
||||
virtual bool ValidateResize(KPartition *partition, off_t *size);
|
||||
/// Validates parameters for resizing a child partition
|
||||
//! Validates parameters for resizing a child partition
|
||||
virtual bool ValidateResizeChild(KPartition *child, off_t *size);
|
||||
/// Validates parameters for moving a partition
|
||||
//! Validates parameters for moving a partition
|
||||
virtual bool ValidateMove(KPartition *partition, off_t *start);
|
||||
/// Validates parameters for moving a child partition
|
||||
//! Validates parameters for moving a child partition
|
||||
virtual bool ValidateMoveChild(KPartition *child, off_t *start);
|
||||
/// Validates parameters for setting name of a partition
|
||||
//! Validates parameters for setting name of a partition
|
||||
virtual bool ValidateSetName(KPartition *partition, char *name);
|
||||
/// Validates parameters for setting name to content of a partition
|
||||
//! Validates parameters for setting name to content of a partition
|
||||
virtual bool ValidateSetContentName(KPartition *partition, char *name);
|
||||
/// Validates parameters for setting type of a partition
|
||||
//! Validates parameters for setting type of a partition
|
||||
virtual bool ValidateSetType(KPartition *partition, const char *type);
|
||||
/// Validates parameters for setting parameters of a partition
|
||||
//! Validates parameters for setting parameters of a partition
|
||||
virtual bool ValidateSetParameters(KPartition *partition,
|
||||
const char *parameters);
|
||||
/// Validates parameters for setting parameters to content of a partition
|
||||
//! Validates parameters for setting parameters to content of a partition
|
||||
virtual bool ValidateSetContentParameters(KPartition *parameters,
|
||||
const char *parameters);
|
||||
/// Validates parameters for initializing a partition
|
||||
//! Validates parameters for initializing a partition
|
||||
virtual bool ValidateInitialize(KPartition *partition, char *name,
|
||||
const char *parameters);
|
||||
/// Validates parameters for creating child of a partition
|
||||
//! Validates parameters for creating child of a partition
|
||||
virtual bool ValidateCreateChild(KPartition *partition, off_t *start,
|
||||
off_t *size, const char *type,
|
||||
const char *parameters, int32 *index);
|
||||
/// Counts partitionable spaces on a partition
|
||||
//! Counts partitionable spaces on a partition
|
||||
virtual int32 CountPartitionableSpaces(KPartition *partition);
|
||||
/// Retrieves a list of partitionable spaces on a partition
|
||||
//! Retrieves a list of partitionable spaces on a partition
|
||||
virtual status_t GetPartitionableSpaces(KPartition *partition,
|
||||
partitionable_space_data *buffer,
|
||||
int32 count,
|
||||
int32 *actualCount = NULL);
|
||||
|
||||
/// Iterates through supported partition types
|
||||
//! Iterates through supported partition types
|
||||
virtual status_t GetNextSupportedType(KPartition *partition, int32 *cookie,
|
||||
char *type);
|
||||
/// Translates the "pretty" content type to an internal type
|
||||
//! Translates the "pretty" content type to an internal type
|
||||
virtual status_t GetTypeForContentType(const char *contentType,
|
||||
char *type);
|
||||
|
||||
// Shadow partition modification
|
||||
|
||||
/// Calls for additional modifications when shadow partition is changed
|
||||
//! Calls for additional modifications when shadow partition is changed
|
||||
virtual status_t ShadowPartitionChanged(KPartition *partition,
|
||||
uint32 operation);
|
||||
|
||||
// Writing
|
||||
|
||||
/// Repairs a partition
|
||||
//! Repairs a partition
|
||||
virtual status_t Repair(KPartition *partition, bool checkOnly,
|
||||
KDiskDeviceJob *job);
|
||||
/// Resizes a partition
|
||||
//! Resizes a partition
|
||||
virtual status_t Resize(KPartition *partition, off_t size,
|
||||
KDiskDeviceJob *job);
|
||||
/// Resizes child of a partition
|
||||
//! Resizes child of a partition
|
||||
virtual status_t ResizeChild(KPartition *child, off_t size,
|
||||
KDiskDeviceJob *job);
|
||||
/// Moves a partition
|
||||
//! Moves a partition
|
||||
virtual status_t Move(KPartition *partition, off_t offset,
|
||||
KDiskDeviceJob *job);
|
||||
/// Moves child of a partition
|
||||
//! Moves child of a partition
|
||||
virtual status_t MoveChild(KPartition *child, off_t offset,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets name to a partition
|
||||
//! Sets name of a partition
|
||||
virtual status_t SetName(KPartition *partition, char *name,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets name to content of a partition
|
||||
//! Sets name of the content of a partition
|
||||
virtual status_t SetContentName(KPartition *partition, char *name,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets type of a partition
|
||||
//! Sets type of a partition
|
||||
virtual status_t SetType(KPartition *partition, char *type,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets parameters of a partition
|
||||
//! Sets parameters of a partition
|
||||
virtual status_t SetParameters(KPartition *partition,
|
||||
const char *parameters,
|
||||
KDiskDeviceJob *job);
|
||||
/// Sets parameters to content of a partition
|
||||
//! Sets parameters to content of a partition
|
||||
virtual status_t SetContentParameters(KPartition *partition,
|
||||
const char *parameters,
|
||||
KDiskDeviceJob *job);
|
||||
/// Creates a child partition
|
||||
//! Creates a child partition
|
||||
virtual status_t CreateChild(KPartition *partition, off_t offset,
|
||||
off_t size, const char *type,
|
||||
const char *parameters, KDiskDeviceJob *job,
|
||||
KPartition **child = NULL,
|
||||
partition_id childID = -1);
|
||||
/// Deletes a child partition
|
||||
//! Deletes a child partition
|
||||
virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job);
|
||||
/// Initializes a partition with this partitioning system
|
||||
//! Initializes a partition with this partitioning system
|
||||
virtual status_t Initialize(KPartition *partition, const char *name,
|
||||
const char *parameters, KDiskDeviceJob *job);
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// KPartition.h
|
||||
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
*/
|
||||
#ifndef _K_DISK_DEVICE_PHYSICAL_PARTITION_H
|
||||
#define _K_DISK_DEVICE_PHYSICAL_PARTITION_H
|
||||
|
||||
@@ -12,7 +17,7 @@ class KDiskDevice;
|
||||
class KDiskSystem;
|
||||
class KShadowPartition;
|
||||
|
||||
/// \brief Class representing an existing partition.
|
||||
//! \brief Class representing an existing partition.
|
||||
class KPhysicalPartition : public KPartition {
|
||||
public:
|
||||
KPhysicalPartition(partition_id id = -1);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// KPartition.h
|
||||
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
*/
|
||||
#ifndef _K_DISK_DEVICE_SHADOW_PARTITION_H
|
||||
#define _K_DISK_DEVICE_SHADOW_PARTITION_H
|
||||
|
||||
@@ -11,9 +16,10 @@ namespace DiskDevice {
|
||||
|
||||
class KPhysicalPartition;
|
||||
|
||||
/// \brief Class representing a shadow of an existing partition.
|
||||
///
|
||||
/// See \ref path_kernel_structures for more information.
|
||||
/*! \brief Class representing a shadow of an existing partition.
|
||||
|
||||
See \ref path_kernel_structures for more information.
|
||||
*/
|
||||
class KShadowPartition : public KPartition, private KPartitionListener {
|
||||
public:
|
||||
KShadowPartition(KPhysicalPartition *physicalPartition);
|
||||
|
||||
Reference in New Issue
Block a user