Like Tree1Likes
  • 1 Post By Nominal Animal

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

This is a discussion on How do I know whether a disk does a READ or a WRITE? within the Linux Programming forums, part of the Platform Specific Boards category; There's struct request , which represents a request by the hard disk. The question is, how can I get info ...

  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
    21,635
    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*
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    838
    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.
    Xpl0ReRChR likes this.

  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, 01: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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21