> 
> 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.                   \\  [EMAIL PROTECTED]
\\    -- Joseph Merrick           \\  [EMAIL PROTECTED]




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to