1748170 Members
3847 Online
108758 Solutions
New Discussion юеВ

corrupted files

 
SOLVED
Go to solution
B.Beekmans
Advisor

corrupted files

We got a lot of corrupted files. there is a file of 5MB but after 512 k there is no more text in it.If we look binary at it , the rest are all zero's.
We want to know which files are corrupted and which are not. Is there a way to determine which files have zero's after 5 KB ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning...
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor
Solution

Re: corrupted files

Hi:

By what determination do you conclude that the file is corrupted?

This sounds like a "sparse" file to me. Sparse files are common in databases,

A sparse file can easily be created by opening a file; seeking to some offset; writing some data; and closing the file.

Using tools like 'cpio' or 'cp' to copy a sparse file will expand it. That is, the empty regions will be populated with zeros.

Regards!

...JRF...
Peter Godron
Honored Contributor

Re: corrupted files

Hi,
File may have been created via prealloc. See man prealloc
Creates files filled with null.

What are the symptoms that lead you to assume the files are corrupted? Any clue in the filename as to what they may be?
Peter Nikitka
Honored Contributor

Re: corrupted files

Hi,

I really doubt, that the method you trying to use to find such files will make much sense.
But if you want to try:

dd if=$yourfile of=/tmp/tstout bs=5k skip=1
if [ -s /tmp/tstout ]
then
tr -d '\0' /tmp/tststrip
if [ -s /tmp/tststrip ]
then print $yourfile is NULLfilled
fi
fi

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Peter Godron
Honored Contributor

Re: corrupted files

Hi,
can you please update this thread or did the forum find you a suitable solution.
B.Beekmans
Advisor

Re: corrupted files

We know now what has happened:
The following command was issued:
cd /import/DNP01 ; tar cf - . | ( cd /appl/samba/shares/unmirr_prod_sts03/data/DNP01/content_storage_01/00015c61 ; tar xf - )
But since the /appl/samba shares/unmirr_prod_sts03 didn't excist , tar emptied it's buffer( 512 k) in the original directory.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning...