* 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:
@@ -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,84 +103,79 @@ 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
|
offset = 0;
|
||||||
int 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 *)(maps + offset);
|
||||||
partition_map_header *header =
|
TRACE(("Volume::Mount: partition map %d (type %d):\n", i,
|
||||||
reinterpret_cast<partition_map_header*>(maps+offset);
|
header->type()));
|
||||||
TRACE(("partition map %d (type %d):\n", i, header->type()));
|
if (header->type() == 1) {
|
||||||
if (header->type() == 1) {
|
TRACE(("Volume::Mount: map type -> physical\n"));
|
||||||
TRACE(("map type: physical\n"));
|
physical_partition_map* map = (physical_partition_map *)header;
|
||||||
physical_partition_map* map =
|
// Find the corresponding partition descriptor
|
||||||
reinterpret_cast<physical_partition_map*>(header);
|
partition_descriptor *descriptor = NULL;
|
||||||
// Find the corresponding partition descriptor
|
for (uint8 j = 0; j < partitionDescriptorCount; j++) {
|
||||||
partition_descriptor *descriptor = NULL;
|
if (map->partition_number() ==
|
||||||
for (uint8 j = 0; j < partitionDescriptorCount; j++) {
|
partitionDescriptors[j].partition_number()) {
|
||||||
if (map->partition_number() ==
|
descriptor = &partitionDescriptors[j];
|
||||||
partitionDescriptors[j].partition_number())
|
break;
|
||||||
{
|
|
||||||
descriptor = &partitionDescriptors[j];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Create and add the partition
|
}
|
||||||
if (descriptor) {
|
// Create and add the partition
|
||||||
PhysicalPartition *partition = new(nothrow) PhysicalPartition(
|
if (descriptor) {
|
||||||
map->partition_number(),
|
PhysicalPartition *partition
|
||||||
descriptor->start(),
|
= new(nothrow) PhysicalPartition(map->partition_number(),
|
||||||
descriptor->length());
|
descriptor->start(), 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)
|
||||||
physicalCount++;
|
physicalCount++;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
TRACE(("no matching partition descriptor found!\n"));
|
|
||||||
status = B_ERROR;
|
|
||||||
}
|
|
||||||
} else if (header->type() == 2) {
|
|
||||||
// Figure out what kind of type 2 partition map we have based
|
|
||||||
// on the type identifier
|
|
||||||
const entity_id &typeId = header->partition_type_id();
|
|
||||||
DUMP(typeId);
|
|
||||||
DUMP(kSparablePartitionMapId);
|
|
||||||
if (typeId.matches(kVirtualPartitionMapId)) {
|
|
||||||
TRACE(("map type: virtual\n"));
|
|
||||||
virtual_partition_map* map =
|
|
||||||
reinterpret_cast<virtual_partition_map*>(header);
|
|
||||||
virtualCount++;
|
|
||||||
(void)map; // kill the warning for now
|
|
||||||
} else if (typeId.matches(kSparablePartitionMapId)) {
|
|
||||||
TRACE(("map type: sparable\n"));
|
|
||||||
sparable_partition_map* map =
|
|
||||||
reinterpret_cast<sparable_partition_map*>(header);
|
|
||||||
sparableCount++;
|
|
||||||
(void)map; // kill the warning for now
|
|
||||||
} else if (typeId.matches(kMetadataPartitionMapId)) {
|
|
||||||
TRACE(("map type: metadata\n"));
|
|
||||||
metadata_partition_map* map =
|
|
||||||
reinterpret_cast<metadata_partition_map*>(header);
|
|
||||||
metadataCount++;
|
|
||||||
(void)map; // kill the warning for now
|
|
||||||
} else {
|
|
||||||
TRACE(("map type: unrecognized (`%.23s')\n",
|
|
||||||
typeId.identifier()));
|
|
||||||
status = B_ERROR;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TRACE(("Invalid partition type %d found!\n", header->type()));
|
TRACE(("no matching partition descriptor found!\n"));
|
||||||
status = B_ERROR;
|
status = B_ERROR;
|
||||||
}
|
}
|
||||||
offset += header->length();
|
} else if (header->type() == 2) {
|
||||||
|
// Figure out what kind of type 2 partition map we have based
|
||||||
|
// on the type identifier
|
||||||
|
const entity_id &typeId = header->partition_type_id();
|
||||||
|
DUMP(typeId);
|
||||||
|
DUMP(kSparablePartitionMapId);
|
||||||
|
if (typeId.matches(kVirtualPartitionMapId)) {
|
||||||
|
TRACE(("map type: virtual\n"));
|
||||||
|
virtual_partition_map* map =
|
||||||
|
reinterpret_cast<virtual_partition_map*>(header);
|
||||||
|
virtualCount++;
|
||||||
|
(void)map; // kill the warning for now
|
||||||
|
} else if (typeId.matches(kSparablePartitionMapId)) {
|
||||||
|
TRACE(("map type: sparable\n"));
|
||||||
|
sparable_partition_map* map =
|
||||||
|
reinterpret_cast<sparable_partition_map*>(header);
|
||||||
|
sparableCount++;
|
||||||
|
(void)map; // kill the warning for now
|
||||||
|
} else if (typeId.matches(kMetadataPartitionMapId)) {
|
||||||
|
TRACE(("map type: metadata\n"));
|
||||||
|
metadata_partition_map* map =
|
||||||
|
reinterpret_cast<metadata_partition_map*>(header);
|
||||||
|
metadataCount++;
|
||||||
|
(void)map; // kill the warning for now
|
||||||
|
} else {
|
||||||
|
TRACE(("map type: unrecognized (`%.23s')\n",
|
||||||
|
typeId.identifier()));
|
||||||
|
status = B_ERROR;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
TRACE(("Invalid partition type %d found!\n", header->type()));
|
||||||
|
status = B_ERROR;
|
||||||
}
|
}
|
||||||
|
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.
|
||||||
@@ -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();
|
||||||
@@ -219,16 +218,16 @@ Volume::Mount(const char *deviceName, off_t offset, off_t length,
|
|||||||
off_t address;
|
off_t address;
|
||||||
// Read in the file set descriptor
|
// Read in the file set descriptor
|
||||||
status = MapBlock(logicalVolumeDescriptor.file_set_address(),
|
status = MapBlock(logicalVolumeDescriptor.file_set_address(),
|
||||||
&address);
|
&address);
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// See if it's valid, and if so, create the root icb
|
// See if it's valid, and if so, create the root icb
|
||||||
@@ -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,9 +290,8 @@ 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) {
|
||||||
Partition *partition = _GetPartition(address.partition());
|
Partition *partition = _GetPartition(address.partition());
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user