Jump to content











Photo
- - - - -

Extents

file copy in use

  • Please log in to reply
104 replies to this topic

#76 noel

noel

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:nantes
  •  
    France

Posted 04 May 2019 - 01:09 PM

Hello,

I'm sure there is no impact with extents because unity is "clsuter", not sector. But i can be wrong.

 

For LBA,  unity is sector.

So, for LBA in MBR style with disk 4K 512e, i think that the "firmware/controler" inside the disk make the conversion from "normal" sector size(not physical sector size but which name to call the "normal" sector size, "logical size" perhaps). I think, not verify.

For LBA in MBR with disk 4Kn, so big new disk, not usb key, i think no problem because normal and physical sizes are identical.

In GPT disk, i think that the calculation must take care of the "protective MBR sector" if the disk is initialized by a MS program. And also struct is different, so calculation is complex ( i put links to ms info in a previous post).

 

All above is for basic disk.

For dynamic disk, i think that some extents can be on a physical disk 1 and some others extents can be on an other physical disk 2. But i'm not sure. It's only that i understand when i read MS informations.

 

I hope you can give more good, better, verified informations.

 

Ps : i know easy2boot doesn't need to play with these details ( Basic or not, 4K 512n, 4Kn, GPT/MBR ). And i will dead before a USB key comes with GPT and 4Kn !



#77 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 04 May 2019 - 01:16 PM

And to add some more complexity (because we just love it), if you apply wofcompress (see here), then the extents concept does not apply anymore :)

See below after applying wofcompress to f:\data0.vmdk:

>fsutil file queryextents f:\data0.vmdk
VCN : 0x0        Clusters : 0x650      LCN : 0xffffffffffffffff 

But lets keep that one for later as this is deviating from the main topic.

 

I am going to create various virtual disks : 512/512, 512/4096, 4096/4096 in MBR or GPT mode and see how some software (mainly mines... :) ) behave.

 

Being a dirty dev myself, I would not be surprised to find some code out there with a ugly 512 value hardcoded which in some situations may lead to at best wierd results, at worse catastrophic failures.

 

Thanks for bringing this (4k disk) to my attention : i have always dealt with (old) 512 sector size disks but cannot ignore different sector sizes. 



#78 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 04 May 2019 - 02:53 PM

Version 1.4 out.

 

sector size = 4096 was not handled properly.

 

Adding all extents sector count and multiplying by the sector size was not matching the filesize in bytes.

 

Thanks goes to Noel to spot this out ! :)

 

Before

>extents-win64.exe f:\test.dmp
extents 1.3 by erwan2212@gmail.com
***************************
Bytes Per Sector:4096
Sectors per Cluster:1
Cluster size :4096
Filesystem :NTFS
***************************
Filename:f:\test.dmp
File Cluster count :36938 (151298048 bytes)
File size in bytes :151298048
File cluster first :29920
Extents count :2

extents_[0] -  VCN : 0 LCN : 29920 Lba : 30176 Sectors : 282864
extents_[1] -  VCN : 35358 LCN : 1343 Lba : 1599 Sectors : 12640

After

>extents-win64.exe f:\test.dmp
extents 1.4 by erwan2212@gmail.com
***************************
Bytes Per Sector:4096
Sectors per Cluster:1
Cluster size :4096
Filesystem :NTFS
***************************
Filename:f:\test.dmp
File Cluster count :36938 (151298048 bytes)
File size in bytes :151298048
File cluster first :29920
Extents count :2

extents_[0] -  VCN : 0 LCN : 29920 Lba : 30176 Sectors : 35358
extents_[1] -  VCN : 35358 LCN : 1343 Lba : 34595 Sectors : 1580


#79 noel

noel

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:nantes
  •  
    France

Posted 04 May 2019 - 04:16 PM

Hi,

your disk containing the target file is it MBR or GPT?

If GPT, i think LBA is wrong ( if i understand correctly MS documentation ).

But i cut my hair by 4 !



#80 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 04 May 2019 - 04:38 PM

But i cut my hair by 4 !

 

You are not going to have much hair left if you keep doing that :)

I know I would not !

 

Will look at MBR vs GPT now (now that the 512/4096 is sorted out).



#81 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 04 May 2019 - 05:39 PM

If GPT, i think LBA is wrong ( if i understand correctly MS documentation ).

 

Tried on a GPT disk.

LBA looks ok to me: I editer the underlying disk with HxD, reached offset LBA*512 and could witness my file was there.

>extents-win64.exe f:\test.dmp
extents 1.4 by erwan2212@gmail.com
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
Filesystem :NTFS
***************************
Filename:f:\test.dmp
File Cluster count :36938 (151298048 bytes)
File size in bytes :151298048
File cluster first :39543
Extents count :1

extents_[0] -  VCN : 0 LCN : 39543 Lba : 316472 Sectors : 295504


#82 noel

noel

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:nantes
  •  
    France

Posted 04 May 2019 - 09:41 PM

Hi,

I understand my mistake : your LBA is allways good/right because you use the  IOCTL_VOLUME_LOGICAL_TO_PHYSICAL API (and don't calculate it manually). Thank you for the code.

I miss this info


#83 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 06 May 2019 - 11:34 AM

LBA is a way to measure an absolute offset from the first sector (Sector LBA 0) and it is ABSOLUTELY THE SAME in both MBR and GPT, API, manually or otherwise.

 

When you read (say) LBA 5874, it means that there are 5874 sectors before it, this is true as well in a non-initialized or not partitioned device.

 

:duff:

Wonko



#84 devdevadev

devdevadev

    Silver Member

  • Advanced user
  • 540 posts
  •  
    India

Posted 28 December 2021 - 12:12 PM

It's looking extents-win32.exe unable to calculate/get file extents of PTN2:\ventoy.disk.img located in FAT32 Partition 2 of USB Drive. I have also check other files of the FAT32 Partition 2, But extents-win32.exe does not calculate extents of any files in the FAT32 volume ??

@echo off
pushd "%~dp0"
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
set DD=1
set PTN2=I:
if exist "%PTN2%\ventoy.disk.img" call :EXTENTS "%PTN2%\ventoy.disk.img"
echo.
pause
if exist "%PTN2%\ventoy.disk.img" call :GETFILEEXTENTS "%PTN2%\ventoy.disk.img"
pause


:EXTENTS
FOR /F "tokens=1,2,3,4,5,6 delims=:-" %%A IN ('extents-win32.exe "%~1"') DO (
SET ThisToken1=%%A
SET ThisToken1=!ThisToken1: =_!
SET my!ThisToken1!=%%B
IF !ThisToken1!==extents_[0]_ CALL :get_LBA Start_LBA %%E&&CALL :get_LBA Length_LBA %%F
)
SET Filename="%~1"

ECHO Filename=%Filename%
ECHO Start_LBA=%Start_LBA%
ECHO Length_LBA=%Length_LBA%
GOTO :EOF

:get_LBA
SET %1=%2
GOTO :EOF


:GETFILEEXTENTS
for /f "tokens=5,7 delims=: " %%A in ('getfileextents "%~1"') do (set START=%%A & set LENGTH=%%B)
for /f "tokens=3" %%A in ('hex2dec.exe -nobanner 0x%START%') do set STARTLBA=%%A
for /f "tokens=3" %%A in ('hex2dec.exe -nobanner 0x%LENGTH%') do set LENGTHLBA=%%A
set FILE="%~1"
echo FILE=%FILE%
echo STARTLBA=%STARTLBA%
echo LENGTHLBA=%LENGTHLBA%
goto :EOF

Output-

Filename="I:\ventoy.disk.img"
Start_LBA=0
Length_LBA=65536

FILE="I:\ventoy.disk.img"
STARTLBA=
LENGTHLBA=
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
Filesystem :FAT32
***************************
Filename:I:\ventoy.disk.img
File Cluster count :8192 -> in bytes: 33554432
File size in bytes :33554432
File cluster first :21072
Extents count :1

extents_[0] -  VCN : 0 LCN : 21072 Lba : 0 Sectors : 65536



***************************
Bytes Per Sector:512
Setors per Cluster:8
Cluster size :4096
Filesystem :FAT32
***************************
Filename:I:\ventoyKAS.disk.img
File Cluster count :8192 -> in bytes: 33554432
File size in bytes :33554432
File cluster first :29264
Extents count :1

extents_[0] -  VCN : 0 LCN : 29264 Lba : 0 Sectors : 65536



***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
Filesystem :FAT32
***************************
Filename:I:\ventoyNS.disk.img
File Cluster count :8192 -> in bytes: 33554432
File size in bytes :33554432
File cluster first :37456
Extents count :1

extents_[0] -  VCN : 0 LCN : 37456 Lba : 0 Sectors : 65536P

If possible please fix this issue so that we can get correct file extents of .img files location in FAT32/FAT volumes...

 

Regards.....



#85 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 28 December 2021 - 01:03 PM

Hi Devdevadev,

 

Although the issue you are reporting is probably not related to the extents-win32 version number, make sure you use the latest version here : https://github.com/e.../master/console .

 

Also, looking at your output, what is wrong exactly?

I read one extent ?

 

Last but not least, extents and fat32, i need to review the filesystem specs...as clearly I had coded extents-win32 for NTFS...

 

Cheers,

Erwan



#86 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 28 December 2021 - 01:16 PM

This is what I get on a fat32 usb key.

I did not cross check it against other tools but looks fine at first look... ?

 

I believe your issue with FAT32 and extents is about a possibly an old (buggy) version you are using.

I am using latest 1.4 version from december 2020.

 

The only restriction with FAT32 and/or removable disks will be the LBA (which will always report 0 as i believe IOCTL_VOLUME_LOGICAL_TO_PHYSICAL only works with NTFS and/or local disk ).

Although off topic here, removable disk should "normally" have one partition only so in theory using this formula could work : physical offset = LCN * bytes_per_cluster + offset to start of first cluster.

extents-win32.exe e:\mstsc.exe.dmp
extents 1.4 by erwan2212@gmail.com
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
Filesystem :FAT32
***************************
Filename:e:\mstsc.exe.dmp
File Cluster count :95598 (391569408 bytes)
File size in bytes :391568511
File cluster first :6737
Extents count :3

#:0     VCN:0   LCN:6737        Clusters:24350  Lba:0
#:1     VCN:24350       LCN:51295       Clusters:6736   Lba:0
#:2     VCN:31086       LCN:64767       Clusters:64512  Lba:0


#87 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 28 December 2021 - 01:28 PM

@erwan.l

 

Maybe you could add/implement the calculation for Fat32?

 

http://reboot.pro/in...=22571&p=220283

 

:duff:

Wonko



#88 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 28 December 2021 - 01:34 PM

@erwan.l

 

Maybe you could add/implement the calculation for Fat32?

 

http://reboot.pro/in...=22571&p=220283

 

duff.gif

Wonko

 

Hey Wonko,

Nice too see you, long time no speak !

Time is flying by too fast and before I knew my age was incremented by 1 ohmy.png

And this seems to be a feature, not a bug i can fix : life sucks smile.png

 

About devdevadev post, i was not too sure what the bug was about: listing extents or calculating LBA for each extent?

 

Thanks for pointing me out to the original discussion and i shall go back to my old code based on your statement "if it uses VCN to calculate LBA, if VCN is 0 than LBA will also be 0".

 

I am using a windows api (deviceiocontrol + IOCTL_VOLUME_LOGICAL_TO_PHYSICAL ) to calculate LBA so if incorrect, windows is incorrect smile.png

 

Take care,

Erwan



#89 devdevadev

devdevadev

    Silver Member

  • Advanced user
  • 540 posts
  •  
    India

Posted 28 December 2021 - 02:02 PM

Hi Devdevadev,

 

Although the issue you are reporting is probably not related to the extents-win32 version number, make sure you use the latest version here : https://github.com/e.../master/console .

 

Also, looking at your output, what is wrong exactly?

I read one extent ?

 

Last but not least, extents and fat32, i need to review the filesystem specs...as clearly I had coded extents-win32 for NTFS...

 

Cheers,

Erwan


C:\Users\SBI\Downloads\extents\console>extents-win32.exe "I:\ventoy.disk.img"
extents 1.4 by erwan2212@gmail.com
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
Filesystem :FAT32
***************************
Filename:I:\ventoy.disk.img
File Cluster count :8192 (33554432 bytes)
File size in bytes :33554432
File cluster first :175000
Extents count :10

extents_[0] -  VCN : 0 LCN : 175000 Lba : 0 Sectors : 6560
extents_[1] -  VCN : 820 LCN : 130145 Lba : 0 Sectors : 6560
extents_[2] -  VCN : 1640 LCN : 152572 Lba : 0 Sectors : 6560
extents_[3] -  VCN : 2460 LCN : 107718 Lba : 0 Sectors : 6560
extents_[4] -  VCN : 3280 LCN : 189952 Lba : 0 Sectors : 6560
extents_[5] -  VCN : 4100 LCN : 163786 Lba : 0 Sectors : 6560
extents_[6] -  VCN : 4920 LCN : 96504 Lba : 0 Sectors : 6560
extents_[7] -  VCN : 5740 LCN : 118931 Lba : 0 Sectors : 6560
extents_[8] -  VCN : 6560 LCN : 141358 Lba : 0 Sectors : 6560
extents_[9] -  VCN : 7380 LCN : 182476 Lba : 0 Sectors : 6496

C:\Users\SBI\Downloads\extents\console>

I think I am using latest version ? Maybe there is an issue with FAT32 File System compatibility in extents-win32.exe ?

 

Regards...



#90 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 28 December 2021 - 02:19 PM


C:\Users\SBI\Downloads\extents\console>extents-win32.exe "I:\ventoy.disk.img"
extents 1.4 by erwan2212@gmail.com
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
Filesystem :FAT32
***************************
Filename:I:\ventoy.disk.img
File Cluster count :8192 (33554432 bytes)
File size in bytes :33554432
File cluster first :175000
Extents count :10

extents_[0] -  VCN : 0 LCN : 175000 Lba : 0 Sectors : 6560
extents_[1] -  VCN : 820 LCN : 130145 Lba : 0 Sectors : 6560
extents_[2] -  VCN : 1640 LCN : 152572 Lba : 0 Sectors : 6560
extents_[3] -  VCN : 2460 LCN : 107718 Lba : 0 Sectors : 6560
extents_[4] -  VCN : 3280 LCN : 189952 Lba : 0 Sectors : 6560
extents_[5] -  VCN : 4100 LCN : 163786 Lba : 0 Sectors : 6560
extents_[6] -  VCN : 4920 LCN : 96504 Lba : 0 Sectors : 6560
extents_[7] -  VCN : 5740 LCN : 118931 Lba : 0 Sectors : 6560
extents_[8] -  VCN : 6560 LCN : 141358 Lba : 0 Sectors : 6560
extents_[9] -  VCN : 7380 LCN : 182476 Lba : 0 Sectors : 6496

C:\Users\SBI\Downloads\extents\console>

I think I am using latest version ? Maybe there is an issue with FAT32 File System compatibility in extents-win32.exe ?

 

Regards...

 

 

Wonko is going to slap me for that but ... although your version display 1.4, "latest" version 1.4 has a slightly nicer display smile.png

Get it from here : https://github.com/e.../master/console .

 

Yes clearly LBA is not working on fat32 for now : working on it right now.

You'll be my beta tester smile.png

 

Regards,

Erwan

 

And before Wonko strikes me 

 

2aa5f6cc2897c1f30f749db9fb9cc342.jpg


  • devdevadev likes this

#91 devdevadev

devdevadev

    Silver Member

  • Advanced user
  • 540 posts
  •  
    India

Posted 28 December 2021 - 02:33 PM

@echo off
pushd "%~dp0"
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
set DD=1
set PTN2=I:
if exist "%PTN2%\ventoy.disk.img" call :EXTENTS "%PTN2%\ventoy.disk.img"
echo.
pause




:EXTENTS
FOR /F "tokens=1,2,3,4,5,6 delims=:-" %%A IN ('extents-win32.exe "%~1"') DO (
SET ThisToken1=%%A
SET ThisToken1=!ThisToken1: =_!
SET my!ThisToken1!=%%B
IF !ThisToken1!==extents_[0]_ CALL :get_LBA Start_LBA %%E&&CALL :get_LBA Length_LBA %%F
)
SET Filename="%~1"

ECHO Filename=%Filename%
ECHO Start_LBA=%Start_LBA%
ECHO Length_LBA=%Length_LBA%
GOTO :EOF

:get_LBA
SET %1=%2
GOTO :EOF



#92 devdevadev

devdevadev

    Silver Member

  • Advanced user
  • 540 posts
  •  
    India

Posted 28 December 2021 - 02:41 PM

Wonko is going to slap me for that but ... although your version display 1.4, "latest" version 1.4 has a slightly nicer display smile.png

Get it from here : https://github.com/e.../master/console .

 

Yes clearly LBA is not working on fat32 for now : working on it right now.

You'll be my beta tester smile.png

 

Regards,

Erwan

 

And before Wonko strikes me 

 


C:\Users\SBI\Downloads\console>extents-win32.exe "I:\ventoy.disk.img"
extents 1.4 by erwan2212@gmail.com
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
Filesystem :FAT32
***************************
Filename:I:\ventoy.disk.img
File Cluster count :8192 (33554432 bytes)
File size in bytes :33554432
File cluster first :175000
Extents count :10

#:0     VCN:0   LCN:175000      Lba:0   Clusters:820
#:1     VCN:820 LCN:130145      Lba:0   Clusters:820
#:2     VCN:1640        LCN:152572      Lba:0   Clusters:820
#:3     VCN:2460        LCN:107718      Lba:0   Clusters:820
#:4     VCN:3280        LCN:189952      Lba:0   Clusters:820
#:5     VCN:4100        LCN:163786      Lba:0   Clusters:820
#:6     VCN:4920        LCN:96504       Lba:0   Clusters:820
#:7     VCN:5740        LCN:118931      Lba:0   Clusters:820
#:8     VCN:6560        LCN:141358      Lba:0   Clusters:820
#:9     VCN:7380        LCN:182476      Lba:0   Clusters:812

C:\Users\SBI\Downloads\console>

in latest version, It does not seems to show Sectors ?

I need both StartLBA and SectorsLBA so that I can map PTN2:\ventoy.disk.img to PTN2 of USB Drive...



#93 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 28 December 2021 - 03:10 PM

OK 1.5 is out and does handle lba for fat32.

To be checked thus. (i'll check in hxedit).

Get it here : https://github.com/e.../master/console.

 

I am using this formula : physical offset = LCN * bytes_per_cluster + StartingOffset.

 

But as of fat32, I am wondering how to account with this statement read out there "The location of the first data sector in FAT file systems (which is also referred to as the second cluster) can be calculated in the following manner : It is the number of Reserved Sectors + The number of FATs multiplied by Sectors per FAT + The number of RootDirSectors".

 

@Wonko : your thoughts?

It does differ from your statement in the referring post :

"Basically the formula is:

Sectors_Before+Reserved_Sectors+Number_of_FATs(normally 2) * Sectors_per_FAT+LCN * Cluster_size+(possibly) Cluster_bias"

 

As for "I need both StartLBA and SectorsLBA" : startLBA you have it alreadt (it is LBA) - SectorsLBA would be LBA divided by Bytes Per Sector ?

Or if you refer to "Sectors" in previous versions, this was the number of sectors per extent which is now expressed in (number of) "Clusters".

You would get a similar display with fsutil file queryextents (except that extents will give you the LBA).

extents-win32.exe e:\mstsc.exe.dmp
extents 1.5 by erwan2212@gmail.com
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
PartitionNumber: 1
StartingOffset: 1048576
Filesystem :FAT32
***************************
Filename:e:\mstsc.exe.dmp
File Cluster count :95598 (391569408 bytes)
File size in bytes :391568511
File cluster first :6737
Extents count :3

#:0     VCN:0   LCN:6737        Clusters:24350  Lba:55944
#:1     VCN:24350       LCN:51295       Clusters:6736   Lba:412408
#:2     VCN:31086       LCN:64767       Clusters:64512  Lba:520184


#94 devdevadev

devdevadev

    Silver Member

  • Advanced user
  • 540 posts
  •  
    India

Posted 28 December 2021 - 03:18 PM


C:\Users\SBI\Downloads\console>extents-win32.exe "I:\ventoy.disk.img"
extents 1.5 by erwan2212@gmail.com
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
PartitionNumber: 2
StartingOffset: 29050798080
Filesystem :FAT32
***************************
Filename:I:\ventoy.disk.img
File Cluster count :8192 (33554432 bytes)
File size in bytes :33554432
File cluster first :175000
Extents count :10

#:0     VCN:0   LCN:175000      Clusters:820    Lba:58139840
#:1     VCN:820 LCN:130145      Clusters:820    Lba:57781000
#:2     VCN:1640        LCN:152572      Clusters:820    Lba:57960416
#:3     VCN:2460        LCN:107718      Clusters:820    Lba:57601584
#:4     VCN:3280        LCN:189952      Clusters:820    Lba:58259456
#:5     VCN:4100        LCN:163786      Clusters:820    Lba:58050128
#:6     VCN:4920        LCN:96504       Clusters:820    Lba:57511872
#:7     VCN:5740        LCN:118931      Clusters:820    Lba:57691288
#:8     VCN:6560        LCN:141358      Clusters:820    Lba:57870704
#:9     VCN:7380        LCN:182476      Clusters:812    Lba:58199648

C:\Users\SBI\Downloads\console>

Now it show LBA but does not show Sectors ? Can you please show both StartLBA and SectorsLBA of file ?



#95 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 28 December 2021 - 03:53 PM

Do you mean the number of sectors per extent (versus clusters today) or the (lba) offset given in sectors (versus in sectors) ?

I believe what you are looking for is the previous "sectors" displayed in extents-win32 which now became "clusters" i.e the number of clusters (which is a group of sectors) per extent.

 

So how to read the below:

#:0 VCN:0 LCN:6737 Clusters:24350 Lba:55944
#:1 VCN:24350 LCN:51295 Clusters:6736 Lba:412408
#:2 VCN:31086 LCN:64767 Clusters:64512 Lba:520184

 

We have a first extent labelled 0

Its VCN starts at 0.

Its LCN (on the partition) is 6737 (unit is cluster here)

Its number of clusters is 24350 (a cluster=4096 bytes)

Its LBA (offset from start of disk) is 55944 (unit is sector here) aka 55944*512=28643328 (1B51000 in hex)

 

etc

 

Now it show LBA but does not show Sectors ? Can you please show both StartLBA and SectorsLBA of file ?


#96 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 28 December 2021 - 04:12 PM

Beware : my first check shows that i must be missing something in my fat32 lba calculation.

 

I get Lba:55944 (1B51000) but in hxd i find my file on disk at 1f51000 which is 400000 (hex) or 4194304 (decimal) delta.

Partition secreserved is probably one missing item but it does not account for it all.

 

Looking into it...

 

/Erwan

 

EDIT

 

I believe I found the delta:

-sectors reserved * 512 = 6158*512=3152896

-number of fats * secperfat * 512 = 2*1017*512=1041408

Adding these numbers give me 4194304 (decimal) or 400000 (hex)

 

So in order to get a correct FAT32 LBA I need to take these boot sectors informations into account.

Damn...

 

7AKSDjC.png



#97 devdevadev

devdevadev

    Silver Member

  • Advanced user
  • 540 posts
  •  
    India

Posted 28 December 2021 - 06:34 PM

I believe what you are looking for is the previous "sectors" displayed in extents-win32 which now became "clusters"


It will be Nice if both Sectors and Clusters show in the output so we can get StartLBA and SectorsLBA easily using .cmd batch.

Extents.exe GUI show StartLBA Offset of file and Total SectorsLBA in file. And I want to get both using .cmd batch.

#98 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 28 December 2021 - 07:53 PM

It will be Nice if both Sectors and Clusters show in the output so we can get StartLBA and SectorsLBA easily using .cmd batch.

Extents.exe GUI show StartLBA Offset of file and Total SectorsLBA in file. And I want to get both using .cmd batch.

 

Roger that.

I'll fix the FAT32 lba thingy (and ensure correct values) and will then adapt the display output.

Should be done shortly.

For now, consider the LBA value incorrect in FAT32 mode.

 

Regards,

Erwan



#99 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 28 December 2021 - 09:25 PM

LBA FAT32 now working fine.

Thus at some point I feel I will be caught back by the fat32 root directory.

RootDirSectors = ((MaxRootEntries * 32) + (BytesPerSector - 1)) / BytesPerSector.

 

I did check LBA with HxD : LBA = 64136 (decimal) * 512 = 1F51000 (hex) offset on disk.

 

Extents are reported for now in clusters (lcn, vcn, size) and LBA is reported in sectors.

 

I may report LBA in both sectors and bytes in a next update, following Devdevadev feedback to ease batching.

extents-win64.exe e:\mstsc.exe.dmp
extents 1.5 by erwan2212@gmail.com
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
PartitionNumber: 1
StartingOffset: 1048576
Filesystem :FAT32
***************************
Filename:e:\mstsc.exe.dmp
File Cluster count :95598 (391569408 bytes)
File size in bytes :391568511
File cluster first :6737
Extents count :3

#:0     VCN:24350       LCN:6737        Size:24350      Lba:64136
#:1     VCN:31086       LCN:51295       Size:6736       Lba:420600
#:2     VCN:95598       LCN:64767       Size:64512      Lba:528376

MWLgRWT.png



#100 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 30 December 2021 - 08:56 AM

Hi, Erwan.

Happy to hear from you :) , don't worry about the aging, the alternative is much worse.

 

I am not too sure to have understood the differences (if any) between the suggested calculation(s) and what was implemented.

 

Let's put aside (for the moment) the particular case of a logical volume inside Extended (we may get back to it later).

The Lba: that extents should output is (should be) the start LBA (absolute from sector 0) of the file (or its extent at hand).

The LCN: is (should be :unsure:) the Logical cluster number of the filesystem, I have no idea how you get it (also in older versions), but it has to be checked the exact way this numbering is rendered.

Now, in a primary partition/volume (FAT32) what is before the first file (please read as cluster)?
1) MBR

2) so-called "hidden sectors"

3) PBR
4) reserved sectors
5) 1st copy of FAT

6) (usually) 2nd copy of FAT

 

1+2 above are the "Sectors before" that can be read from either the partition entry or from the PBR

3+4 above are the "reserved sectors" that can be read from the PBR

5+6 are either 1x or 2x the FAT size that can be as well read from the PBR

 

Summing the above you get the LBA offset of first cluster in the filesystem, or, if you prefer, past the last copy of the FAT table anything is addressed in clusters.

 

From here the number of sectors until the LBA start of a file is its cluster number multiplied by the cluster size in sectors.

 

In FAT32 there may be a "bias" because the first cluster is cluster #2.

 

So, if the *whatever* method you use to get the cluster number is correct, you have a simple two part calculation:

a. what is before the first cluster (the #1 to #6 above)

b. the cluster number -2 multiplied by sectors in clusters

 

The root directory being (or not being) on cluster #2 and its size is irrelevant if you get the correct cluster number, even if it is confusing (and the "only" official documentation by MS, the (in)famous fatgen103.doc, is actually very confusing in some parts, and easily misinterpreted), one of the main "features" of FAT32 is that of NOT having a "fixed" root directory, UNLIKE FAT12/16 the root directory is in the data region, like everything else.

If you prefer:

1) FAT12/16 are divided in 4 main parts: Reserved sectors, FAT(s), Root Directory, Data region (clusters)

2) FAT 32 is divided in 3 main parts: Reserved sectors, FAT(s), Data region (clusters)

3) NTFS is non-divided :w00t: in 1 part only, Data region (clusters)  

 

:duff:

Wonko






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users