xfs : Enabling -Werror and fixing all build issues that result
This patch will fix almost all warnings we have in xfs code. There are some which I haven't fixed yet, I added comments on part of code which is giving error and its type as well. I tested all the changes on xfs_shell and everything is working fine. Change-Id: I1af1d09e7eab7f2c2397193bd5a584c5d40c424c Reviewed-on: https://review.haiku-os.org/c/haiku/+/5257 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
2e75ef07fe
commit
b666bf3fd8
@ -737,6 +737,7 @@ rule ArchitectureSetupWarnings architecture
|
|||||||
# EnableWerror src add-ons kernel file_systems reiserfs ;
|
# EnableWerror src add-ons kernel file_systems reiserfs ;
|
||||||
EnableWerror src add-ons kernel file_systems udf ;
|
EnableWerror src add-ons kernel file_systems udf ;
|
||||||
EnableWerror src add-ons kernel file_systems userlandfs ;
|
EnableWerror src add-ons kernel file_systems userlandfs ;
|
||||||
|
EnableWerror src add-ons kernel file_systems xfs ;
|
||||||
EnableWerror src add-ons kernel generic ;
|
EnableWerror src add-ons kernel generic ;
|
||||||
EnableWerror src add-ons kernel network ;
|
EnableWerror src add-ons kernel network ;
|
||||||
EnableWerror src add-ons kernel partitioning_systems ;
|
EnableWerror src add-ons kernel partitioning_systems ;
|
||||||
|
@ -12,9 +12,9 @@ TreeDirectory::TreeDirectory(Inode* inode)
|
|||||||
fInitStatus(B_OK),
|
fInitStatus(B_OK),
|
||||||
fRoot(NULL),
|
fRoot(NULL),
|
||||||
fExtents(NULL),
|
fExtents(NULL),
|
||||||
|
fCountOfFilledExtents(0),
|
||||||
fSingleDirBlock(NULL),
|
fSingleDirBlock(NULL),
|
||||||
fOffsetOfSingleDirBlock(-1),
|
fOffsetOfSingleDirBlock(-1),
|
||||||
fCountOfFilledExtents(0),
|
|
||||||
fCurMapIndex(0),
|
fCurMapIndex(0),
|
||||||
fOffset(0),
|
fOffset(0),
|
||||||
fCurBlockNumber(0)
|
fCurBlockNumber(0)
|
||||||
@ -80,7 +80,7 @@ TreeDirectory::PtrSize()
|
|||||||
size_t
|
size_t
|
||||||
TreeDirectory::MaxRecordsPossibleRoot()
|
TreeDirectory::MaxRecordsPossibleRoot()
|
||||||
{
|
{
|
||||||
size_t lengthOfDataFork;
|
size_t lengthOfDataFork = 0;
|
||||||
if (fInode->ForkOffset() != 0)
|
if (fInode->ForkOffset() != 0)
|
||||||
lengthOfDataFork = fInode->ForkOffset() << 3;
|
lengthOfDataFork = fInode->ForkOffset() << 3;
|
||||||
if (fInode->ForkOffset() == 0) {
|
if (fInode->ForkOffset() == 0) {
|
||||||
@ -212,7 +212,7 @@ TreeDirectory::SearchAndFillPath(uint32 offset, int type)
|
|||||||
status_t status;
|
status_t status;
|
||||||
for (int i = 0; i < MAX_TREE_DEPTH && level >= 0; i++, level--) {
|
for (int i = 0; i < MAX_TREE_DEPTH && level >= 0; i++, level--) {
|
||||||
uint64 requiredBlock = B_BENDIAN_TO_HOST_INT64(*ptrToNode);
|
uint64 requiredBlock = B_BENDIAN_TO_HOST_INT64(*ptrToNode);
|
||||||
TRACE("requiredBlock:(%d)\n", requiredBlock);
|
TRACE("requiredBlock:(%" B_PRIu64 ")\n", requiredBlock);
|
||||||
if (path[i].blockNumber == requiredBlock) {
|
if (path[i].blockNumber == requiredBlock) {
|
||||||
// This block already has what we need
|
// This block already has what we need
|
||||||
if (path[i].type == 2)
|
if (path[i].type == 2)
|
||||||
@ -223,11 +223,11 @@ TreeDirectory::SearchAndFillPath(uint32 offset, int type)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// We do not have the block we need
|
// We do not have the block we need
|
||||||
size_t len;
|
ssize_t len;
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
// The size of buffer should be the directory block size
|
// The size of buffer should be the directory block size
|
||||||
len = fInode->DirBlockSize();
|
len = fInode->DirBlockSize();
|
||||||
TRACE("path node type:(%d)\n", path[i].type);
|
TRACE("path node type:(%" B_PRId32 ")\n", path[i].type);
|
||||||
if (path[i].type != 2) {
|
if (path[i].type != 2) {
|
||||||
// Size is not directory block size.
|
// Size is not directory block size.
|
||||||
delete path[i].blockData;
|
delete path[i].blockData;
|
||||||
@ -285,10 +285,10 @@ TreeDirectory::GetAllExtents()
|
|||||||
ArrayDeleter<ExtentMapUnwrap> extentsWrappedDeleter(extentsWrapped);
|
ArrayDeleter<ExtentMapUnwrap> extentsWrappedDeleter(extentsWrapped);
|
||||||
|
|
||||||
size_t maxRecords = MaxRecordsPossibleRoot();
|
size_t maxRecords = MaxRecordsPossibleRoot();
|
||||||
TRACE("Maxrecords: (%d)\n", maxRecords);
|
TRACE("Maxrecords: (%" B_PRIuSIZE ")\n", maxRecords);
|
||||||
|
|
||||||
Volume* volume = fInode->GetVolume();
|
Volume* volume = fInode->GetVolume();
|
||||||
size_t len = volume->BlockSize();
|
ssize_t len = volume->BlockSize();
|
||||||
|
|
||||||
uint16 levelsInTree = fRoot->Levels();
|
uint16 levelsInTree = fRoot->Levels();
|
||||||
status_t status = fInode->GetNodefromTree(levelsInTree, volume, len,
|
status_t status = fInode->GetNodefromTree(levelsInTree, volume, len,
|
||||||
@ -316,8 +316,8 @@ TreeDirectory::GetAllExtents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileSystemBlockNo = ((LongBlock*)leafBuffer)->Right();
|
fileSystemBlockNo = ((LongBlock*)leafBuffer)->Right();
|
||||||
TRACE("Next leaf is at: (%d)\n", fileSystemBlockNo);
|
TRACE("Next leaf is at: (%" B_PRIu64 ")\n", fileSystemBlockNo);
|
||||||
if (fileSystemBlockNo == -1)
|
if (fileSystemBlockNo == (uint64) -1)
|
||||||
break;
|
break;
|
||||||
uint64 readPos = fInode->FileSystemBlockToAddr(fileSystemBlockNo);
|
uint64 readPos = fInode->FileSystemBlockToAddr(fileSystemBlockNo);
|
||||||
if (read_pos(volume->Device(), readPos, fSingleDirBlock, len)
|
if (read_pos(volume->Device(), readPos, fSingleDirBlock, len)
|
||||||
@ -326,7 +326,7 @@ TreeDirectory::GetAllExtents()
|
|||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("Total covered: (%d)\n", fCountOfFilledExtents);
|
TRACE("Total covered: (%" B_PRIu32 ")\n", fCountOfFilledExtents);
|
||||||
|
|
||||||
status = UnWrapExtents(extentsWrapped);
|
status = UnWrapExtents(extentsWrapped);
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ TreeDirectory::FillBuffer(char* blockBuffer, int howManyBlocksFurther,
|
|||||||
if (map.br_state != 0)
|
if (map.br_state != 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
size_t len = fInode->DirBlockSize();
|
ssize_t len = fInode->DirBlockSize();
|
||||||
if (blockBuffer == NULL) {
|
if (blockBuffer == NULL) {
|
||||||
blockBuffer = new(std::nothrow) char[len];
|
blockBuffer = new(std::nothrow) char[len];
|
||||||
if (blockBuffer == NULL)
|
if (blockBuffer == NULL)
|
||||||
@ -407,7 +407,7 @@ TreeDirectory::EntrySize(int len) const
|
|||||||
* Throw in the desired block number and get the index of it
|
* Throw in the desired block number and get the index of it
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
TreeDirectory::SearchMapInAllExtent(int blockNo, uint32& mapIndex)
|
TreeDirectory::SearchMapInAllExtent(uint64 blockNo, uint32& mapIndex)
|
||||||
{
|
{
|
||||||
ExtentMapEntry map;
|
ExtentMapEntry map;
|
||||||
for (uint32 i = 0; i < fCountOfFilledExtents; i++) {
|
for (uint32 i = 0; i < fCountOfFilledExtents; i++) {
|
||||||
@ -454,7 +454,7 @@ TreeDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
while (fOffset != curDirectorySize) {
|
while (fOffset != curDirectorySize) {
|
||||||
blockNoFromAddress = BLOCKNO_FROM_ADDRESS(fOffset, volume);
|
blockNoFromAddress = BLOCKNO_FROM_ADDRESS(fOffset, volume);
|
||||||
|
|
||||||
TRACE("fOffset:(%d), blockNoFromAddress:(%d)\n",
|
TRACE("fOffset:(%" B_PRIu64 "), blockNoFromAddress:(%" B_PRIu32 ")\n",
|
||||||
fOffset, blockNoFromAddress);
|
fOffset, blockNoFromAddress);
|
||||||
if (fCurBlockNumber != blockNoFromAddress
|
if (fCurBlockNumber != blockNoFromAddress
|
||||||
&& blockNoFromAddress > map.br_startoff
|
&& blockNoFromAddress > map.br_startoff
|
||||||
@ -498,7 +498,7 @@ TreeDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
ExtentDataEntry* dataEntry = (ExtentDataEntry*) entry;
|
ExtentDataEntry* dataEntry = (ExtentDataEntry*) entry;
|
||||||
|
|
||||||
uint16 currentOffset = (char*)dataEntry - fSingleDirBlock;
|
uint16 currentOffset = (char*)dataEntry - fSingleDirBlock;
|
||||||
TRACE("GetNext: fOffset:(%d), currentOffset:(%d)\n",
|
TRACE("GetNext: fOffset:(%" B_PRIu64 "), currentOffset:(%" B_PRIu16 ")\n",
|
||||||
BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode), currentOffset);
|
BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode), currentOffset);
|
||||||
|
|
||||||
if (BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode) > currentOffset) {
|
if (BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode) > currentOffset) {
|
||||||
@ -506,7 +506,7 @@ TreeDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataEntry->namelen + 1 > *length)
|
if ((size_t)(dataEntry->namelen) >= *length)
|
||||||
return B_BUFFER_OVERFLOW;
|
return B_BUFFER_OVERFLOW;
|
||||||
|
|
||||||
fOffset = fOffset + EntrySize(dataEntry->namelen);
|
fOffset = fOffset + EntrySize(dataEntry->namelen);
|
||||||
@ -515,7 +515,7 @@ TreeDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
*length = dataEntry->namelen + 1;
|
*length = dataEntry->namelen + 1;
|
||||||
*ino = B_BENDIAN_TO_HOST_INT64(dataEntry->inumber);
|
*ino = B_BENDIAN_TO_HOST_INT64(dataEntry->inumber);
|
||||||
|
|
||||||
TRACE("Entry found. Name: (%s), Length: (%ld), ino: (%ld)\n", name,
|
TRACE("Entry found. Name: (%s), Length: (%" B_PRIuSIZE "), ino: (%" B_PRIu64 ")\n", name,
|
||||||
*length, *ino);
|
*length, *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -532,7 +532,7 @@ TreeDirectory::UnWrapExtents(ExtentMapUnwrap* extentsWrapped)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
uint64 first, second;
|
uint64 first, second;
|
||||||
|
|
||||||
for (int i = 0; i < fCountOfFilledExtents; i++) {
|
for (uint32 i = 0; i < fCountOfFilledExtents; i++) {
|
||||||
first = B_BENDIAN_TO_HOST_INT64(extentsWrapped[i].first);
|
first = B_BENDIAN_TO_HOST_INT64(extentsWrapped[i].first);
|
||||||
second = B_BENDIAN_TO_HOST_INT64(extentsWrapped[i].second);
|
second = B_BENDIAN_TO_HOST_INT64(extentsWrapped[i].second);
|
||||||
fExtents[i].br_state = first >> 63;
|
fExtents[i].br_state = first >> 63;
|
||||||
@ -569,17 +569,17 @@ TreeDirectory::FillMapEntry(int num, ExtentMapEntry** fMap,
|
|||||||
(*fMap)->br_startoff = (firstHalf & MASK(63)) >> 9;
|
(*fMap)->br_startoff = (firstHalf & MASK(63)) >> 9;
|
||||||
(*fMap)->br_startblock = ((firstHalf & MASK(9)) << 43) | (secondHalf >> 21);
|
(*fMap)->br_startblock = ((firstHalf & MASK(9)) << 43) | (secondHalf >> 21);
|
||||||
(*fMap)->br_blockcount = secondHalf & MASK(21);
|
(*fMap)->br_blockcount = secondHalf & MASK(21);
|
||||||
TRACE("FillMapEntry: startoff:(%ld), startblock:(%ld), blockcount:(%ld),"
|
TRACE("FillMapEntry: startoff:(%" B_PRIu64 "), startblock:(%" B_PRIu64 "),"
|
||||||
"state:(%d)\n", (*fMap)->br_startoff, (*fMap)->br_startblock,
|
"blockcount:(%" B_PRIu64 "),state:(%" B_PRIu8 ")\n", (*fMap)->br_startoff,
|
||||||
(*fMap)->br_blockcount, (*fMap)->br_state);
|
(*fMap)->br_startblock,(*fMap)->br_blockcount, (*fMap)->br_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TreeDirectory::SearchForMapInDirectoryBlock(int blockNo,
|
TreeDirectory::SearchForMapInDirectoryBlock(uint64 blockNo,
|
||||||
int entries, ExtentMapEntry** map, int type, int pathIndex)
|
int entries, ExtentMapEntry** map, int type, int pathIndex)
|
||||||
{
|
{
|
||||||
TRACE("SearchForMapInDirectoryBlock: blockNo:(%d)\n", blockNo);
|
TRACE("SearchForMapInDirectoryBlock: blockNo:(%" B_PRIu64 ")\n", blockNo);
|
||||||
for (int i = 0; i < entries; i++) {
|
for (int i = 0; i < entries; i++) {
|
||||||
FillMapEntry(i, map, type, pathIndex);
|
FillMapEntry(i, map, type, pathIndex);
|
||||||
if ((*map)->br_startoff <= blockNo
|
if ((*map)->br_startoff <= blockNo
|
||||||
@ -614,7 +614,7 @@ TreeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
TRACE("TreeDirectory: Lookup\n");
|
TRACE("TreeDirectory: Lookup\n");
|
||||||
TRACE("Name: %s\n", name);
|
TRACE("Name: %s\n", name);
|
||||||
uint32 hashValueOfRequest = hashfunction(name, length);
|
uint32 hashValueOfRequest = hashfunction(name, length);
|
||||||
TRACE("Hashval:(%ld)\n", hashValueOfRequest);
|
TRACE("Hashval:(%" B_PRIu32 ")\n", hashValueOfRequest);
|
||||||
|
|
||||||
Volume* volume = fInode->GetVolume();
|
Volume* volume = fInode->GetVolume();
|
||||||
status_t status;
|
status_t status;
|
||||||
@ -686,7 +686,7 @@ TreeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
= (ExtentLeafEntry*)(fSingleDirBlock + sizeof(ExtentLeafHeader));
|
= (ExtentLeafEntry*)(fSingleDirBlock + sizeof(ExtentLeafHeader));
|
||||||
|
|
||||||
int numberOfLeafEntries = B_BENDIAN_TO_HOST_INT16(leafHeader->count);
|
int numberOfLeafEntries = B_BENDIAN_TO_HOST_INT16(leafHeader->count);
|
||||||
TRACE("numberOfLeafEntries:(%d)\n", numberOfLeafEntries);
|
TRACE("numberOfLeafEntries:(%" B_PRId32 ")\n", numberOfLeafEntries);
|
||||||
int left = 0;
|
int left = 0;
|
||||||
int mid;
|
int mid;
|
||||||
int right = numberOfLeafEntries - 1;
|
int right = numberOfLeafEntries - 1;
|
||||||
@ -705,7 +705,7 @@ TreeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
left = mid + 1;
|
left = mid + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("left:(%d), right:(%d)\n", left, right);
|
TRACE("left:(%" B_PRId32 "), right:(%" B_PRId32 ")\n", left, right);
|
||||||
uint32 nextLeaf = B_BENDIAN_TO_HOST_INT32(leafHeader->info.forw);
|
uint32 nextLeaf = B_BENDIAN_TO_HOST_INT32(leafHeader->info.forw);
|
||||||
uint32 lastHashVal = B_BENDIAN_TO_HOST_INT32(
|
uint32 lastHashVal = B_BENDIAN_TO_HOST_INT32(
|
||||||
leafEntry[numberOfLeafEntries - 1].hashval);
|
leafEntry[numberOfLeafEntries - 1].hashval);
|
||||||
@ -721,7 +721,7 @@ TreeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
uint32 dataBlockNumber = BLOCKNO_FROM_ADDRESS(address * 8, volume);
|
uint32 dataBlockNumber = BLOCKNO_FROM_ADDRESS(address * 8, volume);
|
||||||
uint32 offset = BLOCKOFFSET_FROM_ADDRESS(address * 8, fInode);
|
uint32 offset = BLOCKOFFSET_FROM_ADDRESS(address * 8, fInode);
|
||||||
|
|
||||||
TRACE("BlockNumber:(%d), offset:(%d)\n", dataBlockNumber, offset);
|
TRACE("BlockNumber:(%" B_PRIu32 "), offset:(%" B_PRIu32 ")\n", dataBlockNumber, offset);
|
||||||
|
|
||||||
status = SearchAndFillPath(dataBlockNumber, DATA);
|
status = SearchAndFillPath(dataBlockNumber, DATA);
|
||||||
int pathIndex = -1;
|
int pathIndex = -1;
|
||||||
@ -746,19 +746,19 @@ TreeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
dataBlockNumber - targetMap->br_startoff, targetMap);
|
dataBlockNumber - targetMap->br_startoff, targetMap);
|
||||||
fOffsetOfSingleDirBlock = dataBlockNumber;
|
fOffsetOfSingleDirBlock = dataBlockNumber;
|
||||||
|
|
||||||
TRACE("offset:(%d)\n", offset);
|
TRACE("offset:(%" B_PRIu32 ")\n", offset);
|
||||||
ExtentDataEntry* entry
|
ExtentDataEntry* entry
|
||||||
= (ExtentDataEntry*)(fSingleDirBlock + offset);
|
= (ExtentDataEntry*)(fSingleDirBlock + offset);
|
||||||
|
|
||||||
int retVal = strncmp(name, (char*)entry->name, entry->namelen);
|
int retVal = strncmp(name, (char*)entry->name, entry->namelen);
|
||||||
if (retVal == 0) {
|
if (retVal == 0) {
|
||||||
*ino = B_BENDIAN_TO_HOST_INT64(entry->inumber);
|
*ino = B_BENDIAN_TO_HOST_INT64(entry->inumber);
|
||||||
TRACE("ino:(%d)\n", *ino);
|
TRACE("ino:(%" B_PRIu64 ")\n", *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
left++;
|
left++;
|
||||||
}
|
}
|
||||||
if (lastHashVal == hashValueOfRequest && nextLeaf != -1) {
|
if (lastHashVal == hashValueOfRequest && nextLeaf != (uint32) -1) {
|
||||||
// Go to forward neighbor. We might find an entry there.
|
// Go to forward neighbor. We might find an entry there.
|
||||||
status = SearchAndFillPath(nextLeaf, LEAF);
|
status = SearchAndFillPath(nextLeaf, LEAF);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
|
@ -90,7 +90,7 @@ public:
|
|||||||
TreePointer* GetPtrFromNode(int pos, void* buffer);
|
TreePointer* GetPtrFromNode(int pos, void* buffer);
|
||||||
TreeKey* GetKeyFromRoot(int pos);
|
TreeKey* GetKeyFromRoot(int pos);
|
||||||
TreePointer* GetPtrFromRoot(int pos);
|
TreePointer* GetPtrFromRoot(int pos);
|
||||||
status_t SearchMapInAllExtent(int blockNo,
|
status_t SearchMapInAllExtent(uint64 blockNo,
|
||||||
uint32& mapIndex);
|
uint32& mapIndex);
|
||||||
status_t GetAllExtents();
|
status_t GetAllExtents();
|
||||||
size_t MaxRecordsPossibleRoot();
|
size_t MaxRecordsPossibleRoot();
|
||||||
@ -105,7 +105,7 @@ public:
|
|||||||
status_t SearchAndFillPath(uint32 offset, int type);
|
status_t SearchAndFillPath(uint32 offset, int type);
|
||||||
status_t SearchOffsetInTreeNode (uint32 offset,
|
status_t SearchOffsetInTreeNode (uint32 offset,
|
||||||
TreePointer** pointer, int pathIndex);
|
TreePointer** pointer, int pathIndex);
|
||||||
void SearchForMapInDirectoryBlock (int blockNo,
|
void SearchForMapInDirectoryBlock (uint64 blockNo,
|
||||||
int entries, ExtentMapEntry** map,
|
int entries, ExtentMapEntry** map,
|
||||||
int type, int pathIndex);
|
int type, int pathIndex);
|
||||||
uint32 SearchForHashInNodeBlock(uint32 hashVal);
|
uint32 SearchForHashInNodeBlock(uint32 hashVal);
|
||||||
|
@ -9,14 +9,19 @@
|
|||||||
#ifndef _DEBUG_H_
|
#ifndef _DEBUG_H_
|
||||||
#define _DEBUG_H_
|
#define _DEBUG_H_
|
||||||
|
|
||||||
|
#define TRACE_XFS
|
||||||
#ifdef TRACE_XFS
|
#ifdef TRACE_XFS
|
||||||
#define TRACE(x...) dprintf("\n\33[34mxfs:\33[0m " x)
|
#define TRACE(x...) dprintf("\n\33[34mxfs:\33[0m " x)
|
||||||
|
#ifdef FS_SHELL
|
||||||
#define ASSERT(x) \
|
#define ASSERT(x) \
|
||||||
{ if (!(x)) kernel_debugger("xfs: assert failed: " #x "\n"); }
|
{ if (!(x)) kernel_debugger("xfs: assert failed: " #x "\n"); }
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define TRACE(x...)
|
#define TRACE(x...)
|
||||||
|
#ifdef FS_SHELL
|
||||||
#define ASSERT(x)
|
#define ASSERT(x)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#define ERROR(x...) dprintf("\n\33[34mxfs:\33[0m " x)
|
#define ERROR(x...) dprintf("\n\33[34mxfs:\33[0m " x)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,8 +32,8 @@ Extent::FillMapEntry(void* pointerToMap)
|
|||||||
fMap->br_startoff = (firstHalf & MASK(63)) >> 9;
|
fMap->br_startoff = (firstHalf & MASK(63)) >> 9;
|
||||||
fMap->br_startblock = ((firstHalf & MASK(9)) << 43) | (secondHalf >> 21);
|
fMap->br_startblock = ((firstHalf & MASK(9)) << 43) | (secondHalf >> 21);
|
||||||
fMap->br_blockcount = (secondHalf & MASK(21));
|
fMap->br_blockcount = (secondHalf & MASK(21));
|
||||||
TRACE("Extent::Init: startoff:(%ld), startblock:(%ld), blockcount:(%ld),"
|
TRACE("Extent::Init: startoff:(%" B_PRIu64 "), startblock:(%" B_PRIu64 "),"
|
||||||
"state:(%d)\n", fMap->br_startoff, fMap->br_startblock,
|
"blockcount:(%" B_PRIu64 "),state:(%" B_PRIu8 ")\n", fMap->br_startoff, fMap->br_startblock,
|
||||||
fMap->br_blockcount, fMap->br_state);
|
fMap->br_blockcount, fMap->br_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,11 +153,11 @@ Extent::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
|
|
||||||
// We don't read stale entries.
|
// We don't read stale entries.
|
||||||
numberOfEntries -= numberOfStaleEntries;
|
numberOfEntries -= numberOfStaleEntries;
|
||||||
TRACE("numberOfEntries:(%d)\n", numberOfEntries);
|
TRACE("numberOfEntries:(%" B_PRId32 ")\n", numberOfEntries);
|
||||||
uint16 currentOffset = (char*)entry - fBlockBuffer;
|
uint16 currentOffset = (char*)entry - fBlockBuffer;
|
||||||
|
|
||||||
for (int i = 0; i < numberOfEntries; i++) {
|
for (int i = 0; i < numberOfEntries; i++) {
|
||||||
TRACE("EntryNumber:(%d)\n", i);
|
TRACE("EntryNumber:(%" B_PRId32 ")\n", i);
|
||||||
ExtentUnusedEntry* unusedEntry = (ExtentUnusedEntry*)entry;
|
ExtentUnusedEntry* unusedEntry = (ExtentUnusedEntry*)entry;
|
||||||
|
|
||||||
if (B_BENDIAN_TO_HOST_INT16(unusedEntry->freetag) == DIR2_FREE_TAG) {
|
if (B_BENDIAN_TO_HOST_INT16(unusedEntry->freetag) == DIR2_FREE_TAG) {
|
||||||
@ -170,7 +170,7 @@ Extent::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
}
|
}
|
||||||
ExtentDataEntry* dataEntry = (ExtentDataEntry*) entry;
|
ExtentDataEntry* dataEntry = (ExtentDataEntry*) entry;
|
||||||
|
|
||||||
TRACE("GetNext: fOffset:(%d), currentOffset:(%d)\n",
|
TRACE("GetNext: fOffset:(%" B_PRIu32 "), currentOffset:(%" B_PRIu16 ")\n",
|
||||||
fOffset, currentOffset);
|
fOffset, currentOffset);
|
||||||
|
|
||||||
if (fOffset >= currentOffset) {
|
if (fOffset >= currentOffset) {
|
||||||
@ -179,7 +179,7 @@ Extent::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataEntry->namelen + 1 > *length)
|
if ((size_t)(dataEntry->namelen) >= *length)
|
||||||
return B_BUFFER_OVERFLOW;
|
return B_BUFFER_OVERFLOW;
|
||||||
|
|
||||||
fOffset = currentOffset;
|
fOffset = currentOffset;
|
||||||
@ -188,7 +188,7 @@ Extent::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
*length = dataEntry->namelen + 1;
|
*length = dataEntry->namelen + 1;
|
||||||
*ino = B_BENDIAN_TO_HOST_INT64(dataEntry->inumber);
|
*ino = B_BENDIAN_TO_HOST_INT64(dataEntry->inumber);
|
||||||
|
|
||||||
TRACE("Entry found. Name: (%s), Length: (%ld),ino: (%ld)\n", name,
|
TRACE("Entry found. Name: (%s), Length: (%" B_PRIuSIZE "),ino: (%" B_PRIu64 ")\n", name,
|
||||||
*length, *ino);
|
*length, *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ Extent::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
TRACE("Extent: Lookup\n");
|
TRACE("Extent: Lookup\n");
|
||||||
TRACE("Name: %s\n", name);
|
TRACE("Name: %s\n", name);
|
||||||
uint32 hashValueOfRequest = hashfunction(name, length);
|
uint32 hashValueOfRequest = hashfunction(name, length);
|
||||||
TRACE("Hashval:(%ld)\n", hashValueOfRequest);
|
TRACE("Hashval:(%" B_PRIu32 ")\n", hashValueOfRequest);
|
||||||
ExtentBlockTail* blockTail = BlockTail();
|
ExtentBlockTail* blockTail = BlockTail();
|
||||||
ExtentLeafEntry* leafEntry = BlockFirstLeaf(blockTail);
|
ExtentLeafEntry* leafEntry = BlockFirstLeaf(blockTail);
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ Extent::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
left = mid+1;
|
left = mid+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("left:(%d), right:(%d)\n", left, right);
|
TRACE("left:(%" B_PRId32 "), right:(%" B_PRId32 ")\n", left, right);
|
||||||
|
|
||||||
while (B_BENDIAN_TO_HOST_INT32(leafEntry[left].hashval)
|
while (B_BENDIAN_TO_HOST_INT32(leafEntry[left].hashval)
|
||||||
== hashValueOfRequest) {
|
== hashValueOfRequest) {
|
||||||
@ -240,13 +240,13 @@ Extent::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 offset = GetOffsetFromAddress(address);
|
uint32 offset = GetOffsetFromAddress(address);
|
||||||
TRACE("offset:(%d)\n", offset);
|
TRACE("offset:(%" B_PRIu32 ")\n", offset);
|
||||||
ExtentDataEntry* entry = (ExtentDataEntry*)(fBlockBuffer + offset);
|
ExtentDataEntry* entry = (ExtentDataEntry*)(fBlockBuffer + offset);
|
||||||
|
|
||||||
int retVal = strncmp(name, (char*)entry->name, entry->namelen);
|
int retVal = strncmp(name, (char*)entry->name, entry->namelen);
|
||||||
if (retVal == 0) {
|
if (retVal == 0) {
|
||||||
*ino = B_BENDIAN_TO_HOST_INT64(entry->inumber);
|
*ino = B_BENDIAN_TO_HOST_INT64(entry->inumber);
|
||||||
TRACE("ino:(%d)\n", *ino);
|
TRACE("ino:(%" B_PRIu64 ")\n", *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
left++;
|
left++;
|
||||||
|
@ -140,8 +140,8 @@ xfs_inode_t::DataExtentsCount() const
|
|||||||
|
|
||||||
Inode::Inode(Volume* volume, xfs_ino_t id)
|
Inode::Inode(Volume* volume, xfs_ino_t id)
|
||||||
:
|
:
|
||||||
fVolume(volume),
|
|
||||||
fId(id),
|
fId(id),
|
||||||
|
fVolume(volume),
|
||||||
fBuffer(NULL),
|
fBuffer(NULL),
|
||||||
fExtents(NULL)
|
fExtents(NULL)
|
||||||
{
|
{
|
||||||
@ -291,7 +291,7 @@ Inode::GetPtrFromNode(int pos, void* buffer)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
Inode::GetNodefromTree(uint16& levelsInTree, Volume* volume,
|
Inode::GetNodefromTree(uint16& levelsInTree, Volume* volume,
|
||||||
size_t& len, size_t DirBlockSize, char* block) {
|
ssize_t& len, size_t DirBlockSize, char* block) {
|
||||||
|
|
||||||
char* node = new(std::nothrow) char[len];
|
char* node = new(std::nothrow) char[len];
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
@ -300,7 +300,7 @@ Inode::GetNodefromTree(uint16& levelsInTree, Volume* volume,
|
|||||||
|
|
||||||
ArrayDeleter<char> nodeDeleter(node);
|
ArrayDeleter<char> nodeDeleter(node);
|
||||||
|
|
||||||
TRACE("levels:(%d)\n", levelsInTree);
|
TRACE("levels:(%" B_PRIu16 ")\n", levelsInTree);
|
||||||
|
|
||||||
TreePointer* ptrToNode = GetPtrFromRoot(1);
|
TreePointer* ptrToNode = GetPtrFromRoot(1);
|
||||||
uint64 fileSystemBlockNo = B_BENDIAN_TO_HOST_INT64(*ptrToNode);
|
uint64 fileSystemBlockNo = B_BENDIAN_TO_HOST_INT64(*ptrToNode);
|
||||||
@ -345,13 +345,13 @@ Inode::ReadExtentsFromTreeInode()
|
|||||||
DIR_DFORK_PTR(Buffer()), sizeof(BlockInDataFork));
|
DIR_DFORK_PTR(Buffer()), sizeof(BlockInDataFork));
|
||||||
|
|
||||||
size_t maxRecords = MaxRecordsPossibleInTreeRoot();
|
size_t maxRecords = MaxRecordsPossibleInTreeRoot();
|
||||||
TRACE("Maxrecords: (%d)\n", maxRecords);
|
TRACE("Maxrecords: (%" B_PRIuSIZE ")\n", maxRecords);
|
||||||
|
|
||||||
uint16 levelsInTree = root->Levels();
|
uint16 levelsInTree = root->Levels();
|
||||||
delete root;
|
delete root;
|
||||||
|
|
||||||
Volume* volume = GetVolume();
|
Volume* volume = GetVolume();
|
||||||
size_t len = volume->BlockSize();
|
ssize_t len = volume->BlockSize();
|
||||||
|
|
||||||
len = DirBlockSize();
|
len = DirBlockSize();
|
||||||
char* block = new(std::nothrow) char[len];
|
char* block = new(std::nothrow) char[len];
|
||||||
@ -385,8 +385,8 @@ Inode::ReadExtentsFromTreeInode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileSystemBlockNo = ((LongBlock*)leafBuffer)->Right();
|
fileSystemBlockNo = ((LongBlock*)leafBuffer)->Right();
|
||||||
TRACE("Next leaf is at: (%d)\n", fileSystemBlockNo);
|
TRACE("Next leaf is at: (%" B_PRIu64 ")\n", fileSystemBlockNo);
|
||||||
if (fileSystemBlockNo == -1)
|
if (fileSystemBlockNo == (uint64) -1)
|
||||||
break;
|
break;
|
||||||
uint64 readPos = FileSystemBlockToAddr(fileSystemBlockNo);
|
uint64 readPos = FileSystemBlockToAddr(fileSystemBlockNo);
|
||||||
if (read_pos(volume->Device(), readPos, block, len)
|
if (read_pos(volume->Device(), readPos, block, len)
|
||||||
@ -395,7 +395,7 @@ Inode::ReadExtentsFromTreeInode()
|
|||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("Total covered: (%d)\n", indexIntoExtents);
|
TRACE("Total covered: (%" B_PRId32 ")\n", indexIntoExtents);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ Inode::ReadExtents()
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Inode::SearchMapInAllExtent(int blockNo)
|
Inode::SearchMapInAllExtent(uint64 blockNo)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < DataExtentsCount(); i++) {
|
for (int i = 0; i < DataExtentsCount(); i++) {
|
||||||
if (fExtents[i].br_startoff <= blockNo
|
if (fExtents[i].br_startoff <= blockNo
|
||||||
@ -431,7 +431,7 @@ Inode::SearchMapInAllExtent(int blockNo)
|
|||||||
status_t
|
status_t
|
||||||
Inode::ReadAt(off_t pos, uint8* buffer, size_t* length)
|
Inode::ReadAt(off_t pos, uint8* buffer, size_t* length)
|
||||||
{
|
{
|
||||||
TRACE("Inode::ReadAt: pos:(%ld), *length:(%ld)\n", pos, *length);
|
TRACE("Inode::ReadAt: pos:(%" B_PRIdOFF "), *length:(%" B_PRIuSIZE ")\n", pos, *length);
|
||||||
status_t status;
|
status_t status;
|
||||||
if (fExtents == NULL) {
|
if (fExtents == NULL) {
|
||||||
status = ReadExtents();
|
status = ReadExtents();
|
||||||
@ -442,13 +442,13 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* length)
|
|||||||
// set/check boundaries for pos/length
|
// set/check boundaries for pos/length
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
ERROR("inode %" B_PRIdINO ": ReadAt failed(pos %" B_PRIdOFF
|
ERROR("inode %" B_PRIdINO ": ReadAt failed(pos %" B_PRIdOFF
|
||||||
", length %lu)\n", ID(), pos, length);
|
", length %lu)\n", ID(), pos, *length);
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos >= Size() || length == 0) {
|
if (pos >= Size() || length == 0) {
|
||||||
TRACE("inode %" B_PRIdINO ": ReadAt 0 (pos %" B_PRIdOFF
|
TRACE("inode %" B_PRIdINO ": ReadAt 0 (pos %" B_PRIdOFF
|
||||||
", length %lu)\n", ID(), pos, length);
|
", length %" B_PRIuSIZE ")\n", ID(), pos, *length);
|
||||||
*length = 0;
|
*length = 0;
|
||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
@ -456,7 +456,7 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* length)
|
|||||||
uint32 blockNo = BLOCKNO_FROM_POSITION(pos, GetVolume());
|
uint32 blockNo = BLOCKNO_FROM_POSITION(pos, GetVolume());
|
||||||
uint32 offsetIntoBlock = BLOCKOFFSET_FROM_POSITION(pos, this);
|
uint32 offsetIntoBlock = BLOCKOFFSET_FROM_POSITION(pos, this);
|
||||||
|
|
||||||
size_t lengthOfBlock = BlockSize();
|
ssize_t lengthOfBlock = BlockSize();
|
||||||
char* block = new(std::nothrow) char[lengthOfBlock];
|
char* block = new(std::nothrow) char[lengthOfBlock];
|
||||||
if (block == NULL)
|
if (block == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@ -467,9 +467,9 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* length)
|
|||||||
size_t lengthLeftInFile;
|
size_t lengthLeftInFile;
|
||||||
size_t lengthLeftInBlock;
|
size_t lengthLeftInBlock;
|
||||||
size_t lengthToRead;
|
size_t lengthToRead;
|
||||||
TRACE("What is blockLen:(%d)\n", lengthOfBlock);
|
TRACE("What is blockLen:(%" B_PRId64 ")\n", lengthOfBlock);
|
||||||
while (*length > 0) {
|
while (*length > 0) {
|
||||||
TRACE("Inode::ReadAt: pos:(%ld), *length:(%ld)\n", pos, *length);
|
TRACE("Inode::ReadAt: pos:(%" B_PRIdOFF "), *length:(%" B_PRIuSIZE ")\n", pos, *length);
|
||||||
// As long as you can read full blocks, read.
|
// As long as you can read full blocks, read.
|
||||||
lengthLeftInFile = Size() - pos;
|
lengthLeftInFile = Size() - pos;
|
||||||
lengthLeftInBlock = lengthOfBlock - offsetIntoBlock;
|
lengthLeftInBlock = lengthOfBlock - offsetIntoBlock;
|
||||||
@ -509,7 +509,7 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* length)
|
|||||||
offsetIntoBlock = BLOCKOFFSET_FROM_POSITION(pos, this);
|
offsetIntoBlock = BLOCKOFFSET_FROM_POSITION(pos, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("lengthRead:(%d)\n", lengthRead);
|
TRACE("lengthRead:(%" B_PRIuSIZE ")\n", lengthRead);
|
||||||
*length = lengthRead;
|
*length = lengthRead;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -529,9 +529,9 @@ Inode::GetFromDisk()
|
|||||||
uint32 len = fVolume->InodeSize();
|
uint32 len = fVolume->InodeSize();
|
||||||
// Inode len to read (size of inode)
|
// Inode len to read (size of inode)
|
||||||
|
|
||||||
TRACE("AgNumber: (%d), AgRelativeIno: (%d), AgRelativeBlockNum: (%d),"
|
TRACE("AgNumber: (%" B_PRIu32 "), AgRelativeIno: (%" B_PRIu32 "),"
|
||||||
"Offset: (%d), len: (%d)\n", agNo,
|
"AgRelativeBlockNum: (%" B_PRIu32 "),Offset: (%" B_PRId64 "),"
|
||||||
agRelativeInodeNo, agBlock, offset, len);
|
"len: (%" B_PRIu32 ")\n", agNo,agRelativeInodeNo, agBlock, offset, len);
|
||||||
|
|
||||||
if (agNo > fVolume->AgCount()) {
|
if (agNo > fVolume->AgCount()) {
|
||||||
ERROR("Inode::GetFromDisk : AG Number more than number of AGs");
|
ERROR("Inode::GetFromDisk : AG Number more than number of AGs");
|
||||||
@ -568,7 +568,7 @@ Inode::FileSystemBlockToAddr(uint64 block)
|
|||||||
xfs_fsblock_t actualBlockToRead =
|
xfs_fsblock_t actualBlockToRead =
|
||||||
FSBLOCKS_TO_BASICBLOCKS(fVolume->BlockLog(),
|
FSBLOCKS_TO_BASICBLOCKS(fVolume->BlockLog(),
|
||||||
((uint64)(agNo * numberOfBlocksInAg) + agBlockNo));
|
((uint64)(agNo * numberOfBlocksInAg) + agBlockNo));
|
||||||
TRACE("blockToRead:(%d)\n", actualBlockToRead);
|
TRACE("blockToRead:(%" B_PRIu64 ")\n", actualBlockToRead);
|
||||||
|
|
||||||
uint64 readPos = actualBlockToRead * (BASICBLOCKSIZE);
|
uint64 readPos = actualBlockToRead * (BASICBLOCKSIZE);
|
||||||
return readPos;
|
return readPos;
|
||||||
|
@ -231,9 +231,9 @@ public:
|
|||||||
status_t ReadExtents();
|
status_t ReadExtents();
|
||||||
status_t ReadAt(off_t pos, uint8* buffer, size_t* length);
|
status_t ReadAt(off_t pos, uint8* buffer, size_t* length);
|
||||||
status_t GetNodefromTree(uint16& levelsInTree,
|
status_t GetNodefromTree(uint16& levelsInTree,
|
||||||
Volume* volume, size_t& len,
|
Volume* volume, ssize_t& len,
|
||||||
size_t DirBlockSize, char* block);
|
size_t DirBlockSize, char* block);
|
||||||
int SearchMapInAllExtent(int blockNo);
|
int SearchMapInAllExtent(uint64 blockNo);
|
||||||
void UnWrapExtentFromWrappedEntry(
|
void UnWrapExtentFromWrappedEntry(
|
||||||
uint64 wrappedExtent[2],
|
uint64 wrappedExtent[2],
|
||||||
ExtentMapEntry* entry);
|
ExtentMapEntry* entry);
|
||||||
|
@ -10,11 +10,11 @@
|
|||||||
LeafDirectory::LeafDirectory(Inode* inode)
|
LeafDirectory::LeafDirectory(Inode* inode)
|
||||||
:
|
:
|
||||||
fInode(inode),
|
fInode(inode),
|
||||||
|
fDataMap(NULL),
|
||||||
|
fLeafMap(NULL),
|
||||||
fOffset(0),
|
fOffset(0),
|
||||||
fDataBuffer(NULL),
|
fDataBuffer(NULL),
|
||||||
fLeafBuffer(NULL),
|
fLeafBuffer(NULL),
|
||||||
fLeafMap(NULL),
|
|
||||||
fDataMap(NULL),
|
|
||||||
fCurBlockNumber(-1)
|
fCurBlockNumber(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ LeafDirectory::IsLeafType()
|
|||||||
bool status = true;
|
bool status = true;
|
||||||
if (fInode->BlockCount() == 1
|
if (fInode->BlockCount() == 1
|
||||||
|| fInode->DataExtentsCount() == 1
|
|| fInode->DataExtentsCount() == 1
|
||||||
|| fInode->Size() !=
|
|| (uint64) fInode->Size() !=
|
||||||
(fInode->BlockCount() - 1) * fInode->DirBlockSize())
|
(fInode->BlockCount() - 1) * fInode->DirBlockSize())
|
||||||
status = false;
|
status = false;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ LeafDirectory::IsLeafType()
|
|||||||
return status;
|
return status;
|
||||||
|
|
||||||
FillMapEntry(fInode->DataExtentsCount() - 1, fLeafMap);
|
FillMapEntry(fInode->DataExtentsCount() - 1, fLeafMap);
|
||||||
TRACE("leaf_Startoffset:(%ld)\n",
|
TRACE("leaf_Startoffset:(%" B_PRIu64 ")\n",
|
||||||
LEAF_STARTOFFSET(fInode->GetVolume()->BlockLog()));
|
LEAF_STARTOFFSET(fInode->GetVolume()->BlockLog()));
|
||||||
|
|
||||||
if (fLeafMap->br_startoff
|
if (fLeafMap->br_startoff
|
||||||
@ -87,9 +87,9 @@ LeafDirectory::FillMapEntry(int num, ExtentMapEntry* fMap)
|
|||||||
fMap->br_startoff = (firstHalf & MASK(63)) >> 9;
|
fMap->br_startoff = (firstHalf & MASK(63)) >> 9;
|
||||||
fMap->br_startblock = ((firstHalf & MASK(9)) << 43) | (secondHalf >> 21);
|
fMap->br_startblock = ((firstHalf & MASK(9)) << 43) | (secondHalf >> 21);
|
||||||
fMap->br_blockcount = secondHalf & MASK(21);
|
fMap->br_blockcount = secondHalf & MASK(21);
|
||||||
TRACE("FillMapEntry: startoff:(%ld), startblock:(%ld), blockcount:(%ld),"
|
TRACE("Extent::Init: startoff:(%" B_PRIu64 "), startblock:(%" B_PRIu64 "),"
|
||||||
"state:(%d)\n", fMap->br_startoff, fMap->br_startblock,
|
"blockcount:(%" B_PRIu64 "),state:(%" B_PRIu8 ")\n", fMap->br_startoff, fMap->br_startblock,
|
||||||
fMap->br_blockcount, fMap->br_state);
|
fMap->br_blockcount, fMap->br_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ LeafDirectory::FillBuffer(int type, char* blockBuffer, int howManyBlocksFurthur)
|
|||||||
} else if (type == LEAF) {
|
} else if (type == LEAF) {
|
||||||
fLeafBuffer = blockBuffer;
|
fLeafBuffer = blockBuffer;
|
||||||
ExtentLeafHeader* header = (ExtentLeafHeader*) fLeafBuffer;
|
ExtentLeafHeader* header = (ExtentLeafHeader*) fLeafBuffer;
|
||||||
TRACE("NumberOfEntries in leaf: (%d)\n",
|
TRACE("NumberOfEntries in leaf: (%" B_PRIu16 ")\n",
|
||||||
B_BENDIAN_TO_HOST_INT16(header->count));
|
B_BENDIAN_TO_HOST_INT16(header->count));
|
||||||
}
|
}
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@ -180,7 +180,7 @@ LeafDirectory::EntrySize(int len) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LeafDirectory::SearchAndFillDataMap(int blockNo)
|
LeafDirectory::SearchAndFillDataMap(uint64 blockNo)
|
||||||
{
|
{
|
||||||
int len = fInode->DataExtentsCount();
|
int len = fInode->DataExtentsCount();
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ LeafDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
while (fOffset != curDirectorySize) {
|
while (fOffset != curDirectorySize) {
|
||||||
blockNoFromAddress = BLOCKNO_FROM_ADDRESS(fOffset, volume);
|
blockNoFromAddress = BLOCKNO_FROM_ADDRESS(fOffset, volume);
|
||||||
|
|
||||||
TRACE("fOffset:(%d), blockNoFromAddress:(%d)\n",
|
TRACE("fOffset:(%" B_PRIu32 "), blockNoFromAddress:(%" B_PRIu32 ")\n",
|
||||||
fOffset, blockNoFromAddress);
|
fOffset, blockNoFromAddress);
|
||||||
if (fCurBlockNumber != blockNoFromAddress
|
if (fCurBlockNumber != blockNoFromAddress
|
||||||
&& blockNoFromAddress > fDataMap->br_startoff
|
&& blockNoFromAddress > fDataMap->br_startoff
|
||||||
@ -260,7 +260,7 @@ LeafDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
ExtentDataEntry* dataEntry = (ExtentDataEntry*) entry;
|
ExtentDataEntry* dataEntry = (ExtentDataEntry*) entry;
|
||||||
|
|
||||||
uint16 currentOffset = (char*)dataEntry - fDataBuffer;
|
uint16 currentOffset = (char*)dataEntry - fDataBuffer;
|
||||||
TRACE("GetNext: fOffset:(%d), currentOffset:(%d)\n",
|
TRACE("GetNext: fOffset:(%" B_PRIu32 "), currentOffset:(%" B_PRIu16 ")\n",
|
||||||
BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode), currentOffset);
|
BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode), currentOffset);
|
||||||
|
|
||||||
if (BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode) > currentOffset) {
|
if (BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode) > currentOffset) {
|
||||||
@ -268,7 +268,7 @@ LeafDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataEntry->namelen + 1 > *length)
|
if ((size_t)(dataEntry->namelen) >= *length)
|
||||||
return B_BUFFER_OVERFLOW;
|
return B_BUFFER_OVERFLOW;
|
||||||
|
|
||||||
fOffset = fOffset + EntrySize(dataEntry->namelen);
|
fOffset = fOffset + EntrySize(dataEntry->namelen);
|
||||||
@ -277,8 +277,8 @@ LeafDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
*length = dataEntry->namelen + 1;
|
*length = dataEntry->namelen + 1;
|
||||||
*ino = B_BENDIAN_TO_HOST_INT64(dataEntry->inumber);
|
*ino = B_BENDIAN_TO_HOST_INT64(dataEntry->inumber);
|
||||||
|
|
||||||
TRACE("Entry found. Name: (%s), Length: (%ld),ino: (%ld)\n", name,
|
TRACE("Entry found. Name: (%s), Length: (%" B_PRIuSIZE "),ino: (%" B_PRIu64 ")\n",
|
||||||
*length, *ino);
|
name, *length, *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,9 +292,9 @@ LeafDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
TRACE("LeafDirectory: Lookup\n");
|
TRACE("LeafDirectory: Lookup\n");
|
||||||
TRACE("Name: %s\n", name);
|
TRACE("Name: %s\n", name);
|
||||||
uint32 hashValueOfRequest = hashfunction(name, length);
|
uint32 hashValueOfRequest = hashfunction(name, length);
|
||||||
TRACE("Hashval:(%ld)\n", hashValueOfRequest);
|
TRACE("Hashval:(%" B_PRIu32 ")\n", hashValueOfRequest);
|
||||||
|
|
||||||
status_t status;
|
status_t status = B_OK;
|
||||||
if (fLeafBuffer == NULL)
|
if (fLeafBuffer == NULL)
|
||||||
status = FillBuffer(LEAF, fLeafBuffer, 0);
|
status = FillBuffer(LEAF, fLeafBuffer, 0);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
@ -306,7 +306,7 @@ LeafDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
int numberOfLeafEntries = B_BENDIAN_TO_HOST_INT16(leafHeader->count);
|
int numberOfLeafEntries = B_BENDIAN_TO_HOST_INT16(leafHeader->count);
|
||||||
TRACE("numberOfLeafEntries:(%d)\n", numberOfLeafEntries);
|
TRACE("numberOfLeafEntries:(%" B_PRId32 ")\n", numberOfLeafEntries);
|
||||||
int left = 0;
|
int left = 0;
|
||||||
int mid;
|
int mid;
|
||||||
int right = numberOfLeafEntries - 1;
|
int right = numberOfLeafEntries - 1;
|
||||||
@ -328,7 +328,7 @@ LeafDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
left = mid+1;
|
left = mid+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("left:(%d), right:(%d)\n", left, right);
|
TRACE("left:(%" B_PRId32 "), right:(%" B_PRId32 ")\n", left, right);
|
||||||
|
|
||||||
while (B_BENDIAN_TO_HOST_INT32(leafEntry[left].hashval)
|
while (B_BENDIAN_TO_HOST_INT32(leafEntry[left].hashval)
|
||||||
== hashValueOfRequest) {
|
== hashValueOfRequest) {
|
||||||
@ -342,7 +342,7 @@ LeafDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
uint32 dataBlockNumber = BLOCKNO_FROM_ADDRESS(address * 8, volume);
|
uint32 dataBlockNumber = BLOCKNO_FROM_ADDRESS(address * 8, volume);
|
||||||
uint32 offset = BLOCKOFFSET_FROM_ADDRESS(address * 8, fInode);
|
uint32 offset = BLOCKOFFSET_FROM_ADDRESS(address * 8, fInode);
|
||||||
|
|
||||||
TRACE("DataBlockNumber:(%d), offset:(%d)\n", dataBlockNumber, offset);
|
TRACE("DataBlockNumber:(%" B_PRIu32 "), offset:(%" B_PRIu32 ")\n", dataBlockNumber, offset);
|
||||||
if (dataBlockNumber != fCurBlockNumber) {
|
if (dataBlockNumber != fCurBlockNumber) {
|
||||||
fCurBlockNumber = dataBlockNumber;
|
fCurBlockNumber = dataBlockNumber;
|
||||||
SearchAndFillDataMap(dataBlockNumber);
|
SearchAndFillDataMap(dataBlockNumber);
|
||||||
@ -352,13 +352,13 @@ LeafDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("offset:(%d)\n", offset);
|
TRACE("offset:(%" B_PRIu32 ")\n", offset);
|
||||||
ExtentDataEntry* entry = (ExtentDataEntry*)(fDataBuffer + offset);
|
ExtentDataEntry* entry = (ExtentDataEntry*)(fDataBuffer + offset);
|
||||||
|
|
||||||
int retVal = strncmp(name, (char*)entry->name, entry->namelen);
|
int retVal = strncmp(name, (char*)entry->name, entry->namelen);
|
||||||
if (retVal == 0) {
|
if (retVal == 0) {
|
||||||
*ino = B_BENDIAN_TO_HOST_INT64(entry->inumber);
|
*ino = B_BENDIAN_TO_HOST_INT64(entry->inumber);
|
||||||
TRACE("ino:(%d)\n", *ino);
|
TRACE("ino:(%" B_PRIu64 ")\n", *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
left++;
|
left++;
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
void FillMapEntry(int num, ExtentMapEntry* map);
|
void FillMapEntry(int num, ExtentMapEntry* map);
|
||||||
status_t FillBuffer(int type, char* buffer,
|
status_t FillBuffer(int type, char* buffer,
|
||||||
int howManyBlocksFurthur);
|
int howManyBlocksFurthur);
|
||||||
void SearchAndFillDataMap(int blockNo);
|
void SearchAndFillDataMap(uint64 blockNo);
|
||||||
ExtentLeafEntry* FirstLeaf();
|
ExtentLeafEntry* FirstLeaf();
|
||||||
xfs_ino_t GetIno();
|
xfs_ino_t GetIno();
|
||||||
uint32 GetOffsetFromAddress(uint32 address);
|
uint32 GetOffsetFromAddress(uint32 address);
|
||||||
|
@ -10,11 +10,11 @@
|
|||||||
NodeDirectory::NodeDirectory(Inode* inode)
|
NodeDirectory::NodeDirectory(Inode* inode)
|
||||||
:
|
:
|
||||||
fInode(inode),
|
fInode(inode),
|
||||||
|
fDataMap(NULL),
|
||||||
|
fLeafMap(NULL),
|
||||||
fOffset(0),
|
fOffset(0),
|
||||||
fDataBuffer(NULL),
|
fDataBuffer(NULL),
|
||||||
fLeafBuffer(NULL),
|
fLeafBuffer(NULL),
|
||||||
fLeafMap(NULL),
|
|
||||||
fDataMap(NULL),
|
|
||||||
fCurBlockNumber(-1)
|
fCurBlockNumber(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -74,8 +74,8 @@ NodeDirectory::FillMapEntry(int num, ExtentMapEntry* fMap)
|
|||||||
fMap->br_startoff = (firstHalf & MASK(63)) >> 9;
|
fMap->br_startoff = (firstHalf & MASK(63)) >> 9;
|
||||||
fMap->br_startblock = ((firstHalf & MASK(9)) << 43) | (secondHalf >> 21);
|
fMap->br_startblock = ((firstHalf & MASK(9)) << 43) | (secondHalf >> 21);
|
||||||
fMap->br_blockcount = secondHalf & MASK(21);
|
fMap->br_blockcount = secondHalf & MASK(21);
|
||||||
TRACE("FillMapEntry: startoff:(%ld), startblock:(%ld), blockcount:(%ld),"
|
TRACE("Extent::Init: startoff:(%" B_PRIu64 "), startblock:(%" B_PRIu64 "),"
|
||||||
"state:(%d)\n", fMap->br_startoff, fMap->br_startblock,
|
"blockcount:(%" B_PRIu64 "),state:(%" B_PRIu8 ")\n", fMap->br_startoff, fMap->br_startblock,
|
||||||
fMap->br_blockcount, fMap->br_state);
|
fMap->br_blockcount, fMap->br_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ NodeDirectory::FillBuffer(int type, char* blockBuffer, int howManyBlocksFurthur)
|
|||||||
if (map->br_state != 0)
|
if (map->br_state != 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
size_t len = fInode->DirBlockSize();
|
ssize_t len = fInode->DirBlockSize();
|
||||||
if (blockBuffer == NULL) {
|
if (blockBuffer == NULL) {
|
||||||
blockBuffer = new(std::nothrow) char[len];
|
blockBuffer = new(std::nothrow) char[len];
|
||||||
if (blockBuffer == NULL)
|
if (blockBuffer == NULL)
|
||||||
@ -122,7 +122,8 @@ NodeDirectory::FillBuffer(int type, char* blockBuffer, int howManyBlocksFurthur)
|
|||||||
}
|
}
|
||||||
} else if (type == LEAF) {
|
} else if (type == LEAF) {
|
||||||
fLeafBuffer = blockBuffer;
|
fLeafBuffer = blockBuffer;
|
||||||
ExtentLeafHeader* header = (ExtentLeafHeader*) fLeafBuffer;
|
//TODO : see if we can do something with this header
|
||||||
|
//ExtentLeafHeader* header = (ExtentLeafHeader*) fLeafBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@ -172,7 +173,7 @@ NodeDirectory::EntrySize(int len) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeDirectory::SearchAndFillDataMap(int blockNo)
|
NodeDirectory::SearchAndFillDataMap(uint64 blockNo)
|
||||||
{
|
{
|
||||||
int len = fInode->DataExtentsCount();
|
int len = fInode->DataExtentsCount();
|
||||||
|
|
||||||
@ -214,7 +215,7 @@ NodeDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
while (fOffset != curDirectorySize) {
|
while (fOffset != curDirectorySize) {
|
||||||
blockNoFromAddress = BLOCKNO_FROM_ADDRESS(fOffset, volume);
|
blockNoFromAddress = BLOCKNO_FROM_ADDRESS(fOffset, volume);
|
||||||
|
|
||||||
TRACE("fOffset:(%d), blockNoFromAddress:(%d)\n",
|
TRACE("fOffset:(%" B_PRIu32 "), blockNoFromAddress:(%" B_PRIu32 ")\n",
|
||||||
fOffset, blockNoFromAddress);
|
fOffset, blockNoFromAddress);
|
||||||
if (fCurBlockNumber != blockNoFromAddress
|
if (fCurBlockNumber != blockNoFromAddress
|
||||||
&& blockNoFromAddress > fDataMap->br_startoff
|
&& blockNoFromAddress > fDataMap->br_startoff
|
||||||
@ -253,7 +254,7 @@ NodeDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
ExtentDataEntry* dataEntry = (ExtentDataEntry*) entry;
|
ExtentDataEntry* dataEntry = (ExtentDataEntry*) entry;
|
||||||
|
|
||||||
uint16 currentOffset = (char*)dataEntry - fDataBuffer;
|
uint16 currentOffset = (char*)dataEntry - fDataBuffer;
|
||||||
TRACE("GetNext: fOffset:(%d), currentOffset:(%d)\n",
|
TRACE("GetNext: fOffset:(%" B_PRIu32 "), currentOffset:(%" B_PRIu16 ")\n",
|
||||||
BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode), currentOffset);
|
BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode), currentOffset);
|
||||||
|
|
||||||
if (BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode) > currentOffset) {
|
if (BLOCKOFFSET_FROM_ADDRESS(fOffset, fInode) > currentOffset) {
|
||||||
@ -261,7 +262,7 @@ NodeDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataEntry->namelen + 1 > *length)
|
if ((size_t)(dataEntry->namelen) >= *length)
|
||||||
return B_BUFFER_OVERFLOW;
|
return B_BUFFER_OVERFLOW;
|
||||||
|
|
||||||
fOffset = fOffset + EntrySize(dataEntry->namelen);
|
fOffset = fOffset + EntrySize(dataEntry->namelen);
|
||||||
@ -270,8 +271,8 @@ NodeDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
*length = dataEntry->namelen + 1;
|
*length = dataEntry->namelen + 1;
|
||||||
*ino = B_BENDIAN_TO_HOST_INT64(dataEntry->inumber);
|
*ino = B_BENDIAN_TO_HOST_INT64(dataEntry->inumber);
|
||||||
|
|
||||||
TRACE("Entry found. Name: (%s), Length: (%ld),ino: (%ld)\n", name,
|
TRACE("Entry found. Name: (%s), Length: (%" B_PRIuSIZE "),ino: (%" B_PRIu64 ")\n",
|
||||||
*length, *ino);
|
name,*length, *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +286,7 @@ NodeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
TRACE("NodeDirectory: Lookup\n");
|
TRACE("NodeDirectory: Lookup\n");
|
||||||
TRACE("Name: %s\n", name);
|
TRACE("Name: %s\n", name);
|
||||||
uint32 hashValueOfRequest = hashfunction(name, length);
|
uint32 hashValueOfRequest = hashfunction(name, length);
|
||||||
TRACE("Hashval:(%ld)\n", hashValueOfRequest);
|
TRACE("Hashval:(%" B_PRIu32 ")\n", hashValueOfRequest);
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (fCurLeafBufferNumber != 1) {
|
if (fCurLeafBufferNumber != 1) {
|
||||||
@ -305,7 +306,7 @@ NodeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("rightMapOffset:(%d)\n", rightMapOffset);
|
TRACE("rightMapOffset:(%" B_PRIu32 ")\n", rightMapOffset);
|
||||||
|
|
||||||
FillMapEntry(fInode->DataExtentsCount() - 2, fLeafMap);
|
FillMapEntry(fInode->DataExtentsCount() - 2, fLeafMap);
|
||||||
fCurLeafMapNumber = 2;
|
fCurLeafMapNumber = 2;
|
||||||
@ -322,7 +323,7 @@ NodeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
int numberOfLeafEntries = B_BENDIAN_TO_HOST_INT16(leafHeader->count);
|
int numberOfLeafEntries = B_BENDIAN_TO_HOST_INT16(leafHeader->count);
|
||||||
TRACE("numberOfLeafEntries:(%d)\n", numberOfLeafEntries);
|
TRACE("numberOfLeafEntries:(%" B_PRId32 ")\n", numberOfLeafEntries);
|
||||||
int left = 0;
|
int left = 0;
|
||||||
int mid;
|
int mid;
|
||||||
int right = numberOfLeafEntries - 1;
|
int right = numberOfLeafEntries - 1;
|
||||||
@ -344,7 +345,7 @@ NodeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
left = mid + 1;
|
left = mid + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("left:(%d), right:(%d)\n", left, right);
|
TRACE("left:(%" B_PRId32 "), right:(%" B_PRId32 ")\n", left, right);
|
||||||
|
|
||||||
while (B_BENDIAN_TO_HOST_INT32(leafEntry[left].hashval)
|
while (B_BENDIAN_TO_HOST_INT32(leafEntry[left].hashval)
|
||||||
== hashValueOfRequest) {
|
== hashValueOfRequest) {
|
||||||
@ -358,7 +359,8 @@ NodeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
uint32 dataBlockNumber = BLOCKNO_FROM_ADDRESS(address * 8, volume);
|
uint32 dataBlockNumber = BLOCKNO_FROM_ADDRESS(address * 8, volume);
|
||||||
uint32 offset = BLOCKOFFSET_FROM_ADDRESS(address * 8, fInode);
|
uint32 offset = BLOCKOFFSET_FROM_ADDRESS(address * 8, fInode);
|
||||||
|
|
||||||
TRACE("DataBlockNumber:(%d), offset:(%d)\n", dataBlockNumber, offset);
|
TRACE("DataBlockNumber:(%" B_PRIu32 "), offset:(%" B_PRIu32 ")\n",
|
||||||
|
dataBlockNumber, offset);
|
||||||
if (dataBlockNumber != fCurBlockNumber) {
|
if (dataBlockNumber != fCurBlockNumber) {
|
||||||
fCurBlockNumber = dataBlockNumber;
|
fCurBlockNumber = dataBlockNumber;
|
||||||
SearchAndFillDataMap(dataBlockNumber);
|
SearchAndFillDataMap(dataBlockNumber);
|
||||||
@ -368,13 +370,13 @@ NodeDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("offset:(%d)\n", offset);
|
TRACE("offset:(%" B_PRIu32 ")\n", offset);
|
||||||
ExtentDataEntry* entry = (ExtentDataEntry*)(fDataBuffer + offset);
|
ExtentDataEntry* entry = (ExtentDataEntry*)(fDataBuffer + offset);
|
||||||
|
|
||||||
int retVal = strncmp(name, (char*)entry->name, entry->namelen);
|
int retVal = strncmp(name, (char*)entry->name, entry->namelen);
|
||||||
if (retVal == 0) {
|
if (retVal == 0) {
|
||||||
*ino = B_BENDIAN_TO_HOST_INT64(entry->inumber);
|
*ino = B_BENDIAN_TO_HOST_INT64(entry->inumber);
|
||||||
TRACE("ino:(%d)\n", *ino);
|
TRACE("ino:(%" B_PRIu64 ")\n", *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
left++;
|
left++;
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
void FillMapEntry(int num, ExtentMapEntry* map);
|
void FillMapEntry(int num, ExtentMapEntry* map);
|
||||||
status_t FillBuffer(int type, char* buffer,
|
status_t FillBuffer(int type, char* buffer,
|
||||||
int howManyBlocksFurther);
|
int howManyBlocksFurther);
|
||||||
void SearchAndFillDataMap(int blockNo);
|
void SearchAndFillDataMap(uint64 blockNo);
|
||||||
uint32 FindHashInNode(uint32 hashVal);
|
uint32 FindHashInNode(uint32 hashVal);
|
||||||
uint32 GetOffsetFromAddress(uint32 address);
|
uint32 GetOffsetFromAddress(uint32 address);
|
||||||
int EntrySize(int len) const;
|
int EntrySize(int len) const;
|
||||||
|
@ -86,17 +86,17 @@ ShortDirectory::Lookup(const char* name, size_t length, xfs_ino_t* ino)
|
|||||||
xfs_ino_t rootIno = fInode->GetVolume()->Root();
|
xfs_ino_t rootIno = fInode->GetVolume()->Root();
|
||||||
if (strcmp(name, ".") == 0 || (rootIno == fInode->ID())) {
|
if (strcmp(name, ".") == 0 || (rootIno == fInode->ID())) {
|
||||||
*ino = fInode->ID();
|
*ino = fInode->ID();
|
||||||
TRACE("ShortDirectory:Lookup: name: \".\" ino: (%d)\n", *ino);
|
TRACE("ShortDirectory:Lookup: name: \".\" ino: (%" B_PRIu64 ")\n", *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
*ino = GetIno(&fHeader->parent);
|
*ino = GetIno(&fHeader->parent);
|
||||||
TRACE("Parent: (%d)\n", *ino);
|
TRACE("Parent: (%" B_PRIu64 ")\n", *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShortFormEntry* entry = FirstEntry();
|
ShortFormEntry* entry = FirstEntry();
|
||||||
TRACE("Length of first entry: (%d),offset of first entry:"
|
TRACE("Length of first entry: (%" B_PRIu8 "),offset of first entry:"
|
||||||
"(%d)\n", entry->namelen, B_BENDIAN_TO_HOST_INT16(entry->offset.i));
|
"(%" B_PRIu16 ")\n", entry->namelen, B_BENDIAN_TO_HOST_INT16(entry->offset.i));
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
for (int i = 0; i < fHeader->count; i++) {
|
for (int i = 0; i < fHeader->count; i++) {
|
||||||
@ -124,7 +124,7 @@ ShortDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
strlcpy(name, ".", *length + 1);
|
strlcpy(name, ".", *length + 1);
|
||||||
*ino = fInode->ID();
|
*ino = fInode->ID();
|
||||||
fTrack = 1;
|
fTrack = 1;
|
||||||
TRACE("ShortDirectory:GetNext: name: \".\" ino: (%d)\n", *ino);
|
TRACE("ShortDirectory:GetNext: name: \".\" ino: (%" B_PRIu64 ")\n", *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
if (fTrack == 1) {
|
if (fTrack == 1) {
|
||||||
@ -135,19 +135,19 @@ ShortDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
strlcpy(name, "..", *length + 1);
|
strlcpy(name, "..", *length + 1);
|
||||||
*ino = GetIno(&fHeader->parent);
|
*ino = GetIno(&fHeader->parent);
|
||||||
fTrack = 2;
|
fTrack = 2;
|
||||||
TRACE("ShortDirectory:GetNext: name: \"..\" ino: (%d)\n", *ino);
|
TRACE("ShortDirectory:GetNext: name: \"..\" ino: (%" B_PRIu64 ")\n", *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShortFormEntry* entry = FirstEntry();
|
ShortFormEntry* entry = FirstEntry();
|
||||||
TRACE("Length of first entry: (%d), offset of first entry:"
|
TRACE("Length of first entry: (%" B_PRIu8 "),offset of first entry:"
|
||||||
"(%d)\n", entry->namelen, B_BENDIAN_TO_HOST_INT16(entry->offset.i));
|
"(%" B_PRIu16 ")\n", entry->namelen, B_BENDIAN_TO_HOST_INT16(entry->offset.i));
|
||||||
|
|
||||||
for (int i = 0; i < fHeader->count; i++) {
|
for (int i = 0; i < fHeader->count; i++) {
|
||||||
uint16 curOffset = B_BENDIAN_TO_HOST_INT16(entry->offset.i);
|
uint16 curOffset = B_BENDIAN_TO_HOST_INT16(entry->offset.i);
|
||||||
if (curOffset > fLastEntryOffset) {
|
if (curOffset > fLastEntryOffset) {
|
||||||
|
|
||||||
if (entry->namelen + 1 > *length)
|
if ((size_t)(entry->namelen + 1) > *length)
|
||||||
return B_BUFFER_OVERFLOW;
|
return B_BUFFER_OVERFLOW;
|
||||||
|
|
||||||
fLastEntryOffset = curOffset;
|
fLastEntryOffset = curOffset;
|
||||||
@ -156,8 +156,8 @@ ShortDirectory::GetNext(char* name, size_t* length, xfs_ino_t* ino)
|
|||||||
*length = entry->namelen + 1;
|
*length = entry->namelen + 1;
|
||||||
*ino = GetEntryIno(entry);
|
*ino = GetEntryIno(entry);
|
||||||
|
|
||||||
TRACE("Entry found. Name: (%s), Length: (%ld),ino: (%ld)\n", name,
|
TRACE("Entry found. Name: (%s), Length: (%" B_PRIuSIZE "),ino: (%" B_PRIu64 ")\n",
|
||||||
*length, *ino);
|
name,*length, *ino);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
entry = (ShortFormEntry*)((char*)entry + EntrySize(entry->namelen));
|
entry = (ShortFormEntry*)((char*)entry + EntrySize(entry->namelen));
|
||||||
|
@ -22,25 +22,6 @@ struct identify_cookie
|
|||||||
int cookie;
|
int cookie;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//! xfs_io() callback hook
|
|
||||||
static status_t
|
|
||||||
iterative_io_get_vecs_hook(void *cookie, io_request *request, off_t offset,
|
|
||||||
size_t size, struct file_io_vec *vecs, size_t *_count)
|
|
||||||
{
|
|
||||||
return B_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! xfs_io() callback hook
|
|
||||||
static status_t
|
|
||||||
iterative_io_finished_hook(void *cookie, io_request *request, status_t status,
|
|
||||||
bool partialTransfer, size_t bytesTransferred)
|
|
||||||
{
|
|
||||||
return B_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - Scanning
|
// #pragma mark - Scanning
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
#include "system_dependencies.h"
|
#include "system_dependencies.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reference documentation:
|
Reference documentation:
|
||||||
https://mirrors.edge.kernel.org/pub/linux/utils/fs/xfs/docs
|
https://mirrors.edge.kernel.org/pub/linux/utils/fs/xfs/docs
|
||||||
/xfs_filesystem_structure.pdf
|
/xfs_filesystem_structure.pdf
|
||||||
|
|
||||||
Chapter 5: Common XFS types (Page 8)
|
Chapter 5: Common XFS types (Page 8)
|
||||||
|
|
||||||
|
These are on-disk data types (how the data is stored on disk)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user