* Removing new_vnode which was commented out in favor of publish_vnode

in order to publish the root node
* fixed _RootVNodeID assignement
* Applying our coding guidelines

Mounting now goes as far as lookup, then I get a panic from w>Desktop
thread in CreateVolume -> GetRootDirectory. ;-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27104 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Salvatore Benedetto
2008-08-21 11:56:25 +00:00
parent c9334140f6
commit e0c8039816
2 changed files with 100 additions and 95 deletions
+32 -28
View File
@@ -11,6 +11,8 @@
#include "PhysicalPartition.h" #include "PhysicalPartition.h"
#include "Recognition.h" #include "Recognition.h"
extern fs_volume_ops gUDFVolumeOps;
extern fs_vnode_ops gUDFVnodeOps;
/*! \brief Creates an unmounted volume with the given id. */ /*! \brief Creates an unmounted volume with the given id. */
Volume::Volume(fs_volume *fsVolume) Volume::Volume(fs_volume *fsVolume)
@@ -87,9 +89,10 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length,
partitionDescriptorCount); partitionDescriptorCount);
// Set up the block cache // Set up the block cache
if (!status) if (!status) {
TRACE(("Volume::Mount: partition recognized\n"));
fBlockCache = block_cache_create(device, length, blockSize, IsReadOnly()); fBlockCache = block_cache_create(device, length, blockSize, IsReadOnly());
else { } else {
TRACE_ERROR(("Volume::Mount: failed to recognize partition\n")); TRACE_ERROR(("Volume::Mount: failed to recognize partition\n"));
return status; return status;
} }
@@ -100,40 +103,36 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length,
int metadataCount = 0; int metadataCount = 0;
// Set up the partitions // Set up the partitions
if (!status) {
// Set up physical and sparable partitions first // Set up physical and sparable partitions first
int offset = 0; offset = 0;
for (uint8 i = 0; i < logicalVolumeDescriptor.partition_map_count() for (uint8 i = 0; i < logicalVolumeDescriptor.partition_map_count()
&& !status; i++) && !status; i++)
{ {
uint8 *maps = logicalVolumeDescriptor.partition_maps(); uint8 *maps = logicalVolumeDescriptor.partition_maps();
partition_map_header *header = partition_map_header *header = (partition_map_header *)(maps + offset);
reinterpret_cast<partition_map_header*>(maps+offset); TRACE(("Volume::Mount: partition map %d (type %d):\n", i,
TRACE(("partition map %d (type %d):\n", i, header->type())); header->type()));
if (header->type() == 1) { if (header->type() == 1) {
TRACE(("map type: physical\n")); TRACE(("Volume::Mount: map type -> physical\n"));
physical_partition_map* map = physical_partition_map* map = (physical_partition_map *)header;
reinterpret_cast<physical_partition_map*>(header);
// Find the corresponding partition descriptor // Find the corresponding partition descriptor
partition_descriptor *descriptor = NULL; partition_descriptor *descriptor = NULL;
for (uint8 j = 0; j < partitionDescriptorCount; j++) { for (uint8 j = 0; j < partitionDescriptorCount; j++) {
if (map->partition_number() == if (map->partition_number() ==
partitionDescriptors[j].partition_number()) partitionDescriptors[j].partition_number()) {
{
descriptor = &partitionDescriptors[j]; descriptor = &partitionDescriptors[j];
break; break;
} }
} }
// Create and add the partition // Create and add the partition
if (descriptor) { if (descriptor) {
PhysicalPartition *partition = new(nothrow) PhysicalPartition( PhysicalPartition *partition
map->partition_number(), = new(nothrow) PhysicalPartition(map->partition_number(),
descriptor->start(), descriptor->start(), descriptor->length());
descriptor->length());
status = partition ? B_OK : B_NO_MEMORY; status = partition ? B_OK : B_NO_MEMORY;
if (!status) { if (!status) {
TRACE(("Adding PhysicalPartition(number: %d, start: %ld, " TRACE(("Volume::Mount: adding PhysicalPartition(number: %d, "
"length: %ld)\n", map->partition_number(), "start: %ld, length: %ld)\n", map->partition_number(),
descriptor->start(), descriptor->length())); descriptor->start(), descriptor->length()));
status = _SetPartition(i, partition); status = _SetPartition(i, partition);
if (!status) if (!status)
@@ -178,7 +177,6 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length,
} }
offset += header->length(); offset += header->length();
} }
}
// Do some checking as to what sorts of partitions we've actually found. // Do some checking as to what sorts of partitions we've actually found.
if (!status) { if (!status) {
@@ -211,6 +209,7 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length,
// our partitions are all set up. We now need to investigate the file // our partitions are all set up. We now need to investigate the file
// set descriptor pointed to by the logical volume descriptor. // set descriptor pointed to by the logical volume descriptor.
if (!status) { if (!status) {
TRACE(("Volume::Mount: Partition has been set up\n"));
MemoryChunk chunk(logicalVolumeDescriptor.file_set_address().length()); MemoryChunk chunk(logicalVolumeDescriptor.file_set_address().length());
status = chunk.InitCheck(); status = chunk.InitCheck();
@@ -223,11 +222,11 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length,
if (!status) if (!status)
address <<= blockShift; address <<= blockShift;
if (!status) { if (!status) {
ssize_t bytesRead = read_pos(device, address, chunk.Data(), ssize_t bytesRead
blockSize); = read_pos(device, address, chunk.Data(), blockSize);
if (bytesRead != ssize_t(blockSize)) { if (bytesRead != ssize_t(blockSize)) {
status = B_IO_ERROR; status = B_IO_ERROR;
TRACE(("read_pos(pos:%Ld, len:%ld) failed with: 0x%lx\n", TRACE_ERROR(("read_pos(pos:%Ld, len:%ld) failed with: 0x%lx\n",
address, blockSize, bytesRead)); address, blockSize, bytesRead));
} }
} }
@@ -244,12 +243,16 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length,
if (!status) { if (!status) {
PDUMP(fileSet); PDUMP(fileSet);
fRootIcb = new(nothrow) Icb(this, fileSet->root_directory_icb()); fRootIcb = new(nothrow) Icb(this, fileSet->root_directory_icb());
status = fRootIcb ? fRootIcb->InitCheck() : B_NO_MEMORY; if (fRootIcb == NULL || fRootIcb->InitCheck() != B_OK)
return B_NO_MEMORY;
} }
TRACE(("Volume::Mount: Root Node id = %d\n", fRootIcb->Id()));
if (!status) { if (!status) {
//status = new_vnode(fFSVolume->Id(), RootIcb()->Id(), (void*)RootIcb()); status = publish_vnode(fFSVolume, fRootIcb->Id(), fRootIcb,
if (status) { &gUDFVnodeOps, fRootIcb->Mode(), 0);
TRACE(("Error creating vnode for root icb! " if (status != B_OK) {
TRACE_ERROR(("Error creating vnode for root icb! "
"status = 0x%lx, `%s'\n", status, "status = 0x%lx, `%s'\n", status,
strerror(status))); strerror(status)));
// Clean up the icb we created, since _Unset() // Clean up the icb we created, since _Unset()
@@ -257,6 +260,8 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length,
delete fRootIcb; delete fRootIcb;
fRootIcb = NULL; fRootIcb = NULL;
} }
TRACE(("Volume::Mount: Root vnode published. Id = %d\n",
fRootIcb->Id()));
} }
} }
} }
@@ -285,8 +290,7 @@ Volume::Name() const {
status_t status_t
Volume::MapBlock(long_address address, off_t *mappedBlock) Volume::MapBlock(long_address address, off_t *mappedBlock)
{ {
DEBUG_INIT_ETC("Volume", TRACE(("Volume::MapBlock: partition = %d, block = %ld, mappedBlock = %p\n",
("partition: %d, block: %ld, mappedBlock: %p",
address.partition(), address.block(), mappedBlock)); address.partition(), address.block(), mappedBlock));
status_t error = mappedBlock ? B_OK : B_BAD_VALUE; status_t error = mappedBlock ? B_OK : B_BAD_VALUE;
if (!error) { if (!error) {
@@ -174,7 +174,7 @@ udf_lookup(fs_volume *_volume, fs_vnode *_directory, const char *file,
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
} }
} }
TRACE(("udf_lookup: vnodeId: %Ld\n", *vnodeID)); TRACE(("udf_lookup: vnodeId = %Ld found!\n", *vnodeID));
return status; return status;
} }
@@ -439,8 +439,9 @@ udf_mount(fs_volume *_volume, const char *_device, uint32 flags,
_volume->private_volume = volume; _volume->private_volume = volume;
_volume->ops = &gUDFVolumeOps; _volume->ops = &gUDFVolumeOps;
*_rootVnodeID = *(ino_t *)volume->RootIcb(); *_rootVnodeID = volume->RootIcb()->Id();
TRACE(("udf_mount: succefully mounted the partition\n"));
return B_OK; return B_OK;
} }