Virtual Filesystems Are Virtual Office Documents
Listing 7. Allowing a User to Use FUSE on Fedora Core
root-bash-# usermod -a -G fuse ben
An example of setting up a little PostgreSQL table and creating a new virtual office document to allow editing this table is shown in Listing 8.
Listing 8. Setting Up a Virtual Office Document to Edit a Database Table
bash-$ psql ben=# create database lj; ben=# \c lj; You are now connected to database "lj". lj=# create table msgs lj-# ( id serial primary key, lj-# num int, msg varchar(200), lj-# foo varchar(100) ); lj=# insert into msgs values lj-# ( default, 7, 'This is msg #1', 'Foo is Bar'); lj=# insert into msgs values lj-# ( default, 12, 'Second message', 'ii tenki'); lj=# select * from msgs; id | num | msg | foo ----+-----+----------------+------------ 1 | 7 | This is msg #1 | Foo is Bar 2 | 12 | Second message | ii tenki (2 rows) \q bash-$ ferrisls pg://localhost/lj msgs bash-$ ferrisls --xml pg://localhost/lj/msgs <ferrisls> <ferrisls url="pg:///localhost/lj/msgs" name="msgs"> <context id="1" num="7" msg="This is msg #1" foo="Foo is Bar" name="1" primary-key="id" /> <context id="2" num="12" msg="Second message" foo="ii tenki" name="2" primary-key="id" /> </ferrisls> </ferrisls> bash-$ ferris-filesystem-to-xsltfs-sheets \ --plugin excel2003 --fuse msgs \ pg://localhost/lj/msgs bash-$ ferrisls -lh ~/ferrisfuse ... ben ben 129 06 Oct 21 11:56 mount-msgs.sh ... ben ben 4.0k 06 Oct 21 11:56 msgs bash-$ cd ~/ferrisfuse/ bash-$ ./mount-msgs.sh bash-$ ls -lh msgs ... 0 ben ben 3.8K Jan 1 1970 msgs.xml* bash-$ cat msgs/msgs.xml | head <?xml version="1.0" encoding="UTF-8" ... ?> <Workbook xmlns=...> <OfficeDocumentSettings xmlns=...> <Colors> ... bash-$ ooffice msgs/msgs.xml
The final command in Listing 8 opens the virtual spreadsheet document, which should look similar to Figure 1. I then changed some data in the second row and saved the file giving the result shown in Figure 2.
Looking at the PostgreSQL table after saving the virtual office document shows the updated contents—see Listing 9.
Listing 9. The Contents of the Database after Editing with OpenOffice.org
bash-$ psql lj lj=# select * from msgs; id | num | msg | foo ----+-----+----------------+----------------------- 1 | 7 | This is msg #1 | Foo is Bar 2 | 23 | Second message | The weather outside... (2 rows)
The ferris-mount-etagere-as-kml.sh script uses xsltfs:// and FUSE to set up a read/write virtual KML file. The stylesheets translate between libferris geoemblems and the KML format for place names used by Google Earth.
The stylesheets used to expose libferris emblems provide an example of translating a whole tree in libferris into a hierarchical XML document for an external application to use. The is-dir EA from the input filesystem is used to determine the type of XML element to generate in the translated filesystem, as KML files require the use of Placemark or Folder elements depending on whether children are to be found.
For testing purposes, if the LIBFERRIS_XSLTFS_DONT_UPDATE environment variable is set, libferris performs the reverse stylesheet application and logs what updates would have been done but does not actually update the input filesystem.
There are a few hints that can make setting up and adjusting custom forward and reverse stylesheets much simpler.
I use the example.xml file shown in Listing 1 again here as the input filesystem. Although in this example, I am starting with example.xml, which is an XML file, we want to see how libferris sees this input filesystem, not only the raw XML itself. For example, the contents of an elements text nodes will be available as the content attribute when libferris mounts this XML file.
To get at the libferris view of the XML, I use ferrisls with its --xml-xsltfs-debug option. I also need to recurse the example.xml file to get the whole filesystem and explicitly select any attributes that the example.xsl file will want to use.
The manual application of a forward stylesheet is shown in Listing 10.
The reverse stylesheet can be applied to the translated filesystem XML file. Once this output looks sane, non-destructive testing can be done by applying it through xsltfs:// with LIBFERRIS_XSLTFS_DONT_UPDATE set. Make sure ferris-logging-xsltfs is set to debug in the ferris-capplet-logging configuration tool to get all the information about what would have been updated.
|Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform||Jan 23, 2015|
|Designing with Linux||Jan 22, 2015|
|Wondershaper—QOS in a Pinch||Jan 21, 2015|
|Ideal Backups with zbackup||Jan 19, 2015|
|Non-Linux FOSS: Animation Made Easy||Jan 14, 2015|
|Internet of Things Blows Away CES, and it May Be Hunting for YOU Next||Jan 12, 2015|
- Designing with Linux
- Wondershaper—QOS in a Pinch
- Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform
- Ideal Backups with zbackup
- Internet of Things Blows Away CES, and it May Be Hunting for YOU Next
- Slow System? iotop Is Your Friend
- New Products
- Non-Linux FOSS: Animation Made Easy
- Hats Off to Mozilla
- diff -u: What's New in Kernel Development
Editorial Advisory Panel
Thank you to our 2014 Editorial Advisors!
- Jeff Parent
- Brad Baillio
- Nick Baronian
- Steve Case
- Chadalavada Kalyana
- Caleb Cullen
- Keir Davis
- Michael Eager
- Nick Faltys
- Dennis Frey
- Philip Jacob
- Jay Kruizenga
- Steve Marquez
- Dave McAllister
- Craig Oda
- Mike Roberts
- Chris Stark
- Patrick Swartz
- David Lynch
- Alicia Gibb
- Thomas Quinlan
- Carson McDonald
- Kristen Shoemaker
- Charnell Luchich
- James Walker
- Victor Gregorio
- Hari Boukis
- Brian Conner
- David Lane