Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When trying to manage trash can from mounted NTFS volumes, I ended up reading FreeDesktop.org's reference on it.

Poking around and doing some tests, I realized Ubuntu/Gnome does not follow the specs 100%. Here's why:

  • For non-/ partitions, it always uses <driveroot>/.Trash-<uid>, It never used <driveroot>/.Trash/<uid>, even when i created it in advance. While this works, it's annoying: if I have 15 users, I end up with 15 /.Trash-xxx folders in my drive, while the other approach would still give a single folder (with 15 sub-folders). That "pollution" in my drives is very unpleasant. And specs say "If an $topdir/.Trash directory is absent, an $topdir/.Trash-$uid directory is to be used". Well, it is present, so why does it never use it?

  • root trash does not work, at least not out of the box. Open nautilus as root and click on trash; it gives an error. Try to delete any file, it says "it can't move to trash". Ok, I know this can be fixed by creating /root/.local/share. But specs says "A “home trash” directory SHOULD be automatically created for any new user. If this directory is needed for a trashing operation but does not exist, the implementation SHOULD automatically create it, without any warnings or delays.". Why the error then? Bug?

  • Why must I change /etc/fstab entries for mounted volumes, adding options like uid and guid, if the volumes are already mounted as RW for everyone?

These are just some examples of deviation from the standard. So, the question is:

"If Ubuntu does not adhere 100% to the spec, HOW exactly does the trash work? WHERE can i find a technical reference for Ubuntu's implementation of the trash?"

By the way: if Ubuntu does happen to follow specs, please tell me what I am doing wrong, especially regarding the /.Trash-<uid> vs /.Trash/<uid> issue.

Thanks!

EDIT:

Some more info:

  • If a given fs has no support for the sticky bit (VFAT, NTFS), it probably doesn't have for permissions either (at least VFAT surely doesn't). So what prevents one user from purging / restoring other users' ./Trash-xxx ? If one can read/write his own Trash, one can do the same for the whole drive, including other's trashes, correct? Or does Gnome have some kind of "extra" protection on ./Trash-xxx folders on VFAT/NTFS fs?

  • If Linux can "emulate" file permissions on NTFS mounting by editing /fstab uid and gid options, can it also "emulate" the sticky bit? I would really prefer to use /.Trash/xxx format...

  • For the root issue: for the / partition, I can use trash as root, and it goes to /root/.local/share/Trash. But if I click on Nautilus "Trash" (as root), I get an error. Don't you? So files are correctly trashed, but I can't access it. All I can do is manually "purge" them (by deleting files on /root/.local/share/Trash), but restoring would be very tricky (opening info files and manually moving, etc.).

  • For non-/ partitions (or at least for VFAT/NTFS), I can not even use trash as root: it does not create a ./Trash-0 folder, it simply says "Cannot trash, want to permanently delete?" Why?

  • About fstab: i use it for a permanent mount for my NTFS partitions. I have several, and if not "pre-mounted" they really clutter the desktop and/or Nautilus. I'd rather have it pre-mounted, integrated in my file system, in mounts like /data , /windows/xp , /windows/vista , and so on, and leave /media and its "mount/unmount" flexibility just for truly removable drives.

So, if Ubuntu/Gnome truly follows the spec, is there any way to fix the root issues and to "emulate" the sticky bit for (at least) my fstab'ed NTFS fixed partitions?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

GNOME is using .Trash correctly as far as I understand - if you look in gio/glocalfile.c source you'd see that it does make an attempt to use the .Trash directory if it exists. Do note though that the directory has to have the correct permissions for users to be able to safely store trash files in it (and in safely here, I mean that other users won't be able to recover user's trashed files). For this GNOME requires that the .Trash directory must have the sticky bit set on it - see Trash Directories,note (1) in FreeDesktop.Org's Trash specification.

The main problem with the above approach, is that most r/w removable media you find is FAT, which doesn't support the sticky bit so the only way to handle this safely is to use a per user trash directory.

Regarding root Trash - I can't reproduce the problem you describe, it seems to work well for me.

Regarding /etc/fstab - I'm not sure what is the problem there: you should need to mess around with fstab, unless you want full control over where an external file system is mounted. Normally removable media is mounted automatically upon detection in /media for the user that is currently active, but it is then inaccessible to any other user. If you want a different setup then you should mess with the configuration file. I don't see how that relates to trash, though.

share|improve this answer
    
Thanks! You gave me LOTS of interesting info, and a few questions arose... where should i ask / reply your comments? Here in this comment or editing my original question? –  MestreLion Feb 20 '11 at 1:28
    
Ive marked yours as accepted answer... but, if possible, please reply to the new issues ive mentioned in my (edited) question. And thanks a LOT for your answer! –  MestreLion Feb 20 '11 at 2:25
add comment

A bit late this, but if anyone is interested: , I had the same problem but, on advice I downloaded Dolphin. I then ran Dolphin through sudo dolphin in terminal.

Now, right clicking on the Wastebin and selecting Empty Wastebin clears the files rather than producing an error.

This does not really relate to your question, but is simply a work around.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.