This is just an example of virtual fs in userspace using FUSE. Althought the goal is not reached, the idea is to build a different way to handle files, by tagging them and suppress the traditional directories. Howewer a big and important constraint is to maintain the compatibility with the traditionals tools (ls, mkdir,...), while giving them a different or modified expressiveness. For example we can imagine the ls listing files by intersecting or making the union (not implemented) of a list of tags. Even if VTagFS is a toy project and is not very advanced it can give some thoughts of what can be made with fuse.
- Linux kernel compiled with fuse support or loaded as module.
- fusermount and headers installed, which are included in the packages fuse-utils and libfuse2 under Debian or Ubuntu. The version 2.5.3 seems to be required.
- Last version of the fuse python binding.
- For using fuse without administrator rights, add yourself in the fuse group.
- If you want to access extended attributes, be sure to mount your partition with user_xattr.
# mount and start vtagfs' daemon like that $ ./vtagfs ./mountpoint # umount pyinotifyfs $ fusermount -u ./mountpoint
Say ./mp is the mount point of vtagfs, you can declare one or several tags like that:
- mkdir mp/tag1; where tag1 is the tag name.
- mkdir -p mp/tag2/tag3; tag2 and tag3 are simultaneously declared.
You can note that all the tags are at the same 'level', moreover, the notion of level or hierarchy is quite irrelevant in this fs implementation.
You can remove tags simply by rm them like directories:
- rm -rf mp/tag1/; will removes the tag 'tag1' and all its references in all the inodes using this tag.
- rm -rf mp/tag2/tag3; removes tag2 and tag3.
Please, be sure you don't remove a tag that is not empty, otherwise you also remove the reference to him (which is now obsolete).
First it is important to know the price to pay to have files: files are held in memory, they are never written on disk, big files can impact your memory, and umount or failures will erase your data.
When you can create a file you must specify its name and at least one tag, the followings examples are valid:
$ mkdir -p mp/tag1/tag2 $ touch mp/tag1/foo $ echo "42" > mp/tag1/tag2/bar
Once the file is created you can edit and write it by referring to its name together with 0,1 or several tags:
$ echo "24" >> test/bar $ echo "42" >> test/tag2/bar $ cat test/bar 42 24 42
For deleting a file you must provide at least one tag, then the tag is removed from this file, and if the file is not anymore associated to any tag, then it is definitively deleted.
$ rm test/tag2/bar $ ls test/tag2/bar ls: test/tag2/bar: No such file or directory $ ls -la test/tag1/bar -rw-r--r-- 1 ookoi ookoi 9 Jul 15 21:24 test/tag1/bar
You can also create symlinks, pointing on files or directories on your traditional fs, the way to create and manage symlinks are the same than for files.
vtagfs doesn't support hard links, rights management (chmod, chown).
By chaining n tags you operate an intersection of their contents, consider this example:
$ mkdir -p test/tag1/tag2 $ touch test/tag1/tag2/foo $ touch test/tag1/bar $ ls -la test/tag1/tag2/ total 0 drwxr-xr-x 2 ookoi ookoi 0 Jul 15 21:38 ./ drwxr-xr-x 2 ookoi ookoi 0 Jul 15 21:38 ../ -rw-r--r-- 1 ookoi ookoi 0 Jul 15 21:36 foo $ ls -la test/tag1/ total 1 drwxr-xr-x 2 ookoi ookoi 0 Jul 15 21:38 ./ drwxr-xr-x 2 ookoi ookoi 0 Jul 15 21:38 ../ -rw-r--r-- 1 ookoi ookoi 9 Jul 15 21:37 bar -rw-r--r-- 1 ookoi ookoi 0 Jul 15 21:36 foo