can I read if select(fds+1,&fdr,&fdw,&fde,0) indicates fdr is ready? - Linux

This is a discussion on can I read if select(fds+1,&fdr,&fdw,&fde,0) indicates fdr is ready? - Linux ; hi all, I have a file_operations defined as static struct file_operations = { ..ioctl = myioctl, ..open = myopen, ..release = myrelease, ..poll = mypoll } my question is: if the user process opened the device, and after that, select(devfds+1,&fdr,&fdw,&fde,0); ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: can I read if select(fds+1,&fdr,&fdw,&fde,0) indicates fdr is ready?

  1. can I read if select(fds+1,&fdr,&fdw,&fde,0) indicates fdr is ready?

    hi all,

    I have a file_operations defined as
    static struct file_operations =
    {
    ..ioctl = myioctl,
    ..open = myopen,
    ..release = myrelease,
    ..poll = mypoll
    }

    my question is:
    if the user process opened the device,
    and after that, select(devfds+1,&fdr,&fdw,&fde,0);

    if the call indicates the device is readable,


    how do I read the content? i tried with read(devfds,buf,1023),but it
    doesn't work.

    do I need to provide .read in file_operations?

    thanks.


  2. Re: can I read if select(fds+1,&fdr,&fdw,&fde,0) indicates fdr is ready?

    baumann.Pan@gmail.com wrote:
    > I have a file_operations defined as
    > static struct file_operations =
    > {
    > .ioctl = myioctl,
    > .open = myopen,
    > .release = myrelease,
    > .poll = mypoll
    > }
    >
    > my question is:
    > if the user process opened the device,
    > and after that, select(devfds+1,&fdr,&fdw,&fde,0);
    >
    > if the call indicates the device is readable,


    > how do I read the content? i tried with read(devfds,buf,1023),but it
    > doesn't work.
    >
    > do I need to provide .read in file_operations?


    Aren't you writing a device driver? From where do you expect the data
    to come if you don't provide a .read function?

    GH


+ Reply to Thread