[haiku-development] Re: xfs crc checksums

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 12 Jun 2022 17:38:22 +0000

12 juin 2022, 16:32 "Raghav Sharma" <raghavself28@xxxxxxxxx> a écrit:

On haiku we have ByteOrder.h to convert endianness, though I haven't
seen declaring variables directly as little endian or big endian like
on linux (_be32, _le32).

The way it's currently designed in Haiku XFS code is that most structs have a 
SwapEndian() function

The idea then is:

- Load the data from disk and do validation (CRC, etc)
- Create the structure using the data and do the SwapEndian()
- The SwapEndian() function converts everything that needs to be converted to 
native CPU endianness

Then work in native CPU endianness all the time.

When we add write support we need to do that in the reverse order basically:

- SwapEndian() to convert from CPU order back to XFS order
- Compute the CRC and other things that is endian-dependant
- Finally write to disk

There are many possible ways to handle this, but if you want or need to use 
another one, try to be consistent in all the XFS code with how and when you do 
it. Otherwise it's a mess and we never know which endian each thing is in.

-- 
Adrien.

Other related posts: