AmigaOS3.5 (113/193)

From:Roger H�gensen
Date:16 Aug 2000 at 19:34:51
Subject:Have you filled the HD 101%, and then it's become useless? (repost, can someone comment on this please?)

Do not fear! I have a solution.

Some time ago I was making a diskblanker/eraser.
The purpose was to fill all free space with 0's.
A nice way to prevent file recovery with disksalv etc.
(to remove/erase sensitive information so well that salvage tools
will be unable to recover it)

But for some odd reason my HD became 101% full.
Apparently the bitmap of the FFS partition needed to be extended
to reference the VERY large file.
But since the file ocupied all space the FFS was unable
to update the HD.

I was unable to delete the file as well since the FFS reported
not enough space to save bitmap (or something like that)
DiskSalv reported some of the same and was thus unable to fix the HD.
In other words a format seemed the only solution.

But wait, for some odd reason I looked in one of my dev manuals
and found a OS function called SetFileSize()
I found that this might be my last chance,
I coded a tiny utility in my RAM disk :)
(i was able to read from my lost hd, phew :/

Then I ran the util, it set the size of the file to 0.
And this worked strangely enough.
Then a reboot and a short validation later
I could write to my HD again.
Now I could delete that pesky file (which was size 0 now :)

Is this a bug in the FFS filesystem?
Why did this happen?
Has this been fixed in the latest versions (OS3.5 and BB1) ?
Can it be fixed/prevented by adding a check?
SFS seem to check this.

I would have thought that setting the size to 0 would bring
a unable to write bitmap error but it didn't.
Does SetFileSize() change the size in the actual fileheader block?
Rather that change the HD bitmap?

If someone can answer I would be very happy.
Anyway, all this HD talk on this list remonded me of this incident,
so I dug up my old source code and you can see it below.
Feel free to make your own utils folks (those who can code in here).
If anyone want I could email you a copy of the util.
Send me a private email, or nag me about putting it on Aminet...

This code is old (from 97, sorry it's so simple :)
It's very easy to use the function tough, it's in dos.library

*** Start AmigaE Source Code ***
OPT OSVERSION=37

PROC main() HANDLE
DEF fh=NIL

IF StrCmp(arg,'',ALL)
WriteF('Usage: emptyfile <filename>\n')
ELSE
IF (fh:=Open(arg,OLDFILE))
IF SetFileSize(fh,0,-1)<>-1
WriteF('Filesize changed!\n')
ELSE
WriteF('Unable to change filesize!\n')
ENDIF
Close(fh)
fh:=NIL
ELSE
WriteF('Unable to open file!\n')
ENDIF
ENDIF
EXCEPT
IF fh THEN Close(fh)
WriteF('Unknown Error!\n')
ENDPROC
*** End AmigaE Source Code ***

A good tip!

NEVER fill up you HD more than 99% (for various reasons)

Kind regards,
Roger H�gensen...



3:35 The wise shall inherit glory: but shame shall be the promotion of fools.


Roger "Rescator" H�gensen - Software/Music/Graphics/Media
Mail: "rescator@emsai.net" ----- WEB: "www.emsai.net"
Msi Software * Info, software and more ----- Sith Academy * The Sith
Member of DTA (DataType Association) & ADN (Amiga Developer Network)