For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > April 2005 > bad ioctl - what's the error?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author bad ioctl - what's the error?
Stroller

2005-04-10, 3:57 am

Hi,

This is probably a really dumb question, but it's late at night & I'm
posting here because I found this posting <http://tinyurl.com/6rmlj>
really helpful when I started trying to dig into this earlier this
evening.

I'm trying to get a Conexant PCI ADSL modem running under Linux 2.6.11
- the firmware doesn't seem to be uploading to the card, and so I'm
trying to work out what's going on. A previous version of the driver
works perfectly under a 2.6.9 kernel, but I gather the driver has been
updated to accommodate some API changes > 2.6.10. Apparently this
driver works fine for a few others who have used it, but I seem to be
doing everything by the instructions, so I don't see what else to do
apart from digging into the code to work out what's happening.

The firmware loader fails with the error message "bad ioctl 400c2502,
Status=c00000b5", which I find is printed by the following code:

Status = ioctl( SocketID, CommandID, &Socketioc );
if ( Status < 0 )
{
printf( " bad ioctl %x, Status=%x\n", CommandID, Status );
return STATUS_FAILURE;
}

So the "Status=c00000b" refers directly to the return value of the
`ioctl` call, right? I'm new to this side of things, but as I
understand it `ioctl` allows the programmer to interface with &
generally talk to the hardware device. So what does c00000b mean in
this case, please? (I have a feeling it's going to mean the kernel
module is b0rked, but I'm prepared to wait & see on that).

`man ioctl` tells me that:

RETURN VALUE
Usually, on success zero is returned. A few ioctls use the
return
value as an output parameter and return a nonnegative value on
success.
On error, -1 is returned, and errno is set appropriately.
ERRORS
EBADF d is not a valid descriptor.
EFAULT argp references an inaccessible memory area.
...

So my understanding is that "c00000b" isn't a valid return value for
`ioctl`. I thought initially that "c00000b" must be hex for the errno,
but grepping errno.h has not been enlightening.

I've tried editing the code so it returns a decimal integer, i.e.:
printf( " bad ioctl %x, Status=%x, %d\n", CommandID, Status, Status
);
however the error message displayed becomes:
bad ioctl 400c2502, Status=c00000b5, -1073741643
which doesn't make any more sense to me.

If someone could help me understand this, I would be extremely
grateful,

Stroller.

loic-dev@gmx.net

2005-04-11, 4:00 pm

Hello,

> I'm trying to get a Conexant PCI ADSL modem running under Linux

2.6.11
> - the firmware doesn't seem to be uploading to the card, and so I'm
> trying to work out what's going on.


[snip]

> The firmware loader fails with the error message "bad ioctl 400c2502,
> Status=c00000b5", which I find is printed by the following code:
>
> Status = ioctl( SocketID, CommandID, &Socketioc );
> if ( Status < 0 )
> {
> printf( " bad ioctl %x, Status=%x\n", CommandID, Status );
> return STATUS_FAILURE;
> }
>
> So the "Status=c00000b" refers directly to the return value of the
> `ioctl` call, right? I'm new to this side of things, but as I
> understand it `ioctl` allows the programmer to interface with &
> generally talk to the hardware device. So what does c00000b mean in
> this case, please? (I have a feeling it's going to mean the kernel
> module is b0rked, but I'm prepared to wait & see on that).


ioctl() is meant to be a general interface for every possible device
drivers. As a result , the CommandID parameter, the Socketioc
parameters, and the value returned by ioctl() rely direly on the driver
itself.

With other words, if you get status c00000b5 for command 400c2502, you
have to read the spec of the modem driver (or alternatively, the
source) to know what it really means.


> `man ioctl` tells me that:
>
> RETURN VALUE
> Usually, on success zero is returned. A few ioctls use

the
> return
> value as an output parameter and return a nonnegative value on
> success.
> On error, -1 is returned, and errno is set appropriately.
> ERRORS
> EBADF d is not a valid descriptor.
> EFAULT argp references an inaccessible memory area.
> ...
>
> So my understanding is that "c00000b" isn't a valid return value for
> `ioctl`. I thought initially that "c00000b" must be hex for the

errno,
> but grepping errno.h has not been enlightening.


This is not quite correct. ioctl() and the resulting error codes are
only standardized for STREAMS devices. For non STREAMS devices, like
your modem, this call is unspecified. Which mean basically that it
might return whatever the driver/programmer feels like.


Hope this help,
Loic.

SM Ryan

2005-04-11, 4:00 pm

# The firmware loader fails with the error message "bad ioctl 400c2502,
# Status=c00000b5", which I find is printed by the following code:

On a 32-bit machine (int)0xc00000b5 is negative integer, Status<0. If the only
error response is -1, you have to test for that specificly, Status==-1. We don't
know if your device can return an unsigned value that looks like a negative
integer without being -1 or an error.

The error number will be assigned to errno. You can print that, perror(),
and/or strerror(errno).

--
SM Ryan http://www.rawbw.com/~wyrmwif/
No pleasure, no rapture, no exquiste sin greater than central air.
Stroller

2005-04-12, 3:58 am


SM Ryan wrote:
> # The firmware loader fails with the error message "bad ioctl

400c2502,
> # Status=c00000b5", which I find is printed by the following code:
>
> The error number will be assigned to errno. You can print that,

perror(),
> and/or strerror(errno).


Thanks very much to both of you. Unless I'm doing something wrong, I'm
losing more & more hope each day in getting this driver working ;)

Status = ioctl( SocketID, CommandID, &Socketioc );
Error = errno ;
if ( Status < 0 )
{
printf ( "Error is: " ); printf ( strerror(Error) );
printf ( "\n" );
printf( " bad ioctl %x, Status=%x, %d\n", CommandID,
Status, Status );
return STATUS_FAILURE;
}

Gives:

# /etc/Conexant/cnxadslload /etc/Conexant/
Error is: Success
bad ioctl 400c2502, Status=c00000b5, -1073741643
Last record not found - load terminating
download ARM micro code (downLoadMicroCode) failed,
NTStatus=c0000001

I posted about this error to my distro's -user list before I ended up
here, and someone there has brought another brand of modem
<http://www.sangoma.com/s518.htm> to my attention - I have to say that
their Linux support looks VERY tempting.

Stroller.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com