Skip to content

Commit ced8029

Browse files
committed
https://github.com/AssafTzurEl/DiscUtils/commit/3853944811a16d6220dcb6e8d408561e05569e43
[xfs-btree-bugfix] Fix bug in XFS B+tree inode In XFS source code, bb_leftsib and bb_rightsib (declared in xfs_format.h) are both of type __be32, which is an unsigned int32 (and not 64). While I was there, I added Inode.ToString() to help me differentiate beween inodes: In Linux, inodes are identified by a unique ID.
1 parent 1e02bb3 commit ced8029

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/java/DiscUtils/Xfs/BTreeExtentHeader.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public int readFrom(byte[] buffer, int offset) {
8989
_magic = EndianUtilities.toUInt32BigEndian(buffer, offset);
9090
_level = EndianUtilities.toUInt16BigEndian(buffer, offset + 0x4);
9191
_numberOfRecords = EndianUtilities.toUInt16BigEndian(buffer, offset + 0x6);
92-
_leftSibling = EndianUtilities.toInt64BigEndian(buffer, offset + 0x8);
93-
_rightSibling = EndianUtilities.toInt64BigEndian(buffer, offset + 0xC);
92+
_leftSibling = EndianUtilities.toInt32BigEndian(buffer, offset + 0x8);
93+
_rightSibling = EndianUtilities.toInt32BigEndian(buffer, offset + 0xC);
9494
return 24;
9595
}
9696

src/main/java/DiscUtils/Xfs/Inode.java

+12
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
public class Inode implements IByteArraySerializable {
4343
public Inode(long number, Context context) {
44+
_number = number;
4445
SuperBlock sb = context.getSuperBlock();
4546
setRelativeInodeNumber((int) (number & sb.getRelativeInodeMask()));
4647
setAllocationGroup((int) ((number & sb.getAgInodeMask()) >>> (sb.getAgBlocksLog2() + sb.getInodesPerBlockLog2())));
@@ -98,6 +99,12 @@ public void setBlockOffset(int value) {
9899
_blockOffset = value;
99100
}
100101

102+
private long _number;
103+
104+
public long getNumber() {
105+
return _number;
106+
}
107+
101108
public static final short InodeMagic = 0x494e;
102109

103110
/**
@@ -577,4 +584,9 @@ public IBuffer bufferFromExtentList(Context context, List<Extent> extents) {
577584
}
578585
return new StreamBuffer(new ExtentStream(this.getLength(), builderExtents), Ownership.Dispose);
579586
}
587+
588+
@Override
589+
public String toString() {
590+
return "inode " + _number;
591+
}
580592
}

0 commit comments

Comments
 (0)