The Volume now stores the type of the file system (as Type()).

Improved constructor.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4706 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2003-09-16 02:31:06 +00:00
parent 101bb5d182
commit 479e4ab5cf
2 changed files with 9 additions and 8 deletions
@@ -27,16 +27,12 @@ Volume::Volume(boot::Partition *partition)
if ((fDevice = open_node(partition, O_RDONLY)) < B_OK) if ((fDevice = open_node(partition, O_RDONLY)) < B_OK)
return; return;
char *buffer = (char *)malloc(4096); if (read_pos(fDevice, 0, &fType, sizeof(int32)) < B_OK)
if (buffer == NULL)
return; return;
if (read_pos(fDevice, 0, buffer, sizeof(uint32)) < B_OK) { fType = B_BENDIAN_TO_HOST_INT32(fType);
free(buffer);
return;
}
switch (B_BENDIAN_TO_HOST_INT32(*(uint32 *)buffer)) { switch (fType) {
case DT_AMIGA_FFS: case DT_AMIGA_FFS:
case DT_AMIGA_FFS_INTL: case DT_AMIGA_FFS_INTL:
case DT_AMIGA_FFS_DCACHE: case DT_AMIGA_FFS_DCACHE:
@@ -46,10 +42,13 @@ Volume::Volume(boot::Partition *partition)
printf("The Amiga OFS is not yet supported.\n"); printf("The Amiga OFS is not yet supported.\n");
default: default:
// unsupported file system // unsupported file system
free(buffer);
return; return;
} }
char *buffer = (char *)malloc(4096);
if (buffer == NULL)
return;
int32 blockSize = partition->block_size; int32 blockSize = partition->block_size;
if (get_root_block(fDevice, buffer, blockSize, partition->size) != B_OK) { if (get_root_block(fDevice, buffer, blockSize, partition->size) != B_OK) {
// try to get the root block at different sizes, if the // try to get the root block at different sizes, if the
@@ -28,10 +28,12 @@ class Volume {
int Device() const { return fDevice; } int Device() const { return fDevice; }
Directory *Root() { return fRoot; } Directory *Root() { return fRoot; }
int32 Type() const { return fType; }
int32 BlockSize() const { return fRootNode.BlockSize(); } int32 BlockSize() const { return fRootNode.BlockSize(); }
protected: protected:
int fDevice; int fDevice;
int32 fType;
RootBlock fRootNode; RootBlock fRootNode;
Directory *fRoot; Directory *fRoot;
}; };