[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] unlinks cause disk corruption?



A friend and I were getting zillions of bounced mail responses from a set
of mailing lists, resulting in hundreds of "MIME file" Email enclosures
(under Claris Emailer).  I wrote a  script to go through the "Downloads"
folder and delete them.

I had been clearing things out regularly and only had dozens of such files
remaining; my friend had not and had accumulated 3143 (!) mail files.  He
had been unable to open his Downloads folder for several weeks.

I ran the script several times for testing purposes on my machine, removing
about 25-30 files each time, putting them back, rinse, repeat.  I had no
problems.  We then moved the script to my friend's machine and deleted the
3143 files.

Shortly thereafter he rebooted his system and it wouldn't come up. He
finally booted off of a CD-ROM and ran Norton Utilities and it listed a
bunch of the deleted files as "lost" and restored them along with a pile of
messed up B-Tree node errors, etc.

Another friend suggested his system may have been marginal before the
deletion process, but we have no way to check this.

The essential section of the script is below (I'll be happy to mail the
whole thing to anyone who asks).  It seemed simple enough, but maybe there
is something about the MacOS filesystem that I don't understand.  If I did
something wrong, what was it? (I don't want to repeat it!).

Thanks -

        # $working=<name of directory>
        opendir(INDIR, "$working") || die "Oops, canot open $working!\n";
        @namelist = readdir(INDIR);  # get the list of files in the directory
        chdir("$working");

        foreach $name (@namelist) {
                if ("$name" =~ /^MIME file$/ ||
                    "$name" =~ /^MIME file\.[0-9]+$/) {
                        unlink("$name");
                }
        }
        closedir(INDIR);



Vicki Brown     vlb@cfcl.com   http://www.cfcl.com/cfcl/vlb
 P.O. Box 1269  San Bruno  CA  94066
 Ooit'n Normaal Mens Ontmoet?  En... Beviel't?
 (Ever met a normal person?  So... did you like it?)