From 972f12eeb47ffa938f1a9021036c5c1b21730172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 8 Jun 2004 06:30:37 +0000 Subject: [PATCH] Fixed several bugs during the mount process: - DeviceOpener::GetSize() didn't work correctly for devices - the size returned was the block count. Also, it didn't expand the computation to 64 bits - the check if the disk size was large enough make use of BlockShift() which access the fBlockShift variable which wasn't initialized at that point - if new_vnode() failed, a wrong error code was returned - it will now write a different error message if the root node creation failed before new_vnode() was called. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7841 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/bfs/Volume.cpp | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.cpp b/src/add-ons/kernel/file_systems/bfs/Volume.cpp index f1757651db..7750dcd7f2 100644 --- a/src/add-ons/kernel/file_systems/bfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Volume.cpp @@ -133,8 +133,10 @@ DeviceOpener::GetSize(off_t *_size, uint32 *_blockSize) return B_OK; } - if (_size) - *_size = geometry.head_count * geometry.cylinder_count * geometry.sectors_per_track; + if (_size) { + *_size = 1LL * geometry.head_count * geometry.cylinder_count + * geometry.sectors_per_track * geometry.bytes_per_sector; + } if (_blockSize) *_blockSize = geometry.bytes_per_sector; @@ -326,6 +328,11 @@ Volume::Mount(const char *deviceName, uint32 flags) return B_BAD_VALUE; } + // initialize short hands to the super block (to save byte swapping) + fBlockSize = fSuperBlock.BlockSize(); + fBlockShift = fSuperBlock.BlockShift(); + fAllocationGroupShift = fSuperBlock.AllocationGroupShift(); + // check if the device size is large enough to hold the file system off_t diskSize; if (opener.GetSize(&diskSize) < B_OK) @@ -337,11 +344,6 @@ Volume::Mount(const char *deviceName, uint32 flags) fLogStart = fSuperBlock.LogStart(); fLogEnd = fSuperBlock.LogEnd(); - // initialize short hands to the super block (to save byte swapping) - fBlockSize = fSuperBlock.BlockSize(); - fBlockShift = fSuperBlock.BlockShift(); - fAllocationGroupShift = fSuperBlock.AllocationGroupShift(); - if (opener.InitCache(NumBlocks()) != B_OK) return B_ERROR; @@ -356,7 +358,8 @@ Volume::Mount(const char *deviceName, uint32 flags) fRootNode = new Inode(this, ToVnode(Root())); if (fRootNode && fRootNode->InitCheck() == B_OK) { - if (new_vnode(fID, ToVnode(Root()), (void *)fRootNode) == B_OK) { + status = new_vnode(fID, ToVnode(Root()), (void *)fRootNode); + if (status == B_OK) { // try to get indices root dir // question: why doesn't get_vnode() work here?? @@ -385,11 +388,13 @@ Volume::Mount(const char *deviceName, uint32 flags) opener.Keep(); return B_OK; } else - status = B_NO_MEMORY; - } else - status = B_BAD_VALUE; + FATAL(("could not create root node: new_vnode() failed!\n")); - FATAL(("could not create root node: new_vnode() failed!\n")); + delete fRootNode; + } else { + status = B_BAD_VALUE; + FATAL(("could not create root node!\n")); + } return status; }