ioctl() 64-bit issues
Peter Wemm
peter at wemm.org
Tue Nov 2 11:31:33 PST 2004
On Tuesday 02 November 2004 12:16 pm, Stasys Smailys wrote:
> Hi, all!
>
> I think we have a problem here at least it seems so to me. Trying to
> fix an infinite loop that occured in usr.sbin/burncd/burncd.c when I
> have tried to blank cdrw disc I discovered that
>
> sys/ioccom.h
> [...]
> int ioctl(int, unsigned long, ...);
> [...]
>
> usr.sbin/burncd/burncd.c
> [...]
> int blank, pct, last = 0;
> [...]
> if (ioctl(fd, CDRIOCGETPROGRESS, &pct) == -1)
>
> err(EX_IOERR,"ioctl(CDRIOGETPROGRESS)");
> [...]
>
> always returns a zero value in pct (pct == 0). By the way there is a
> typo in burncd.c: the second CDRIOCGETPROGRESS misses 'C'. Anyway it
> is not essential. As you can see by yourself in that case the loop
> becomes infinite. Further investigations showed me that pct gets
> overwritten every ioctl's call by CDRIOCGETPROGRESS constant's upper
> bytes. At the moment of ioctl's call the CDRIOCGETPROGRESS value is
> 0x0000004004636f.
If you have a look at cdrio.h:
#define CDRIOCGETPROGRESS _IOR('c', 111, int)
And the implementation is:
case CDRIOCGETPROGRESS:
error = acd_get_progress(cdp, (int *)addr);
Compare to:
#define CDRIOCSENDCUE _IOW('c', 104, struct cdr_cuesheet)
burncd.c: if (ioctl(fd, CDRIOCSENDCUE, &sheet) < 0)
atapi-cd.c:
case CDRIOCSENDCUE:
error = acd_send_cue(cdp, (struct cdr_cuesheet *)addr);
Our ioctl wrapper code causes a copyin/copyout according to the IOR/IOW
encoding. It should be an int, and is being accessed as though it were
an int within the kernel.
If I had to guess, I'm wondering if you got this info from gdb.. I
don't trust gdb for this stuff yet. I'd be more concerned if it was
printf("pct %d\n", pct) that told you this. If you want to try
something, set pct to 12345 right before the ioctl call in case you're
looking at random contents or something.
I don't know what is wrong though. But my initial thought is that it
isn't this...
--
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5
More information about the freebsd-amd64
mailing list