* Made {Publish,Unpublish}Device() virtual and implemented them in
KPartition and as no-ops in KDiskDevice. * Prefixed partition names with "obos_" to not interfere with R5's partition names. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3509 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -41,6 +41,9 @@ public:
|
|||||||
|
|
||||||
virtual void SetID(partition_id id);
|
virtual void SetID(partition_id id);
|
||||||
|
|
||||||
|
virtual status_t PublishDevice();
|
||||||
|
virtual status_t UnpublishDevice();
|
||||||
|
|
||||||
void SetDeviceFlags(uint32 flags); // comprises the ones below
|
void SetDeviceFlags(uint32 flags); // comprises the ones below
|
||||||
uint32 DeviceFlags() const;
|
uint32 DeviceFlags() const;
|
||||||
bool IsRemovable() const;
|
bool IsRemovable() const;
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ public:
|
|||||||
int32 CountReferences() const;
|
int32 CountReferences() const;
|
||||||
|
|
||||||
status_t Open(int flags, int *fd);
|
status_t Open(int flags, int *fd);
|
||||||
status_t PublishDevice();
|
virtual status_t PublishDevice();
|
||||||
status_t UnpublishDevice();
|
virtual status_t UnpublishDevice();
|
||||||
|
|
||||||
void SetBusy(bool busy);
|
void SetBusy(bool busy);
|
||||||
bool IsBusy() const;
|
bool IsBusy() const;
|
||||||
|
|||||||
@@ -125,6 +125,25 @@ KDiskDevice::SetID(partition_id id)
|
|||||||
fDeviceData.id = id;
|
fDeviceData.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PublishDevice
|
||||||
|
status_t
|
||||||
|
KDiskDevice::PublishDevice()
|
||||||
|
{
|
||||||
|
// PublishDevice() and UnpublishDevice() are no-ops for KDiskDevices,
|
||||||
|
// since they are always published.
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnpublishDevice
|
||||||
|
status_t
|
||||||
|
KDiskDevice::UnpublishDevice()
|
||||||
|
{
|
||||||
|
// PublishDevice() and UnpublishDevice() are no-ops for KDiskDevices,
|
||||||
|
// since they are always published.
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetDeviceFlags
|
// SetDeviceFlags
|
||||||
void
|
void
|
||||||
KDiskDevice::SetDeviceFlags(uint32 flags)
|
KDiskDevice::SetDeviceFlags(uint32 flags)
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Drivers.h>
|
||||||
#include <Errors.h>
|
#include <Errors.h>
|
||||||
|
|
||||||
//#include <Partition.h>
|
//#include <Partition.h>
|
||||||
@@ -103,16 +105,46 @@ KPartition::Open(int flags, int *fd)
|
|||||||
status_t
|
status_t
|
||||||
KPartition::PublishDevice()
|
KPartition::PublishDevice()
|
||||||
{
|
{
|
||||||
// not implemented
|
// prepare a partition_info
|
||||||
return B_ERROR;
|
partition_info info;
|
||||||
|
info.offset = Offset();
|
||||||
|
info.size = Size();
|
||||||
|
info.logical_block_size = BlockSize();
|
||||||
|
info.session = 0;
|
||||||
|
info.partition = ID();
|
||||||
|
if (strlen(Device()->Path()) >= 256)
|
||||||
|
return B_NAME_TOO_LONG;
|
||||||
|
strcpy(info.device, Device()->Path());
|
||||||
|
// get the entry path
|
||||||
|
char path[B_PATH_NAME_LENGTH];
|
||||||
|
status_t error = GetPath(path);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
// create the entry
|
||||||
|
int fd = creat(path, 0666);
|
||||||
|
if (fd < 0)
|
||||||
|
return errno;
|
||||||
|
// set the partition info
|
||||||
|
error = B_OK;
|
||||||
|
if (ioctl(fd, B_SET_PARTITION, &info) < 0)
|
||||||
|
error = errno;
|
||||||
|
close(fd);
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnpublishDevice
|
// UnpublishDevice
|
||||||
status_t
|
status_t
|
||||||
KPartition::UnpublishDevice()
|
KPartition::UnpublishDevice()
|
||||||
{
|
{
|
||||||
// not implemented
|
// get the entry path
|
||||||
return B_ERROR;
|
char path[B_PATH_NAME_LENGTH];
|
||||||
|
status_t error = GetPath(path);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
// remove the entry
|
||||||
|
if (remove(path) < 0)
|
||||||
|
return errno;
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetBusy
|
// SetBusy
|
||||||
@@ -381,7 +413,10 @@ KPartition::GetPath(char *path) const
|
|||||||
int32 leafLen = strlen("/raw");
|
int32 leafLen = strlen("/raw");
|
||||||
if (len <= leafLen || strcmp(path + len - leafLen, "/raw"))
|
if (len <= leafLen || strcmp(path + len - leafLen, "/raw"))
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
sprintf(path + len - leafLen + 1, "%ld", Index());
|
// TODO: For the time being the name is "obos_*" to not interfere with R5's
|
||||||
|
// names.
|
||||||
|
// sprintf(path + len - leafLen + 1, "%ld", Index());
|
||||||
|
sprintf(path + len - leafLen + 1, "obos_%ld", Index());
|
||||||
} else {
|
} else {
|
||||||
// Our parent is a normal partition, no device: Append our index.
|
// Our parent is a normal partition, no device: Append our index.
|
||||||
sprintf(path + len, "_%ld", Index());
|
sprintf(path + len, "_%ld", Index());
|
||||||
|
|||||||
Reference in New Issue
Block a user