Date: Tue, 2 Nov 2004 12:31:30 -0700 From: Peter Wemm <peter@wemm.org> To: freebsd-amd64@freebsd.org Cc: Stasys Smailys <ssmailys@komvista.lt> Subject: Re: ioctl() 64-bit issues Message-ID: <200411021131.30701.peter@wemm.org> In-Reply-To: <4187EB23.1060407@komvista.lt> References: <4187EB23.1060407@komvista.lt>
next in thread | previous in thread | raw e-mail | index | archive | help
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@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411021131.30701.peter>