sabato 4 luglio 2009

FsGateway - access to Sugar Datastore

FsGateway is a Mono application that allows to mount several entities as a filesystem using mono-fuse. Now we see the sugar_datastore module.

sugar_datastore module

This module allows mounting a Sugar Datastore storage as a filesystem. This way you can access to your document created using Sugar. Tags are shown as directories in the exported filesystem. You can open a Write document by simply double-clicking on it, and Open Office will be opened.

To do this, simply run the application specifying the filesystem type (sugar_datastore), the location where your data is stored (in this case datastore_sample) and the mountpoint (in this case mountpoint/):

mono --debug fsgateway.exe sugar_datastore datastore_sample mountpoint/

Now you can use your preferred file manager such as Nautilus or Dolphin to see the content and open each object with a double-click:

Here some snapshopt:




Since the datastore is read scanning the storage directory without using the datastore internal storage capability, data is read-only. This is done by the module, changing this behavior is very easy.

Obviously, you can open a SoaS datastore using this step:

  • become root (unfortunately)
  • plug in your SoaS in the USB port
  • create a working directory (e.g.: //mkdir ~/soas_datastore//)
  • mount the home partition with loop option (e.g.: //mount -o loop /media/disk/LiveOS/home.img soas_datastore// )
  • mount the datastore stored inside it (e.s. //mono --debug fsgateway.exe sugar_datastore ~/soas_datastore/liveuser/.sugar/default/datastore mountpoint//)

Of course, you can try the "allow_other" FUSE option to allow other users to access to the datastore.

lunedì 15 giugno 2009

FsGateway: looking inside an XML file as a filesystem.

FsGateway is a Mono application that allow to mount several entity as a filesystem. To do this one mono-fuse is used. Actually when you need to start the fsgateway you need do specify the filesystem type and the mountpoint. Now will describe the use of xmlfs "module". This module allow to mount a XML file into the normal filesystem. To do this simply run the application specify filesystem type (xmlfs), an XML file (in this case ~/mono_sugar/xml/xml/xml/bin/Debug/test3.xml) and the mountpoint (in this case mountpoint/):
mono fsgateway.exe xmlfs ~/mono_sugar/xml/xml/xml/bin/Debug/test3.xml mountpoint/
Now you can use your preferred file manager like nautilus or dolphin to see the content and open each node like a file: If you run the "find" or "grep" utilities, the file name that you get contains the XPath query to access the node. For example:
find mountpoint -iname "*md5*"
give this result for the file that I specify:
mountpoint/def:metadigit/def:img[1]/def:md5 mountpoint/def:metadigit/def:img[1]/def:altimg[1]/def:md5 mountpoint/def:metadigit/def:img[1]/def:altimg[2]/def:md5 mountpoint/def:metadigit/def:img[2]/def:md5 mountpoint/def:metadigit/def:img[2]/def:altimg[1]/def:md5 mountpoint/def:metadigit/def:img[2]/def:altimg[2]/def:md5 mountpoint/def:metadigit/def:img[3]/def:md5 mountpoint/def:metadigit/def:img[3]/def:altimg[1]/def:md5 mountpoint/def:metadigit/def:img[3]/def:altimg[2]/def:md5 mountpoint/def:metadigit/def:img[4]/def:md5 mountpoint/def:metadigit/def:img[4]/def:altimg[1]/def:md5 mountpoint/def:metadigit/def:img[4]/def:altimg[2]/def:md5 mountpoint/def:metadigit/def:img[5]/def:md5 mountpoint/def:metadigit/def:img[5]/def:altimg[1]/def:md5 mountpoint/def:metadigit/def:img[5]/def:altimg[2]/def:md5 mountpoint/def:metadigit/def:img[6]/def:md5 mountpoint/def:metadigit/def:img[6]/def:altimg[1]/def:md5 mountpoint/def:metadigit/def:img[6]/def:altimg[2]/def:md5 mountpoint/def:metadigit/def:img[7]/def:md5 mountpoint/def:metadigit/def:img[7]/def:altimg[1]/def:md5 mountpoint/def:metadigit/def:img[7]/def:altimg[2]/def:md5 mountpoint/def:metadigit/def:img[8]/def:md5 mountpoint/def:metadigit/def:img[8]/def:altimg[1]/def:md5 mountpoint/def:metadigit/def:img[8]/def:altimg[2]/def:md5
The same way, if you run "grep" you get the same behavior. For example:
grep -ril piccolo mountpoint/
gives as result:
mountpoint/def:metadigit/def:bib/dc:description/text()
You can find the source code here. Note: the def prefix is automatically added by the module for the default namespace. If this prefix is already used, the module use def2, or def3 ... and so on.