ioctl - Minix

This is a discussion on ioctl - Minix ; hi! in a new "driver" i'm processing ioctl requests like in do_ioctl from tty.c: ------------------ PRIVATE int dm_ioctl(dp, m_ptr, safe) struct driver *dp; /* pointer to driver structure */ message *m_ptr; /* pointer to control message */ int safe; { ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: ioctl

  1. ioctl

    hi!

    in a new "driver" i'm processing ioctl requests like in do_ioctl from
    tty.c:
    ------------------
    PRIVATE int dm_ioctl(dp, m_ptr, safe)
    struct driver *dp; /* pointer to driver structure */
    message *m_ptr; /* pointer to control message */
    int safe;
    {
    struct dm_ioctl *dmi;
    int r;
    int size = sizeof(struct dm_ioctl);

    /* printf("dmtest: ioctl request 0x%x\n", m_ptr->REQUEST); */

    switch (m_ptr->REQUEST) {
    case DM_CREATE:

    .....
    }

    ....
    }
    --------------------

    this works fine.
    the problem is, I can't access the submitted struct.

    I tried:
    ----------------
    r = sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes) m_ptr-
    >ADDRESS, 0,

    (vir_bytes) &dmi, (vir_bytes) size, D);
    ----------------
    but this always results in

    EFAULT /* bad address */

    on client side I do:
    ----
    struct dm_ioctl *dmi = something_valid;
    ioctl(fd, command, dmi);
    ----

    what i'm doing wrong here?

    m.

  2. Re: ioctl

    i'm still trying to access the ioctl request parameter.
    from the message i have:

    m_source = 1 (vfs)
    IO_ENDPT = m_source
    ADDRESS = 8 (increments on driver restart)
    IO_GRANT = ADDRESS
    POSITION = 122345 (changes on each ioctl)
    COUNT = -237632658745 (changes on driver restart)

    r = sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->IO_GRANT, 0,
    (vir_bytes) &dmi, (vir_bytes) size, D);

    r = sys_vircopy( m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS,
    SELF, D, (vir_bytes) &dmi, (vir_bytes) size);

    both keep on failing with -14 (EFAULT) bad address


    "memory", "tty" do it that way. is there something in between client
    and driver? what's the meaning of the character for encoding the ioctl
    requests?
    i used:

    #define DM_CREATE _IORW('X', 1, struct dm_ioctl)





  3. Re: ioctl

    shame on me.

    solution:
    i fuzzed up the datastructure on driver-side:
    it has to be:

    struct dm_ioctl dmi;

    instead of a pointer to that struct.

    now everything works like a charm.

+ Reply to Thread