linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PROBLEM: ioctl (HDIO_GETGEO) on partition
@ 2008-10-30 10:02 Sarangi_Santosh
  2008-11-01 13:40 ` Mark Lord
  0 siblings, 1 reply; 3+ messages in thread
From: Sarangi_Santosh @ 2008-10-30 10:02 UTC (permalink / raw)
  To: linux-kernel

Hi,
I am into a problem where the ioctl (HDIO_GETGEO) if failing on a device
partition(ex: /dev/emcpowerg1), which is working fine for full device (
ex: /dev/emcpowerg).
Basically I am trying to get start offset of the device partition
(hd_geometry.start).
The host information where I am seeing the above problem is as follows:

Linux ampersandmex01 2.6.18-53.el5PAE #1 SMP Wed Oct 10 16:48:18 EDT
2007 i686 i686 i386 GNU/Linux 

Red Hat Enterprise Linux Server release 5.1 (Tikanga)


Can anyone suggest if there is any patch available, so that the problem
can be resolved ?
If the patch is not available, then is there any other way, I can get
the above information without using  the ioctl (HDIO_GETGEO) ?

I am pasting the code snip set below for your reference.

Thanks,
-Santosh

<code snip>
  int                  fd;
  int                  sts;
  struct hd_geometry   hd_geometry_rec;
  unsigned int                offset;

  
  if ((fd = open(p_ppdevname, O_RDONLY | O_NONBLOCK)) < 0)
    {
        return OS_SYSTEM_CALL_FAILED;
    }
  if ((sts = ioctl(fd, HDIO_GETGEO, &hd_geometry_rec)) < 0) ------->
ioctl((HDIO_GETGEO)  is failing for device partition (/dev/emcpowerg1)
    {
      close(fd);
      return OS_SYSTEM_CALL_FAILED;
    }
  offset = (unsigned int) hd_geometry_rec.start;
.
.
.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PROBLEM: ioctl (HDIO_GETGEO) on partition
  2008-10-30 10:02 PROBLEM: ioctl (HDIO_GETGEO) on partition Sarangi_Santosh
@ 2008-11-01 13:40 ` Mark Lord
  2008-11-01 13:43   ` Mark Lord
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Lord @ 2008-11-01 13:40 UTC (permalink / raw)
  To: Sarangi_Santosh; +Cc: linux-kernel

Sarangi_Santosh@emc.com wrote:
> Hi,
> I am into a problem where the ioctl (HDIO_GETGEO) if failing on a device
> partition(ex: /dev/emcpowerg1), which is working fine for full device (
> ex: /dev/emcpowerg).
> Basically I am trying to get start offset of the device partition
> (hd_geometry.start).
> The host information where I am seeing the above problem is as follows:
> 
> Linux ampersandmex01 2.6.18-53.el5PAE #1 SMP Wed Oct 10 16:48:18 EDT
> 2007 i686 i686 i386 GNU/Linux 
> 
> Red Hat Enterprise Linux Server release 5.1 (Tikanga)
> 
> 
> Can anyone suggest if there is any patch available, so that the problem
> can be resolved ?
> If the patch is not available, then is there any other way, I can get
> the above information without using  the ioctl (HDIO_GETGEO) ?
> 
> I am pasting the code snip set below for your reference.
> 
> Thanks,
> -Santosh
> 
> <code snip>
>   int                  fd;
>   int                  sts;
>   struct hd_geometry   hd_geometry_rec;
>   unsigned int                offset;
> 
>   
>   if ((fd = open(p_ppdevname, O_RDONLY | O_NONBLOCK)) < 0)
>     {
>         return OS_SYSTEM_CALL_FAILED;
>     }
>   if ((sts = ioctl(fd, HDIO_GETGEO, &hd_geometry_rec)) < 0) ------->
> ioctl((HDIO_GETGEO)  is failing for device partition (/dev/emcpowerg1)
>     {
>       close(fd);
>       return OS_SYSTEM_CALL_FAILED;
>     }
>   offset = (unsigned int) hd_geometry_rec.start;
..

The code should try HDIO_GETGEO_BIG before falling back to HDIO_GETGEO.
But neither will work for LARGE drives (>= 2TB) on 32-bit systems,
so the code really should try sysfs for this info before using the ioctls.

Sample code to do this correctly is in the geom.c file of recent hdparm
source code packages from sourceforge.

Cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PROBLEM: ioctl (HDIO_GETGEO) on partition
  2008-11-01 13:40 ` Mark Lord
@ 2008-11-01 13:43   ` Mark Lord
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Lord @ 2008-11-01 13:43 UTC (permalink / raw)
  To: Sarangi_Santosh; +Cc: linux-kernel

Mark Lord wrote:
> Sarangi_Santosh@emc.com wrote:
..
>>   if ((sts = ioctl(fd, HDIO_GETGEO, &hd_geometry_rec)) < 0) ------->
>> ioctl((HDIO_GETGEO)  is failing for device partition (/dev/emcpowerg1)
>>     {
>>       close(fd);
>>       return OS_SYSTEM_CALL_FAILED;
>>     }
..

And while we're at it, that code above REALLY wants
a perror(p_ppdevname) call just before the close(fd) line.
That way, when it fails, you'll find out *why* it fails,
making bugs like this much easier to figure out.

.. 
> The code should try HDIO_GETGEO_BIG before falling back to HDIO_GETGEO.
> But neither will work for LARGE drives (>= 2TB) on 32-bit systems,
> so the code really should try sysfs for this info before using the ioctls.
> 
> Sample code to do this correctly is in the geom.c file of recent hdparm
> source code packages from sourceforge.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-01 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-30 10:02 PROBLEM: ioctl (HDIO_GETGEO) on partition Sarangi_Santosh
2008-11-01 13:40 ` Mark Lord
2008-11-01 13:43   ` Mark Lord

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).