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:
parent
c22ee2bf75
commit
6b6f6b7240
@ -49,6 +49,7 @@ public:
|
||||
virtual status_t Open(int flags, int *fd);
|
||||
virtual status_t PublishDevice();
|
||||
virtual status_t UnpublishDevice();
|
||||
bool IsPublished() const;
|
||||
|
||||
void SetBusy(bool busy);
|
||||
bool IsBusy() const;
|
||||
@ -234,6 +235,7 @@ protected:
|
||||
uint32 fAlgorithmData;
|
||||
int32 fReferenceCount;
|
||||
bool fObsolete;
|
||||
bool fPublished;
|
||||
static int32 fNextID;
|
||||
};
|
||||
|
||||
|
@ -31,6 +31,7 @@ KDiskDevice::KDiskDevice(partition_id id)
|
||||
{
|
||||
Unset();
|
||||
fDevice = this;
|
||||
fPublished = true;
|
||||
}
|
||||
|
||||
// destructor
|
||||
|
@ -46,7 +46,8 @@ KPartition::KPartition(partition_id id)
|
||||
fChangeCounter(0),
|
||||
fAlgorithmData(0),
|
||||
fReferenceCount(0),
|
||||
fObsolete(false)
|
||||
fObsolete(false),
|
||||
fPublished(false)
|
||||
{
|
||||
fPartitionData.id = (id >= 0 ? id : _NextID());
|
||||
fPartitionData.offset = 0;
|
||||
@ -164,6 +165,15 @@ KPartition::UnpublishDevice()
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
// IsPublished
|
||||
bool
|
||||
KPartition::IsPublished() const
|
||||
{
|
||||
return fPublished;
|
||||
}
|
||||
|
||||
|
||||
// SetBusy
|
||||
void
|
||||
KPartition::SetBusy(bool busy)
|
||||
|
@ -37,7 +37,6 @@ KPhysicalPartition::~KPhysicalPartition()
|
||||
{
|
||||
}
|
||||
|
||||
// Register
|
||||
// PrepareForRemoval
|
||||
bool
|
||||
KPhysicalPartition::PrepareForRemoval()
|
||||
@ -72,6 +71,9 @@ KPhysicalPartition::Open(int flags, int *fd)
|
||||
status_t
|
||||
KPhysicalPartition::PublishDevice()
|
||||
{
|
||||
if (fPublished)
|
||||
return B_OK;
|
||||
|
||||
// get the path
|
||||
KPath path;
|
||||
status_t error = GetPath(&path);
|
||||
@ -90,20 +92,31 @@ KPhysicalPartition::PublishDevice()
|
||||
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
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
fPublished = true;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// UnpublishDevice
|
||||
status_t
|
||||
KPhysicalPartition::UnpublishDevice()
|
||||
{
|
||||
if (!fPublished)
|
||||
return B_OK;
|
||||
|
||||
// get the path
|
||||
KPath path;
|
||||
status_t error = GetPath(&path);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
fPublished = false;
|
||||
|
||||
return devfs_unpublish_partition(path.Path() + 5);
|
||||
// we need to remove the "/dev/" part from the path
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user