Does it have another way to find out a range of start and end physical unit 
LBAs from file description? Like from linux that I am trying to port to 
OpenSolaris.

Following is a function call.  I can send you a source, it’s about more than 
one paper page long.
void TWL_File_LBA::get_unit_lba_range(char *file_name,
                                      ULONGLONG byte_offset,
                                      ULONGLONG record_length,
                                      ULONGLONG &range_start_unit_lba,
                                      ULONGLONG &range_end_unit_lba,
                                      ULONGLONG &run_length)

In this function it mainly does these steps:

get_volume_name(file_name, VolName, sizeof(VolName), &FsType);
GetLogicalVolumeNum(VolName, &VolGroup, &LogVol);
GetPhysVolInfo(VolGroup, LogVol, VolName, sizeof(VolName), &pe_start);
VolStartLBA += GetPartitionStartLBA(VolName);

if (-1 == ioctl(fileFD, FIGETBSZ, &FsBlockSize))
while (CurFileBlock != 0)
if (-1 == ioctl(fileFD, FIBMAP, &FsBlockAtOffset))

Then use  FsBlockSize and FsBlockAtOffset to calculate a range of unit LBAs and 
run_length

range_start_unit_lba = VolStartLBA + (CurFsBlock * (FsBlockSize >> 9));

if (CurFileBlock == EndFileBlock)
    range_end_unit_lba = VolStartLBA + (CurFsBlock * (FsBlockSize >> 9)) + 
((WrcDatFileSize % FsBlockSize) >> 9) - 1;
else
    range_end_unit_lba = VolStartLBA + ((CurFsBlock + 1) * (FsBlockSize >> 9)) 
- 1;

unit_lba = VolStartLBA + (FsBlockAtOffset * (FsBlockSize >> 9)) + ((byte_offset 
% FsBlockSize) >> 9);
nSectors = (range_end_unit_lba - unit_lba) + 1;
run_length = nSectors << 9;
if (run_length > record_length)
    run_length = record_length;


Thank you very much for your time.
Thai.
--
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to