File in use and resource fork
I had to remove a complicated file from an external hard drive. When I tried to delete it via Finder / Trash, it said, unable to remove, file in use. Nevertheless it was possible to unmount the volume without errors, which means none of the current processes actually used that file.
No big deal I thought, let's just force delete it. And use the superuser command just in case it's an access rights problem:
$ sudo rm -f /Volumes/sams186/App.dmg
But this time it did not help: unable to remove. So I found that the resource fork could prevent files from being deleted. The resource fork is a file system structure which allows the system to store additional information to a file that does not belong to the file itself, but isn't a file system attribute either.
Open parenthesis:
File system attributes are properties of a file such as file name, block address, file size, etc. The number of file system attributes available and the constraints who apply vary from one file system format to another, which means HFS+ does not store exactly the same information as FAT32 or EXT3.
In the long listing of a directory, the existence of a resource fork is indicated with an @ after the access rights:
$ ls -al /Volumes/sams186/
-rw-r--r--@ 1 damian damian 224395264 16 Nov 2006 App.dmg
To show more information about the resource forks in the folder listing, use the @ parameter:
$ ls -al@ /Volumes/sams186/
-rw-r--r--@ 1 damian damian 224395264 16 Nov 2006 App.dmg
com.apple.FinderInfo 32
To display the content of a resource fork:
$ xattr -l /Volumes/sams186/App.dmg
And finally, to delete a part of a resource fork:
$ xattr -d "com.apple.FinderInfo" /Volumes/sams186/App.dmg
Having removed that FinderInfo resource fork, the file could be removed without any problems.




Comments
Ist immer wieder schön, etwas persönliches von dir zu lesen!
Posted by: David :: 1.12.09 15:20