Test for hdio.c

Eugene Syromiatnikov esyr at redhat.com
Wed Mar 25 02:13:36 UTC 2020


On Tue, Mar 24, 2020 at 10:49:49PM +0530, Bran S wrote:
> Hi guys,
> 
> I am writing a test for hdio.c.
> To do so I am calling ioctl as:
> `ioctl(fd, HDIO_GETGEO, &geom);`.
> 
> Here geom is the geometry struct, and fd is the file descriptor.
> Now the problem I am facing is: what should be the file descriptor ?

It is usually -1, to avoid side effects.  There are several exceptions,
like btrfs test and ioctl_termios, but these are pretty specific (fist
one requires root and an environment setup to run; second is, well,
VT ioctl).

> What file or device should the file descriptor refer to ?
> If we are talking about the harddrive then should it refer to /dev/sda ?

IIRC, HDIO_* are for ATA interface devices, /dev/hd*.

Note that it is possible that almost any device file is absent, as
testing environments tend (and should) to be pretty diverse.



More information about the Strace-devel mailing list