Skip to content

Commit 3853944

Browse files
author
Assaf Tzur-El
committed
[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. Branch: [xfs-btree-bugfix]
1 parent b3ffb51 commit 3853944

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Library/DiscUtils.Xfs/BTreeExtentHeader.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,15 @@ internal abstract class BTreeExtentHeader : IByteArraySerializable
4040

4141
public long RightSibling { get; private set; }
4242

43-
public virtual int Size
44-
{
45-
get { return 24; }
46-
}
43+
public virtual int Size => 24;
4744

4845
public virtual int ReadFrom(byte[] buffer, int offset)
4946
{
5047
Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset);
5148
Level = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x4);
5249
NumberOfRecords = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x6);
53-
LeftSibling = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x8);
54-
RightSibling = EndianUtilities.ToInt64BigEndian(buffer, offset + 0xC);
50+
LeftSibling = EndianUtilities.ToInt32BigEndian(buffer, offset + 0x8);
51+
RightSibling = EndianUtilities.ToInt32BigEndian(buffer, offset + 0xC);
5552
return 24;
5653
}
5754

Library/DiscUtils.Xfs/Inode.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ internal class Inode : IByteArraySerializable
3131
{
3232
public Inode(ulong number, Context context)
3333
{
34+
Number = number;
3435
var sb = context.SuperBlock;
3536
RelativeInodeNumber = (uint) (number & sb.RelativeInodeMask);
3637
AllocationGroup = (uint) ((number & sb.AgInodeMask) >> (sb.AgBlocksLog2 + sb.InodesPerBlockLog2));
@@ -57,6 +58,8 @@ public Inode(uint allocationGroup, uint relInode)
5758

5859
public uint BlockOffset { get; private set; }
5960

61+
public ulong Number { get; }
62+
6063
public const ushort InodeMagic = 0x494e;
6164
/// <summary>
6265
/// The inode signature where these two bytes are 0x494e, or "IN" in ASCII.
@@ -319,5 +322,10 @@ public IBuffer BufferFromExtentList(Context context, IList<Extent> extents)
319322
}
320323
return new StreamBuffer(new ExtentStream((long) this.Length, builderExtents), Ownership.Dispose);
321324
}
325+
326+
public override string ToString()
327+
{
328+
return "inode " + Number;
329+
}
322330
}
323331
}

0 commit comments

Comments
 (0)