Quote:
Originally Posted by
fpmurphy
Just attempting to read a disk sector is completely different than attempting to write a disk sector following by attempting to read the same disk sector. That is why disk vendors have what are typically called low level utilities for bad disk sector scanning and the like.
yep. you are right. For (IDE) PATA / SATA (t13.org) disks there are the ATA / ATAPI standards which specifies how to query the device directly and SCSI has a loads of standards (t10.org) for interfacing with the drives. The ATA part can be easily coded in DOS / FreeDOS with Assembly / C counterparts.
Win32 support is available too for direct querying / interfacing of the devices (with DDK/SDK apis) and device ioctl calls. There are multiple utilities from various HDD vendors which either falls in either of the above two categories (DOS or WINDOWS).
I would like to know if Linux has anything like that? If I call libata calls directly in my program would it allow me to talk to the drive directly? At least for the (IDE) PATA / SATA drives?
Though Linux is programmer friendly, I feel not much control is given to the programmer (well, it also relates to the security feature!
and unlike windows, where there are many security exploits / overflows when the kernel address space is hacked from user space leading to privilege escalations, and loads of other issues, not to mention BSOD!
).
I don't know if I am going into a vicious circle of kernel hacking / Linux abuse mode, but I just don't feel some things are right with Linux!
I certainly mean no offense with my above words and for the great minds here. The above words are purely because of my frustration in trying to get the program to work partially at least if not completely.
Now for update:
I have tried posix_fadvise, but the read / write calls are locking up on the bad sectors as said by you.
I have removed the O_DIRECT and using O_WRONLY mode with posix_fadvise on the handle with POSIX_FADV_DONTNEED flag for the entire device starting from sector 0 to (last sector * 512). Is that the right option to be used?
Is there any timeout option that can be set on the Read / Write operations to say to the program / kernel to move on to the next sector / block based on the timeout (time consumed for the current sector)?
I tried with the FDSET , but i believe it is only for socket descriptors and not for file handles. (So dumb of myself!
)
Thanks for the replies.