Date: Thu, 04 Sep 1997 01:29:00 -0700 (PDT) From: Simon Shapiro <Shimon@i-Connect.Net> To: Stephen McKay <syssgm@dtir.qld.gov.au> Cc: freebsd-hackers@freebsd.org, Mike Smith <mike@smith.net.au> Subject: Re: IOCTL Commands - Where is my mistake? Message-ID: <XFMail.970904012900.Shimon@i-Connect.Net> In-Reply-To: <199709040519.PAA09446@ogre.dtir.qld.gov.au>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Stephen McKay; On 04-Sep-97 you wrote: > >From this, I expect that Simon wants to use his ioctl like: > > dpt_perf_t metrics; > > if ( (result = ioctl(fd, DPT_IOCTL_INTERNAL_METRICS, &metrics)) != 0 > ) { > ... > } > > Define his ioctl like: > > #define DPT_IOCTL_INTERNAL_METRICS _IOR('D', 1, dpt_perf_t) > > And put this in his driver: > > int > dpt_ioctl(dev_t dev, int cmd, caddr_t cmdarg, int flags, struct proc > *p) > > ... > > switch (cmd) { > case DPT_IOCTL_INTERNAL_METRICS: > *(dpt_perf_t *)cmdarg = dpt->performance; > break; This is essentially how it is now. > The reason that: > > #define DPT_IOCTL_INTERNAL_METRICS IOC_INOUT | 1 > > works with his current driver code is sheer luck, as Mike says. The > size > is encoded as 0, and that falls through some odd code in ioctl() and > hands > you a cmdarg that points to the pointer that was passed in from user > mode. > A zero size should be an error in my books. In SystemV, it would not have been luck, it would have been the way it should be. One could argue that BSD's was of encoding three separate arguments into one is not exactly a mark of engineering ellegance. Unix code dating back to the dark ages of PDP-11 worked flawlessly that way. I have a sneaking suspicion that throwing out all these encodings and just passing a streight, plain argument actually works, by design. David? --- Sincerely Yours, (Sent on 04-Sep-97, 01:11:04 by XF-Mail) Simon Shapiro Atlas Telecom Senior Architect 14355 SW Allen Blvd., Suite 130 Beaverton OR 97005 Shimon@i-Connect.Net Voice: 503.643.5559, Emergency: 503.799.2313
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.970904012900.Shimon>