Now calls the new devfs partition (un)publishing calls.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7974 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-06-15 15:38:55 +00:00
parent 0d961b9fbc
commit 5d5716e614
@@ -9,6 +9,7 @@
#include <Drivers.h> #include <Drivers.h>
#include <Errors.h> #include <Errors.h>
#include <util/kernel_cpp.h> #include <util/kernel_cpp.h>
#include <devfs.h>
#include "KDiskDevice.h" #include "KDiskDevice.h"
#include "KDiskDeviceManager.h" #include "KDiskDeviceManager.h"
@@ -70,9 +71,11 @@ KPhysicalPartition::Open(int flags, int *fd)
status_t status_t
KPhysicalPartition::PublishDevice() KPhysicalPartition::PublishDevice()
{ {
// ToDo! char path[B_PATH_NAME_LENGTH];
return B_ERROR; status_t error = GetPath(path);
#if 0 if (error != B_OK)
return error;
// prepare a partition_info // prepare a partition_info
partition_info info; partition_info info;
info.offset = Offset(); info.offset = Offset();
@@ -80,42 +83,23 @@ KPhysicalPartition::PublishDevice()
info.logical_block_size = BlockSize(); info.logical_block_size = BlockSize();
info.session = 0; info.session = 0;
info.partition = ID(); info.partition = ID();
if (strlen(Device()->Path()) >= 256) if (strlcpy(info.device, Device()->Path(), B_PATH_NAME_LENGTH) > B_PATH_NAME_LENGTH)
return B_NAME_TOO_LONG; return B_NAME_TOO_LONG;
strcpy(info.device, Device()->Path());
// get the entry path return devfs_publish_partition(path, &info);
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;
#endif
} }
// UnpublishDevice // UnpublishDevice
status_t status_t
KPhysicalPartition::UnpublishDevice() KPhysicalPartition::UnpublishDevice()
{ {
#if 0
// get the entry path // get the entry path
char path[B_PATH_NAME_LENGTH]; char path[B_PATH_NAME_LENGTH];
status_t error = GetPath(path); status_t error = GetPath(path);
if (error != B_OK) if (error != B_OK)
return error; return error;
// remove the entry
if (remove(path) < 0) return devfs_unpublish_partition(path);
return errno;
#endif
return B_OK;
} }
// Mount // Mount