The World Is a libferris Filesystem
Listing 1. A Long Listing of a Directory with Explicit Metadata
$ fls -l \ --show-ea=size-human-readable,width,height,name 4.5k 48 46 emacs.png 1.9k 48 48 gnome-warning.png 3.2k 48 48 gnome-xterm.png 2.5k 48 48 gtkvim.png
Listing 2. Asking libferris itself to determine which EAs are of interest for the current directory and producing an XML document as output.
$ fls -0 --xml <ferrisls> <ferrisls url="file:///tmp/lj" name="lj" > <context size-human-readable="4.5k" protection-ls="-rw-r-----" mtime-display="05 Dec 4 23:39" name="emacs.png" width="48" height="46" /> ... </ferrisls> </ferrisls>
As mentioned previously, if you are sorting a directory on an EA that does not provide a complete ordering, you can chain together sorting predicates. For example, in Listing 3, I have sorted the output based on the numeric EA height and then used a version string sort on the name EA. A version sort is similar to the ls(1) -v option, which in Listing 3 has placed foo20.png after foo3.png. Such sorting is very useful when sorting by file type or MIME major type followed by name.
Listing 3. Sorting Your Output
$ fls --show-ea=width,height,size,name \ --ferris-sort='(:#:height)(:V:name)' 48 48 1968 gnome-warning.png 48 48 3253 gnome-xterm.png 48 48 2550 gtkvim.png 48 46 4589 emacs.png 48 46 4589 foo3.png 48 46 4589 foo20.png
The two concepts of files forming a tree and files having key-value pairs attached to them are similar to the structure of XML. With libferris, you can poke inside XML documents as though they were just another filesystem. For example, see Listing 4.
Listing 4. Initial Exploration of XML as a Filesystem
$ cat example.xml <root> <file1 size="200" /> <file2 interesting="yes" /> <file3>filesystems rock </file3> </root> $ fls -0 ./example.xml/root file1 file2 file3 $ fls -d --show-ea=name,interesting \ ./example.xml/root/file2 file2 yes $ fcat example.xml/root/file3 filesystems rock
By interacting with your filesystem, you can cause updates on the underlying XML document as well. The ferris-redirect client exists to allow shell-like redirection into libferris files. The -T or --trunc option truncates an existing file before writing stdin into it. This is much like the >| shell option. As you can see from the interaction in Listing 5, we have changed the structure of the example.xml document significantly through filesystem interaction.
Listing 5. Changing an XML File through Its Filesystem
$ echo "VIRTUAL filesystems rock more" | \ ferris-redirect -T ./example.xml/root/file3 $ echo "a new way" | \ ferris-redirect ./example.xml/root/file4 $ ferrisrm ./example.xml/root/file2 $ ftouch ./example.xml/root/touched $ cat example.xml <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <root> <file1 size="200"/> <file3>VIRTUAL filesystems rock more </file3> <file4>a new way </file4> <touched/> </root>
As many modern word-processing documents are XML inside a compressed container, libferris allows you to drill down into the office document as though it were a filesystem. In Listing 6, I am listing a simple OpenOffice.org Writer document as a filesystem.
Listing 6. OpenOffice.org Documents Are Filesystems Too
$ fls -lh show-ea=size,name,content \ ~/sample-oo-writer.odt/content.xml/ \ office:document-content/office:body/office:text 0 office:forms 18 text:p Paragraph number 1 0 text:p-1 116 text:p-2 This is the second paragraph ... 0 text:p-3 39 text:p-4 And in summary, this is really... 0 text:p=5 0 text:sequence-decls
A Xerces-C Document Object Model (DOM) can be obtained for any libferris filesystem, just as a Xerces-C DOM can be mounted as a libferris filesystem. Creation of a DOM for a filesystem is evaluated lazily, so you can get a DOM for file:// and only the parts of the DOM that are required are ever created.
The ability to convert any libferris filesystem into a DOM allows you to apply XSLT to your filesystems easily. The example C++ code in Listing 7 applies a stylesheet to a mounted OpenOffice.org document.
|Non-Linux FOSS: libnotify, OS X Style||Jun 18, 2013|
|Containers—Not Virtual Machines—Are the Future Cloud||Jun 17, 2013|
|Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer||Jun 12, 2013|
|Weechat, Irssi's Little Brother||Jun 11, 2013|
|One Tail Just Isn't Enough||Jun 07, 2013|
|Introduction to MapReduce with Hadoop on Linux||Jun 05, 2013|
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Linux Systems Administrator
- Validate an E-Mail Address with PHP, the Right Way
- Introduction to MapReduce with Hadoop on Linux
- RSS Feeds
- New Products
- Weechat, Irssi's Little Brother
- Tech Tip: Really Simple HTTP Server with Python
- Poul-Henning Kamp: welcome to
18 min 34 sec ago
- This has already been done
19 min 34 sec ago
- Reply to comment | Linux Journal
1 hour 4 min ago
- Welcome to 1998
1 hour 53 min ago
- notifier shortcomings
2 hours 17 min ago
3 hours 53 min ago
- Android User
3 hours 55 min ago
- Reply to comment | Linux Journal
5 hours 48 min ago
8 hours 38 min ago
- This is a good post. This
13 hours 51 min ago
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?