Showing posts with label garbagecan. Show all posts
Showing posts with label garbagecan. Show all posts

Thursday, July 23, 2009

Taking Out The Trash Operating System

It is finally time to talk about one of the most hated design decisions (among many worthy candidates) of the Unix (and friends) operating system: irrevocable file deletion. You see, when you delete a file using, say, the rm command, it decides to simply delete all references to the file from the filesystem and mark the space as free. This means that, as far as Unix is concerned, the file is gone forever!

Modern operating systems, such as Tenex, have included a 'garbage can', so when you 'delete' a file, it goes into the garbage can, so if you accidentally deleted a file you need, you can go in there and get it back. Files are only permanently deleted if the user explicitly 'empties' the garbage can or the system needs more memory (at least this is how it works on Windows).

In a (mostly futile) attempt to be more user friendly, the GNOME and KDE devs looked at the trashcans every OTHER operating system used and decided to come up with their own half-assed implementation. Eventually, in an amazing display of cooperation, they even decided to standardize on the same directory, and people say Linux devs can't cooperate! Of course, since this functionality is not built-in to the operating system but is instead a matchsticks-and-glue implementation that rides on the Desktop environment, it has some problems.

First, it only works with programs that explicitly support it. Programs like rm or any GUI tool that is just a wrapper over shell tools (i.e. most of them) will still delete the files as usual. So, sometimes you can retrieve your important file, and sometimes you can't.

Second, since the trashcan is just a regular directory, it can quickly fill up, and if the user does not manually empty it regularly, the hard drive fills up as well. Just like an extremely lazy person, Linux doesn't take out the trash even if the whole house is filled with shit!

While writing my last article, I came upon an error when I quit Avidemux; it read something like "Unable to create Avidemux log. Filesystem is full." Leaving aside the fact that it was creating a log while it was exiting, this was worrisome. Well, I had been copying a lot of stuff onto the hard drive a few days ago, but I had deleted most of it. I then decided to open my garbage can and empty the trash. Lo and behold, 3 GBs of space opened up instantly!

Well, class, what have we learned today? First, not having a two-step deletion process can cause tens of millions of dollars of damage. Second, not integrating the trashcan leaves the user unsure if he can recover his files if he accidentally deletes them. Third, not monitoring the pseudo-trashcan means one can run out of space very quickly.

Class dismissed!