LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ioctl know if write caching enabled on disks (https://www.linuxquestions.org/questions/linux-newbie-8/ioctl-know-if-write-caching-enabled-on-disks-797312/)

mannu 03-23-2010 10:22 AM

ioctl know if write caching enabled on disks
 
Hello,
Is there an ioctl that tells whether write caching is enabled
on disk? I believe there are many kinds of disks like scsi, ide, sata, pata etc,. And I need to know if whether write caching is enabled for all kinds of disks possible?

On reading scsi document, I found mode sense page code 8 gives whether
write cache is enabled or not. If so we can use SG_IO ioctl. Is my
assumption correct?

For IDE, sata, pata and other possible non scsi disks, how we can get
whether write caching is enabled or not?

Thanks and Regards,
Mannu.

troop 03-23-2010 10:31 AM

man hdparm
man sdparm

mannu 03-23-2010 10:52 PM

Hello Troop,
Thank you for help.
I wanted to know if write caching enabled from C program
instead of forking sdparm and hdparm.

For scsi disks, scsi standard mentions mode sense page 0x8 gives
whether caching enabled or not. Hence I can use SG_IO ioctl for this.

For IDE, sata, pata and other possible non scsi disks, while googling
around, I found HDIO_GET_WCACHE ioctl in "/usr/include/linux/hdreg.h".
Can I use this ioctl? Is it public and defined on all linuses?
Is there any manual page for this?

The following link provides
http://www.kernel.org/doc/Documentation/ioctl/hdio.txt
documentation of above ioctls?

Thanks and Regards,
Mannu.


All times are GMT -5. The time now is 04:42 AM.