If you are writing text files from a program, watch out for using higher
level streaming C++ I/O functions (iostreams). I used to use them (back
when I first started programming under QNX) and found that any random loss
of power (happened to have very poorly supplied power to my house) could
cause extreme havoc on my partition. I’ve lost complete partitions due to
the problem. My suggestion is, if you are writing data files normally, to
use as low level access methods as possible (when reading/writing binary
data, use read/write, if doing ASCII file manipulation, try to use fopen and
f* accessor functions). This might help to prevent more corruption.
Also, a nice trick is if you are writing files and can get an estimate as to
how large the file will be, to resize the file (ltrunc) before you write.
This helps to prevent extra manipulations of the file tables while writing
to disk and can keep your data sane more often.
Other than that, doing syncs is good. If you can do an fsync() on the
particular files you have open, that might be a nice way to keep the
particular open files you are writing in sync.
And try to avoid hard powering off during a chkfsys, I haven’t personally
had any problems with it but have heard that it can cause trouble.
R B Adler
“M. Tavasti” <tavastixx@iki.fi.invalid> wrote in message
news:m2vgndha8i.fsf@akvavitix.vuovasti.com…
I’d like to know is there something else to do for preventing
filesystem from corruption. We are havingproblems with QNX filesystem
on Sandisk 48M flash. We’ve done this far:
- Filesystem won’t be full, there’s always at least 1 meg free.
- On boot image, mount is run like this (using synchronous mount)
/bin/mount -p /dev/hd1.0 /dev/hd1.0t77 / -s
- We have battery backup power, and we get at least 15 second warning
for power going down. After it:
- applications don’t write on disk
- we run ‘sync’
We can’t do shutdown on that point because we don’t know if power
returns or not. If it returns before battery getting empty, we
continue as usual.
- On boot we run 'chkfsys -uPr / ’
Still, we are getting corrupted flash. In fact, some small files are
getting empty nearly every time if they are written nearby of
reboot. And sometimes we get random corruption (plain text files have
binary carbage, etc). We have tried this on two units, and I don’t
think it’s broken hardware.
Running QNX 4.25D, using Fsys.eide for flash.
All ideas welcome, if using e-mail remove xx and .invalid from my e-mail.
–
M. Tavasti / > tavastixx@iki.fi > / +358-40-5078254
Poista sähköpostiosoitteesta molemmat x-kirjaimet
Remove x-letters from my e-mail address