Hi,<div>I have a linux mapper device on the host, I would like to get the start offset.</div><div>I get this by the following ioctl . Although the call succeeds but it sets the hd_geometry_rec to "0"</div><div><br>
</div><div>I checked through gdb , the ioctl call suceeds ,but sets all the field of hd_geometry to "0"</div><div><br></div><div><div>(gdb) p hd_geometry_rec</div><div>$2 = {heads = 0 '\0', sectors = 0 '\0', cylinders = 0, start = 0}</div>
</div><div><br></div><div>The device configuration</div><div>===================</div><div><div>[root@localh trunk]# uname -a</div><div>Linux localh 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux</div>
</div><div><br></div><div><div>[root@localh trunk]# fdisk -l /dev/mapper/mpath4</div><div><br></div><div>Disk /dev/mapper/mpath4: 523 MB, 523960320 bytes</div><div>255 heads, 63 sectors/track, 63 cylinders</div><div>Units = cylinders of 16065 * 512 = 8225280 bytes</div>
<div><br></div><div> Device Boot Start End Blocks Id System</div><div>/dev/mapper/mpath4p1 1 10 80293+ 83 Linux</div><div>/dev/mapper/mpath4p2 11 20 80325 83 Linux</div>
<div>/dev/mapper/mpath4p3 21 30 80325 83 Linux</div><div>/dev/mapper/mpath4p4 31 38 64260 83 Linux</div><div>[root@localh trunk]#</div></div><div><br></div><div>
The Source code</div><div>============</div><div> struct hd_geometry hd_geometry_rec;</div><div> unsigned int offset;</div><div><br></div><div> // Here p_ppdevname is /dev/mapper/mpath4p4</div><div><div> if ((fd = open(p_ppdevname, O_RDONLY | O_NONBLOCK)) < 0)</div>
<div> {</div><div> //Error</div><div> }</div></div><div><br></div><div><br></div><div> </div><div><br></div><div> if ((sts = ioctl(fd, HDIO_GETGEO, &hd_geometry_rec)) < 0)</div><div> {</div>
<div><br></div><div> // Error</div><div> }</div><div> else</div><div> {</div><div> offset = (unsigned int) hd_geometry_rec.start;</div><div> }</div><div> <br clear="all">
<br>-- <br>With best regards,<br>Santosh.<br>
</div>