Partitions do now know whether they have already been published and
avoid attempts to publish a second time. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22198 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -49,6 +49,7 @@ public:
|
|||||||
virtual status_t Open(int flags, int *fd);
|
virtual status_t Open(int flags, int *fd);
|
||||||
virtual status_t PublishDevice();
|
virtual status_t PublishDevice();
|
||||||
virtual status_t UnpublishDevice();
|
virtual status_t UnpublishDevice();
|
||||||
|
bool IsPublished() const;
|
||||||
|
|
||||||
void SetBusy(bool busy);
|
void SetBusy(bool busy);
|
||||||
bool IsBusy() const;
|
bool IsBusy() const;
|
||||||
@@ -234,6 +235,7 @@ protected:
|
|||||||
uint32 fAlgorithmData;
|
uint32 fAlgorithmData;
|
||||||
int32 fReferenceCount;
|
int32 fReferenceCount;
|
||||||
bool fObsolete;
|
bool fObsolete;
|
||||||
|
bool fPublished;
|
||||||
static int32 fNextID;
|
static int32 fNextID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ KDiskDevice::KDiskDevice(partition_id id)
|
|||||||
{
|
{
|
||||||
Unset();
|
Unset();
|
||||||
fDevice = this;
|
fDevice = this;
|
||||||
|
fPublished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ KPartition::KPartition(partition_id id)
|
|||||||
fChangeCounter(0),
|
fChangeCounter(0),
|
||||||
fAlgorithmData(0),
|
fAlgorithmData(0),
|
||||||
fReferenceCount(0),
|
fReferenceCount(0),
|
||||||
fObsolete(false)
|
fObsolete(false),
|
||||||
|
fPublished(false)
|
||||||
{
|
{
|
||||||
fPartitionData.id = (id >= 0 ? id : _NextID());
|
fPartitionData.id = (id >= 0 ? id : _NextID());
|
||||||
fPartitionData.offset = 0;
|
fPartitionData.offset = 0;
|
||||||
@@ -164,6 +165,15 @@ KPartition::UnpublishDevice()
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// IsPublished
|
||||||
|
bool
|
||||||
|
KPartition::IsPublished() const
|
||||||
|
{
|
||||||
|
return fPublished;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetBusy
|
// SetBusy
|
||||||
void
|
void
|
||||||
KPartition::SetBusy(bool busy)
|
KPartition::SetBusy(bool busy)
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ KPhysicalPartition::~KPhysicalPartition()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register
|
|
||||||
// PrepareForRemoval
|
// PrepareForRemoval
|
||||||
bool
|
bool
|
||||||
KPhysicalPartition::PrepareForRemoval()
|
KPhysicalPartition::PrepareForRemoval()
|
||||||
@@ -72,6 +71,9 @@ KPhysicalPartition::Open(int flags, int *fd)
|
|||||||
status_t
|
status_t
|
||||||
KPhysicalPartition::PublishDevice()
|
KPhysicalPartition::PublishDevice()
|
||||||
{
|
{
|
||||||
|
if (fPublished)
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
// get the path
|
// get the path
|
||||||
KPath path;
|
KPath path;
|
||||||
status_t error = GetPath(&path);
|
status_t error = GetPath(&path);
|
||||||
@@ -90,20 +92,31 @@ KPhysicalPartition::PublishDevice()
|
|||||||
return B_NAME_TOO_LONG;
|
return B_NAME_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return devfs_publish_partition(path.Path() + 5, &info);
|
error = devfs_publish_partition(path.Path() + 5, &info);
|
||||||
// we need to remove the "/dev/" part from the path
|
// we need to remove the "/dev/" part from the path
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
fPublished = true;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnpublishDevice
|
// UnpublishDevice
|
||||||
status_t
|
status_t
|
||||||
KPhysicalPartition::UnpublishDevice()
|
KPhysicalPartition::UnpublishDevice()
|
||||||
{
|
{
|
||||||
|
if (!fPublished)
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
// get the path
|
// get the path
|
||||||
KPath path;
|
KPath path;
|
||||||
status_t error = GetPath(&path);
|
status_t error = GetPath(&path);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
fPublished = false;
|
||||||
|
|
||||||
return devfs_unpublish_partition(path.Path() + 5);
|
return devfs_unpublish_partition(path.Path() + 5);
|
||||||
// we need to remove the "/dev/" part from the path
|
// we need to remove the "/dev/" part from the path
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user