Never too picky !
I never had thought of doing that actually : clever ...
Naaah, you perfectly know how both are needed, you only forgot to describe that .
Just for the record and for the casual onlooker, a partition table entry (LBA part) has two fields:
1) Sectors Before (or Start LBA)
2) Size in sectors (or Num LBA)
As a matter of fact, nothing prohibits from putting in #2 a completely "wrong" number, as long as it is smaller or at the most equal to the number of sectors remaining from the Start LBA to the end sector of the device (never tried with a larger number, though).
I.e., in the case of those RMPREPUSB/EASY2BOOT sticks one could in theory get only the offset, and put as extents the difference between it and the sum of the two fields in first partition entry.
Actually my (personal) issue is that I cannot put a meaning on this "sectors" thingie.
What is it?
A physical sector offset? does not look like it it.
A partition sector offset? neither.
The number of sectors of this file? neither.
If I could put a description behind it, then i could probably understand the formula.
Let's take this output:
C:\>myfragmenter.exe -i C:\appoggio\Alcor\LoadDriver.exe
MyFragmenter v1.2, 2008 J.C. Kessels
Commandline argument '-i' accepted.
Processing: C:\appoggio\Alcor\LoadDriver.exe
Fragment list:
Extent 1: Lcn=32014747, Vcn=0, NextVcn=5
5 clusters, 1 fragments.
Finished, 1 files processed.
Lcn is (absolute) Logical (volume) cluster number.
A cluster number being a structure of the volume is absolute within the volume but not absolute with regards to the disk.
You multiply that number by cluster size and you have the relative LBA (from start of the volume).
To it you add the sectors before (or offset to the start of the volume) and you obtain the actual absolute LBA (from the beginning of disk), as seen for NTFS, where everything is a cluster, and the very first sector of the volume belongs to cluster 0, and/or adding the other items before cluster 0 for other filesystems.
Vcn is (relative to the file) Virtual cluster number.
For a contiguous file it is always (obviously) 0.
NextVcn is (relative to the file) Next Virtual cluster number, in practice it is (in case on non-contiguous files) the offset to where the next part of the file is, in case of a contiguous file, there is no such next part (you may think of it as first following cluster that is NOT part of the contiguous file), hence:
NextVcn-Vcn=number of clusters used by file, 5-0=5, same as in the line:
5 clusters, 1 fragments
which you then multiply by the number of sectors per cluster to obtain file size in sectors, in the batch I only parse the line:
Extent 1: Lcn=32014747, Vcn=0, NextVcn=5
because it is easier/faster:
FOR /F "tokens=2,4,6,8,9 delims=:=, " %%A IN ('myfragmenter.exe -i "%File%" ^|
FIND "="') DO (
but I could well do something like:
FOR /F "tokens=1 delims= " %%A IN ('myfragmenter.exe -i "%File%" ^|
FIND "clusters,"') DO (
and get the 5 (number of clusters) already calculated by the program but that would mean running the program twice, or I could use FIND "," and check if a token equals "clusters", everyone would probably use a slightly different approach.
There may be obviously a mis-match between the actual file size (as seen in the filesystem) in bytes and the result of the above, once multiplied by sector size, just like if you have a 1025 byte file (size seen in the filesystem) it will occupy three sectors but really-really a whole cluster, 8*512=4096 bytes "on disk", but the calculation is correct for the LBA entry.
Wonko