@@ -28,7 +28,7 @@ Extent::FillMapEntry(void* pointerToMap)
28
28
{
29
29
uint64 firstHalf = *((uint64*)pointerToMap);
30
30
uint64 secondHalf = *((uint64*)pointerToMap + 1 );
31
- // dividing the 128 bits into 2 parts.
31
+ // dividing the 128 bits into 2 parts.
32
32
firstHalf = B_BENDIAN_TO_HOST_INT64 (firstHalf);
33
33
secondHalf = B_BENDIAN_TO_HOST_INT64 (secondHalf);
34
34
fMap ->br_state = (firstHalf >> 63 );
@@ -76,9 +76,9 @@ Extent::Init()
76
76
void * pointerToMap = DIR_DFORK_PTR (fInode ->Buffer (), fInode ->CoreInodeSize ());
77
77
FillMapEntry (pointerToMap);
78
78
ASSERT (fMap ->br_blockcount == 1 );
79
- // TODO: This is always true for block directories
80
- // If we use this implementation for leaf directories, this is not
81
- // always true
79
+ // TODO: This is always true for block directories
80
+ // If we use this implementation for leaf directories, this is not
81
+ // always true
82
82
status_t status = FillBlockBuffer ();
83
83
if (status != B_OK)
84
84
return status;
@@ -274,7 +274,7 @@ ExtentDataHeader::ExpectedMagic(int8 WhichDirectory, Inode* inode)
274
274
uint32
275
275
ExtentDataHeader::CRCOffset ()
276
276
{
277
- return XFS_EXTENT_CRC_OFF - XFS_EXTENT_V5_VPTR_OFF ;
277
+ return offsetof (ExtentDataHeaderV5::OnDiskData, crc) ;
278
278
}
279
279
280
280
@@ -301,29 +301,23 @@ uint32
301
301
ExtentDataHeader::Size (Inode* inode)
302
302
{
303
303
if (inode->Version () == 1 || inode->Version () == 2 )
304
- return sizeof (ExtentDataHeaderV4) - XFS_EXTENT_V4_VPTR_OFF ;
304
+ return sizeof (ExtentDataHeaderV4::OnDiskData) ;
305
305
else
306
- return sizeof (ExtentDataHeaderV5) - XFS_EXTENT_V5_VPTR_OFF ;
306
+ return sizeof (ExtentDataHeaderV5::OnDiskData) ;
307
307
}
308
308
309
309
310
310
void
311
- ExtentDataHeaderV4::SwapEndian ()
311
+ ExtentDataHeaderV4::_SwapEndian ()
312
312
{
313
- magic = B_BENDIAN_TO_HOST_INT32 (magic);
313
+ fData . magic = ( B_BENDIAN_TO_HOST_INT32 (fData . magic ) );
314
314
}
315
315
316
316
317
317
ExtentDataHeaderV4::ExtentDataHeaderV4 (const char * buffer)
318
318
{
319
- uint32 offset = 0 ;
320
-
321
- magic = *(uint32*)(buffer + offset);
322
- offset += sizeof (uint32);
323
-
324
- memcpy (bestfree, buffer + offset, XFS_DIR2_DATA_FD_COUNT * sizeof (FreeRegion));
325
-
326
- SwapEndian ();
319
+ memcpy (&fData , buffer, sizeof (fData ));
320
+ _SwapEndian ();
327
321
}
328
322
329
323
@@ -335,7 +329,7 @@ ExtentDataHeaderV4::~ExtentDataHeaderV4()
335
329
uint32
336
330
ExtentDataHeaderV4::Magic ()
337
331
{
338
- return magic;
332
+ return fData . magic ;
339
333
}
340
334
341
335
@@ -360,52 +354,29 @@ ExtentDataHeaderV4::Owner()
360
354
}
361
355
362
356
363
- uuid_t *
357
+ const uuid_t &
364
358
ExtentDataHeaderV4::Uuid ()
365
359
{
366
- return NULL ;
360
+ static uuid_t nullUuid;
361
+ return nullUuid;
367
362
}
368
363
369
364
370
365
void
371
- ExtentDataHeaderV5::SwapEndian ()
366
+ ExtentDataHeaderV5::_SwapEndian ()
372
367
{
373
- magic = B_BENDIAN_TO_HOST_INT32 (magic);
374
- blkno = B_BENDIAN_TO_HOST_INT64 (blkno);
375
- lsn = B_BENDIAN_TO_HOST_INT64 (lsn);
376
- owner = B_BENDIAN_TO_HOST_INT64 (owner);
377
- pad = B_BENDIAN_TO_HOST_INT32 (pad);
368
+ fData . magic = B_BENDIAN_TO_HOST_INT32 (fData . magic );
369
+ fData . blkno = B_BENDIAN_TO_HOST_INT64 (fData . blkno );
370
+ fData . lsn = B_BENDIAN_TO_HOST_INT64 (fData . lsn );
371
+ fData . owner = B_BENDIAN_TO_HOST_INT64 (fData . owner );
372
+ fData . pad = B_BENDIAN_TO_HOST_INT32 (fData . pad );
378
373
}
379
374
380
375
381
376
ExtentDataHeaderV5::ExtentDataHeaderV5 (const char * buffer)
382
377
{
383
- uint32 offset = 0 ;
384
-
385
- magic = *(uint32*)(buffer + offset);
386
- offset += sizeof (uint32);
387
-
388
- crc = *(uint32*)(buffer + offset);
389
- offset += sizeof (uint32);
390
-
391
- blkno = *(uint64*)(buffer + offset);
392
- offset += sizeof (uint64);
393
-
394
- lsn = *(uint64*)(buffer + offset);
395
- offset += sizeof (uint64);
396
-
397
- memcpy (&uuid, buffer + offset, sizeof (uuid_t ));
398
- offset += sizeof (uuid_t );
399
-
400
- owner = *(uint64*)(buffer + offset);
401
- offset += sizeof (uint64);
402
-
403
- memcpy (bestfree, buffer + offset, XFS_DIR2_DATA_FD_COUNT * sizeof (FreeRegion));
404
- offset += XFS_DIR2_DATA_FD_COUNT * sizeof (FreeRegion);
405
-
406
- pad = *(uint32*)(buffer + offset);
407
-
408
- SwapEndian ();
378
+ memcpy (&fData , buffer, sizeof (fData ));
379
+ _SwapEndian ();
409
380
}
410
381
411
382
@@ -417,33 +388,33 @@ ExtentDataHeaderV5::~ExtentDataHeaderV5()
417
388
uint32
418
389
ExtentDataHeaderV5::Magic ()
419
390
{
420
- return magic;
391
+ return fData . magic ;
421
392
}
422
393
423
394
424
395
uint64
425
396
ExtentDataHeaderV5::Blockno ()
426
397
{
427
- return blkno;
398
+ return fData . blkno ;
428
399
}
429
400
430
401
431
402
uint64
432
403
ExtentDataHeaderV5::Lsn ()
433
404
{
434
- return lsn;
405
+ return fData . lsn ;
435
406
}
436
407
437
408
438
409
uint64
439
410
ExtentDataHeaderV5::Owner ()
440
411
{
441
- return owner;
412
+ return fData . owner ;
442
413
}
443
414
444
415
445
- uuid_t *
416
+ const uuid_t &
446
417
ExtentDataHeaderV5::Uuid ()
447
418
{
448
- return & uuid;
449
- }
419
+ return fData . uuid ;
420
+ }
0 commit comments