Date: Sun, 26 Sep 1999 18:26:07 -0700 From: Mike Smith <mike@smith.net.au> To: "Juan Lorenzana" <lorenzaj@agcs.com> Cc: hackers@FreeBSD.org Subject: Re: [Fwd: Bsd Problem] Message-ID: <199909270126.SAA15450@dingo.cdrom.com> In-Reply-To: Your message of "Thu, 23 Sep 1999 21:36:29 PDT." <37EAFFCD.6F9F4B0D@agcs.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> > I was wondering if I could get help. Doug Madderom is a developer at > AGCS and has asked me to forward this to the FreeBSD newsgroup. Any > help is appreciated. Thanks. Commentary follows: > I wrote a character device driver using ioct as the method to pass data in a > structure to and from the device driver. If I do not include either a printf or > scanf in the application program that uses the driver the pointer the OS passes > to the ioctl in the driver is not set up right and the driver panics. What am I > doing wrong ? I don't think the use or non-use of printf/scanf have anything to do with the problem here. You've probably made several changes at the same time and missed the significant one. > Program that fails ( works if first line in program is a printf) The program is OK. > Device driver: > ---------------------------------------------- > /* alarmio driver for free BDS */ It's "FreeBSD". 8) > struct Ioctl_args *tmp; ... > *tmp=*(struct Ioctl_args *)arg; You never point (tmp) at anything, and the code above (which is wrong) attempts a structure copy of the structure that (arg) points to into random space. This line should read tmp = (struct Ioctl_args *)arg; Normal programming convention would have you make the assignment in the declaration of tmp: static int alarmioioctl(dev_t dev, int cmd, caddr_t arg, int flag, struct proc *p) { struct Ioctl_args *tmp = (struct Ioctl_args *)arg; Hope this helps. -- \\ The mind's the standard \\ Mike Smith \\ of the man. \\ msmith@freebsd.org \\ -- Joseph Merrick \\ msmith@cdrom.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199909270126.SAA15450>