![]() |
Hello everyone,
A strange thing happened lately on one of my external drives: 4 files seam to have been corrupted and cannot be deleted. (which is quite bothersome since they take up lots of space.) When trying to erase them thru the Finder I get the following error message: "The operation cannot be completed because the item HardBox is in use" where "HardBox" is the name of my external USB drive. So I decided to remove them myself using the Terminal. after entering the usual "cd" command to go to the right directory containing the four files, I try to execute a simple "ls"; the names appear normally as you can see: Code:
xApple:/Volumes/HardBox/toKill/bene xapple$ lsCode:
xApple:/Volumes/HardBox/toKill/bene xapple$ ls -alCode:
xApple:/Volumes/HardBox/toKill/Bene xapple$ rm Greystoke.la.l\303\251gende.de.Tarzan_FR.cd1_prescrit-par-les-refractaires.avi I thought of a operating a "Repair Disk" with the "Disk Utility" but it says the "HardBox" disk needs no repairs. Thanks in advance for any suggestions you could bring ! |
I would guess that the problems you are seeing is due to strange characters in the filenames. The mere presence of accented characters shouldn't be a problem - so I suspect some other weirdness.
1) Could you please email me the smallest one of the files (if you can get it into a mail message as an attachment). I'm interested in this problem - it has come up a few times before and I've never had a sample to investigate myself. You can sent it to: macdev@hayne.net Please use "MACOSXHINTS strange file" as the subject of the message so I will be sure to notice it among the junk mail messages in case it gets classified as junk. 2) Can you rename these files in Finder? If you can, do so and then try deleting them again. 3) You could try removing the whole containing folder: cd /Volumes/HardBox/toKill rm -rf bene If neither of these methods work, let us know and we can suggest other ways. |
1) No, I cannot rename the files in the Finder. When I try to do so, the Finder retorks
"The operation could not be completed. An unexpected error occurred (error code -43)" 2) I would be glad to eMail you one of the files, but I'm scared it would be a bit cumbersom on your mailbox... the smallest of the files weighs 698 [MB]... but you're weird characters theory is intresting... 3) If I try to operate a "rm" on the directory containing the four files I get the following: Code:
xApples-PowerBook:/Volumes/HardBox/toKill xapple$ rm -rf bene |
Oh yeah and I tried doing everything I mentioned as "sudo rm" or "sudo ls -al" and it gives the exact same results...
|
Quote:
sudo rm -rf bene |
Here's two Perl scripts that might help in giving us more diagnostic info.
The first one ("listdir") lists the files like 'ls -l' does. I suspect that it will fail on the files due to strange characters - but it's worth trying. The second one ("listdir_diag") tries to avoid any operation that might fail due to strange characters - and it prints out the numerical values (in hexadecimal and octal) of the characters in the filenames. For info on running scripts, see this Unix FAQ. Code:
#!/usr/bin/perlCode:
#!/usr/bin/perl |
Hmm... these scripts don't seam to be working as they should...
Maybe it's just me that isn't running them properly. I created 2 files containing the scripts exactly as they appear in your last post. The two plain text files have their respective script names, i.e. "listdir" and "listdir_diag" and are located in a sub folder of my home directory. I chmod'ed them for them to be executable by me and also created a "test" folder (containing 3 small files) to test the scripts on. But when I try to execute them I get the following: Code:
xApples-PowerBook:~/scripts xapple$ ls -alWhat am I doing wrong ? |
The "bad interpreter" error message probably indicates that the line-endings in the script file are not correct. They need to be Unix-style line endings. This is covered in the FAQ that I linked to above. (see the section on end-of-line characters)
What editor did you use to create the script files? [edit] I see that there is indeed a bug in the scripts - they don't properly handle the case where you supply the directory as a command-line argument. I only tried them without any arguments - when they list the contents of the current directory. [/edit] |
I have now edited the above post to correct the error in the 'listdir' script so it now works correctly if you give it a command-line argument (the directory to be listed).
The other script ('listdir_diag') didn't suffer from this bug. (I.e. the problems you had with 'listdir_diag' must have been solely due to the line-endings.) |
Ok, I got the scripts working !
(this time I used BBEdit to save them instead of the generic TextEdit) And your prognostics were right: the first one fails and the second one seams to do what it is made to. Here are the results: Code:
xApples-PowerBook:/Volumes/HardBox/toKill xapple$ ls |
Quote:
One possibility is to try using the utility 'convmv' to change the encoding of these filenames. You can download this utility (which is a Perl script) from here: http://j3e.de/linux/convmv/man/ Then you'll have to fool around with it a bit to see if you can convert the filenames. Basic usage is like this: convmv -f name_of_existing_encoding -t name_of_desired_encoding name_of_file where name_of_existing_encoding is one of the encodings that you can list by running the command: convmv --list Which one should be used is something I don't know. It seems that the troublesome characters are (in hexadecimal) "c3 a9" which I've seen listed as being the Unicode for é For the name_of_desired_encoding, I think you want to use UTF-8 or UTF-16 By default, the convmv command just tells you what it is planning to do - it doesn't actually do it. To get it to actually change the filename, you need to add the "--notest" option: convmv -f name_of_existing_encoding -t name_of_desired_encoding --notest name_of_file ----------------------------- Another way of deleting these files that would avoid the above "fooling around" might be to turn on file sharing (in Sharing preferences) and then access your drive from some other (non-OS X) machine. You might be able to delete the files from that other machine. |
I'm getting a serious filesystem corruption vibe here.
Boot off the install disk, use the Tools (?) menu to get to Disk Utility, and verify and / or repair the disk. Or you could boot into single-user mode and run fsck, if you're comfortable with that sort of thing. It does the same as Disk Utility. Cheers, b& |
I managed to successfully create the file Greystoke.la.légende.de.Tarzan_FR.cd1_prescrit-par-les-refractaires.avi by using the hex values you provided to form a string for the C function fopen(const char*, const char*);
Bad news is, I had no problem deleting the file with that name. Deleted it from the command line using "rm Gre*", and from finder using Cmd-delete. They aren't "Suggested" filename characters, but they don't appear to corrupt the file system on there own. |
Quote:
In my experiments (I've been trying with Perl), I can create a string with those hex values, and then create a file (using sysopen(FILE, $filename, O_CREAT)) but then when I check what the filename of the newly created file is (e.g. with the 'listdir_diag' script above), I find that different characters are in the filename. I.e. it seems that the file creation routines do some translation of the characters in the filename. |
I'll check
_______ ok, you are correct stdio changed Code:
0x6c, 0xc3, 0xa9, 0x67,Code:
0x6c, 0x65, 0xcc, 0x81, 0x67Code:
File#2 name: Greystoke.la.le??gende.de.Tarzan_FR.cd1_prescrit-par-les-refractaires.avi |
Quote:
For future reference, here's the C program I wrote for testing this sort of thing: Code:
// This C program attempts to create a file with a specified name. |
Had this happen before after I had cancelled an rsync in mid-sync. These errors are likely due to "bad text encoding" errors on the files themselves. Telltale signs that you're experiencing this condition ( other than the exact symptoms that you are currently seeing ) are clicking on the file and having it dissappear, then reappear sometime later on, seemingly at random. Also, you will sometimes be able to move them but usually will not be able to delete them through any method whatsoever ( ie - GUI trash, rm, srm, etc, etc ). Root can sometimes rename them in order to rid the filename of pesky invisible characters, but the issue will still persist and the file will still be reported as in use, even after a reboot or if you boot to another System folder or an entirely different CPU.
Solution: Run Disk Warrior. It will report the damaged text encodings and likely be able to fix them. You should then be able to delete them anyway you wish after that. |
Well, in the end, to solve the problem what I did is ask a friend to shortly borrow some of his HD's free space, while I reformatted my external USB drive.
The files are now gone for good ^^. I didn't own "Disk Warrior"... and the price is expensive.. "fsck" didn't do anything, in fact didn't even report a problem. and the "convmv" util just seamed as much of a hassle as temporally storing the data elsewhere while the disk was erased... But I thank you all for your attempts at helping me... the mac community is always so firendly ! I just suppose strange file corruptions will always happen... |
was 'rm -rf directoryname' not tried? i know everyone wanted to dissect it, but that would have worked, right?
|
Quote:
The strange characters in the filename apparently cause confusion at the BSD level. |
that's exactly why i asked. he said he tried rm and sudo rm. naturally an rm won't work on a dir with files.
he skipped right over rm -rf. according to what he says he did. i ask since this has worked for me before. |
Quote:
I presume that (according to post #4) he then did 'sudo rm -rf bene' This is not the only time we've encountered a problem like this with files that are undeletable due to strange characters. See: http://forums.macosxhints.com/showthread.php?t=15814 |
oh, how did i miss that.
thanks |
I'm still getting filesystem corruption vibes. Really, really strong ones, too....
Cheers, b& |
You might get that impression given some of the "symptoms", but the earlier posts confirm the presence of "odd" encodings in the filenames, and this issue has come up a number of times on all sorts of Mac forums. A few years ago, a simple solution was to boot into System 9 (which seems to be able to handle more odd encodings than OS X) and delete the file from there. More recent Macs can't boot in System 9 so obviously that is no longer an option, though I wonder if attaching it to an older Mac via target disk mode would work... Someone mentioned using Disk Warrior to fix encodings - I haven't heard whether that works or not, but it would be a shame if money had to be spent to fix a problem that can be caused by just transferring a file to your computer...
|
Quote:
If you have an inode that can't be deleted or renamed, the filesystem IS corrupt. Period. Now, it may be that, in this particular case, the reason the files can't be deleted or renamed is because their filenames have illegal characters not permitted by the HFS+ spec--an archetypal form of corruption. It may also be that the filesystem is theoretically okay, that the spec permits such filenames, but that all the standard libraries and utilities are broken in such a way that they can't deal with all valid filenames--in which case, one is left to wonder how the file got created with that name in the first place. Either way, it doesn't matter. What does matter is that this is a very, very serious bug. Filesystem corruption of any kind is serious bad mojo. If this is something that can be reproduced, especially if it can be done without doing anything particularly unusual, it's also a major security hole. Frankly, it sounds like it'd be near-trivial to fill up a filesystem by creating a super-large file that can't be deleted. Or by creating millions of small files that can't be deleted, either. That in and of itself constitutes a really, really nasty DOS attack that'd be difficult or impossible to protect against in many real-world situations. (Yeah, quotas, partitioning, etc.) Considering how poorly OS X and other systems that allocate swap dynamically handle low disk situations...this is about as bad as they come. Has anybody bothered to tell Apple about this? Is anybody from Apple listening? What's the best way to report security problems to Apple? Cheers, b& |
Quote:
See: http://developer.apple.com/technotes/tn/tn1150.html http://www.usenix.org/publications/l.../sanchez_html/ Quote:
Quote:
Quote:
It would be nice to report this bug but I think first what we need is a way to reproduce it. That is why I was trying to find out exactly what characters were in those troublesome filenames and why I tried (without success) to create a file of that name on my system. Security issues, like other bugs, can be reported via Apple's bug report form: http://developer.apple.com/bugreporter/bugrptform.html |
Quote:
Quote:
Hmmm...here's a thought. You (or somebody else?) mentioned that you could use OS 9 to delete the files? Perhaps they're easier to create in OS 9. If so, here's a suggestion: Create a file on a computer running OS 9. If possible, get that file onto a read-write disk image that has the problem. If not, get the file onto a cheap thumb disk. Confirm that OS X has the problem. Then, send get the disk image or the thumb disk to Apple, along with an appropriate write-up. That should get their attention. I'd offer to help...but I don't have anything that'll boot OS 9 anymore. Of course, it could still just be ye olde fashioned filesystem corruption.... Cheers, b& PS Perhaps manually creating a UU-encoded file would be an easy way to trigger this? Editing a tarball or a zip file? b& |
| All times are GMT -5. The time now is 05:28 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.