Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 03 Sep 1997 00:40:53 -0700 (PDT)
From:      Simon Shapiro <Shimon@i-Connect.Net>
To:        freebsd-hackers@freebsd.org
Subject:   IOCTL Commands - Where is my mistake?
Message-ID:  <XFMail.970903004053.Shimon@i-Connect.Net>

next in thread | raw e-mail | index | archive | help
Hi Y'all,

It is obvious I am making a stupid mistake, but please enlighten me:

I want to pass IOCTL commands to a driver.  This is what I do:

    #define DPT_IOCTL_INTERNAL_METRICS       _IOW('D', 1, dpt_perf_t)

In a user program, I do:

    if ( (result = ioctl(fd, DPT_IOCTL_INTERNAL_METRICS, &metrics)) != 0 ) {
        (void)fprintf(stderr, "%s ERROR:  Failed to send IOCTL %x - %s\n",
                      argv[0], DPT_IOCTL_INTERNAL_METRICS,
                      strerror(errno));
        exit(2);
    }

In the driver, I do:

...

int
dpt_ioctl(dev_t dev, int cmd, caddr_t cmdarg, int flags, struct proc *p)

...

    switch (cmd) {
    case DPT_IOCTL_INTERNAL_METRICS:
         result = copyout((char *)&dpt->performance, 
                         (dpt_softc_t *)(*(caddr_t *)cmdarg),
                         sizeof(dpt_perf_t));
         return(result);

I always get:

su-2.01# dpt_dm /dev/dpt0
dpt_dm ERROR:  Failed to send IOCTL 8d3c4401 - Bad address

Now,  If I change the #define to:

    #define DPT_IOCTL_INTERNAL_METRICS      IOC_INOUT | 1

Everything will work fine!

I tried to change:

    #define DPT_IOCTL_INTERNAL_METRICS    _IOW('D', 1, dpt_perf_t)

to:

    #define DPT_IOCTL_INTERNAL_METRICS   _IOWR('D', 1, dpt_perf_t)

or even:

    #define DPT_IOCTL_INTERNAL_METRICS   _IOR('D', 1, dpt_perf_t)

Still the same.  What di I do?





---


Sincerely Yours,           (Sent on 02-Sep-97, 23:28:40 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.970903004053.Shimon>