From owner-freebsd-hackers Sun Sep 26 18:33:34 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from dingo.cdrom.com (castles530.castles.com [208.214.165.94]) by hub.freebsd.org (Postfix) with ESMTP id E4B2615382 for ; Sun, 26 Sep 1999 18:33:31 -0700 (PDT) (envelope-from mike@dingo.cdrom.com) Received: from dingo.cdrom.com (localhost [127.0.0.1]) by dingo.cdrom.com (8.9.3/8.8.8) with ESMTP id SAA15450; Sun, 26 Sep 1999 18:26:07 -0700 (PDT) (envelope-from mike@dingo.cdrom.com) Message-Id: <199909270126.SAA15450@dingo.cdrom.com> X-Mailer: exmh version 2.0.2 2/24/98 To: "Juan Lorenzana" Cc: hackers@FreeBSD.org Subject: Re: [Fwd: Bsd Problem] In-reply-to: Your message of "Thu, 23 Sep 1999 21:36:29 PDT." <37EAFFCD.6F9F4B0D@agcs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 26 Sep 1999 18:26:07 -0700 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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