flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
vivik 02 Sep 2018, 17:48
I learned that I can read or write to a disk or partition with the CreateFile function. I want to try to store information on hdd without a file system, or with a primitive self-written one. (Just to make data recovery a bit simpler).
Question is, how can I detect if there is a hdd failure? According to this https://www.pcreview.co.uk/threads/fat32-crc-implementation.3920429/ , there is no crc or similar in the file system, it's implemented in the driver somehow. |
|||
![]() |
|
DimonSoft 03 Sep 2018, 03:42
As for the API, your read function might return failure code at some point. Say, your ReadFile might return 0 and GetLastError at that moment will return something like ERROR_CRC, maybe some other code like ERROR_SECTOR_NOT_FOUND depending on the driver logic and the nature of the error. Not that you can do much in such cases.
|
|||
![]() |
|
revolution 03 Sep 2018, 08:19
Another thing is that an HDD will usually only detect errors during reads. While there are some errors that write can detect, it is less common.
So if you want to have a good assurance that your data was written correctly you can read it back again after writing. But be sure to bypass any caching to make sure you are reading from the actual surface. It is also good practice to read the entire surface occasionally to allow the ECC codes to detect any transient errors and rewrite affected sectors. This helps to keep the data in a readable state for longer before unrecoverable errors start to accumulate. |
|||
![]() |
|
DimonSoft 03 Sep 2018, 08:50
As a side note, some bad hard drives might lie about actual writes to the surface: see Raymond’s post plus comments. In the years of crazy marketing it’s quite possible for a hard drive to read back written data from cache instead of the surface for performance reasons.
|
|||
![]() |
|
revolution 04 Sep 2018, 07:52
And all of the above comments apply equally to SSDs (and those cheaper versions of SSDs known commonly as thumb drives), just as much as HDDs.
|
|||
![]() |
|
Furs 04 Sep 2018, 15:48
If you want recovery ability, you should use something like what par2cmdline does.
https://github.com/Parchive/par2cmdline I don't really understand it, seems magic to me. But it works. |
|||
![]() |
|
revolution 04 Sep 2018, 21:32
Furs wrote: If you want recovery ability, you should use something like what par2cmdline does. ![]() |
|||
![]() |
|
Furs 04 Sep 2018, 23:08
revolution wrote:
For example for every 8192 bytes block, store an extra 512-byte sector of redundancy. This gives you 6.25% redundancy which is plenty to repair it. Even backups suffer from silent bit rot and the like ![]() |
|||
![]() |
|
revolution 04 Sep 2018, 23:43
Furs wrote: For example for every 8192 bytes block, store an extra 512-byte sector of redundancy. This gives you 6.25% redundancy which is plenty to repair it. |
|||
![]() |
|
DimonSoft 05 Sep 2018, 03:50
Furs wrote: I was thinking he could use the same algorithm and do it on chunks of sectors for his filesystem (Reed-Solomon coding or whatever it is called, voodoo to me...). <SillyPun>And they’d better be Reed-Right-Solomon codes, not Reed-only.</SillyPun> |
|||
![]() |
|
vivik 06 Sep 2018, 06:33
revolution wrote: Bad data is repaired and rewritten to spare locations. Sounds like a file system feature. This wouldn't work with raw linear disk access? Is that NTFS or FAT? I'd prefer data to be written on the same place it was, because read is faster if it's sequential. Also, what is SMART? Is that a program, or an additional information hdd provides? Also, is there a ReadFile alternative that can notify me when the file is 50% read? Let's say I read 500mb of memory in a single read, but I want to notify another thread when the first 1mb and 10mb are loaded, so that I can at least check the header while the rest of the file is being read. I'm not sure if 3 separate ReadFile calls are as effective as just 1. The async io is probably what I'm looking for. |
|||
![]() |
|
revolution 06 Sep 2018, 07:22
vivik wrote:
The SMART data is maintained by the drive. There are programs you can use to view the data from the drive. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.