Thread: How do I know whether a disk does a READ or a WRITE?

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    69

    How do I know whether a disk does a READ or a WRITE?

    There's struct request, which represents a request by the hard disk. The question is, how can I get info on whether the disk does a read or a write?

    Your help will be much appreciated!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    As far as I know, there is no struct request in the C standard library. I am going to hazard a guess as to the context that you did not provide: *moved to Linux programming forum*
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Good call, laserlight.

    The struct request defined in include/linux/blkdev.h file in the Linux kernel sources has a field unsigned int cmd_flags (line 102 or so). If (cmd_flags & REQ_WRITE) is true the request is a write request, otherwise it is a read request.

    This is documented in the comments for the enum rq_flag_bits type in the include/linux/blk_types.h file (line 140 or so) in the kernel sources.

  4. #4
    Registered User
    Join Date
    Nov 2011
    Posts
    69
    Thank you Nominal Animal, you have been most helpful!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Write the low-order 8 bits of the time to the disk file
    By kfuller002 in forum C Programming
    Replies: 2
    Last Post: 11-10-2010, 02:32 PM
  2. Direct Disk Read/Write
    By abachler in forum Networking/Device Communication
    Replies: 3
    Last Post: 10-06-2008, 09:20 PM
  3. Does MinGW Write to Disk?
    By glo in forum Tech Board
    Replies: 7
    Last Post: 07-21-2008, 03:56 PM
  4. read write from hard disk
    By bojan in forum C Programming
    Replies: 3
    Last Post: 05-17-2006, 01:15 AM
  5. Write data to a disk file
    By bnd98 in forum C++ Programming
    Replies: 11
    Last Post: 04-20-2003, 04:21 PM

Tags for this Thread