220 Part III — Conquering Gmail
Representing All of This in E-Mail
But lest you forget, you’re trying to represent all of this data in e-mail messages
and not a proper storage medium. The translation between the two is the job of
FUSE and GmailFS. Together, they handle the requests from the operating sys-
tem for the data inside the directories, the inodes, and then the datablocks, and
feed it back in the manner that the kernel expects.
To do that, GmailFS needs to store all of these different types of data within the
framework that e-mail provides. Think on this: What is the framework available
for data within e-mail?
It’s easy, actually. You can use the subject line, the body of the message itself, and
any number of attachments. That is how GmailFS works.
The Actual Data in Action
GmailFS just uses the subject line and the attachments. Nothing is held in the
message body itself. There are three types of messages used.
Directory and file entry messages:These hold the parent path and name of
a file or a directory. The subject of these messages has a reference to the file’s
or directory’s inode.
Inode messages:The subject line of these messages holds the information
found in an inode.
Datablock messages:These messages hold the file’s data in attachments.
The subject of the messages holding these structures contains a reference to
the file’s inode as well as the current block number. Because Gmail has a size
limit of 5MB for attachments, this message may contain more than one
attachment.
So, now when you run the cat supersecretpasswords.txtcommand on a file
within the GmailFS system, FUSE and the GmailFS script first use Libgmail to
request the corresponding file entry message. This command points them to the
inode message, which then points them to the datablock message and the data
you need.
As previously mentioned in a sidebar, each of the messages’ subject lines contains
the file system name. This allows you to use more than one file system off the
same Gmail account, and also provides some security. The security comes from
the way that GmailFS adds data to itself — by sending mail to itself. Without the
hard-to-guess file system name, it would be possible for an outside party to send
messages to the account that added data to the file system.