We cannot assign tags to files in a direct manner in a bare-POSIX environment. The technical difficulty lies in the POSIX definition which lacks storage of meta-info associated with a file. Though the non-POSIX Extended file attributes laid down the mechanism to fill in this gap, GNU userland applications or desktop environments do not utilize them in general. 1)This forces us to invent new means of storing tags. Databases are neat, but they do not integrate well with the GNU environment, they require special interfaces and tools for access and management 2). Revisiting an old friend seems to offer a good solution, though: symbolic links.

You can create a seperate directory for each tag, then create symlinks under respective directories. That is to say, if file1 should be tagged with tag1 and tag7, you should create a symlink, pointing to file1, under tag1 and tag7 directories. Advantage in doing so is, you can easiliy access to all files tagged with, say, tag3, just by going into tag3 dir. You can manage your “database” without requiring special interfaces. Access to files with a desired tag takes O(1) time. But symbolic links, by their nature, can be broken: if you move file1 to some other place, all links pointing to it are dead (as also pointed out in this more recent review).

symutils addresses this issue with symfix(1) tool. It can, somewhat automated, somewhat manually, fix the broken links. There're other handy tools for handling symlink tags in symutils 3). lssym(1) looks for common symlinks under given directories, such that you can list what tags are associated with given a file and find files tagged with given tag list, so you can ask it to “find the files tagged with tag1 and tag3”, for instance. replsym(1) helps you with move a target for symbolic links.

Alternatives

There are FUSE based solutions which are usually coupled to a database backend:

They suffer from the same problem as symlinks when the source file is moved (which can be remedied with inotify, given that tag filesystem is guaranteed to be mounted during relevant moves/deletes). And DB look-ups run at O(n log(n)) or worse (when queried for non-primary-key; though if speed ever becomes an issue, Sphinx can be used to remedy the situation).

There's an ongoing thread at Ubuntu's Brainstorm which you might want to check out.

Future

Extended file attributes. Probably. If userland programmers take a step towards it. There are no problems associated with moving/deleting the tagged file. A tool similar to locate(1) can be developed to look-up tags quickly.

Nepomuk is not a real solution —it's target audience is desktop environments, and it does not provide tools to access the database from shell. 4)

1)
Freedesktop encourages xattrs, but apparently, they were too late for the debut. KDE went for Nepomuk instead, for instance.
2)
FUSE wrappers are neat though, see below
3)
Although these tools were created with symlink tags in mind, they are generic tools
4)
as far I know
 
articles/a_way_of_tagging_files.txt · Last modified: 2018/04/22 03:31 by salviati
 
RSS - 2007 © Designed by Oscar M. Lage - Userlinux HeadQuarters