Find the answer to your Linux question:
Results 1 to 3 of 3
Hello all, To keep long story short, I am coding a character device driver(like scull), when I read from my character device driver using cat it simply waits for more ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Location
    Rajshahi || Dhaka, Bangladesh
    Posts
    11

    Modify Character Device Driver to Handle Cat


    Hello all,
    To keep long story short, I am coding a character device driver(like scull), when I read from my character device driver using cat it simply waits for more data to be fed in, doesn't quit). How can I modify the driver so that cat reads all the available data and quits. (I debugged and found out the driver opens instead of closing after each read.)
    Thanks in advance.
    Regards.

  2. #2
    Just Joined!
    Join Date
    Jul 2011
    Posts
    16
    Cat keeps reading as long as read() returns more than 0 bytes. In your driver, You give the data as long as you have data. If your driver has no data to give just return 0. When cat gets zero as return value of read() function, it exits.

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Location
    Rajshahi || Dhaka, Bangladesh
    Posts
    11
    Umm I realized the problem, thanx anyway. Its just I wanted to implement blocking read, and when device buffer is empty, I sent it to wait queue, that was the problem, and it turned out its exactly the behavior needed for our assignment.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •