Hacking Gmail

(Grace) #1

Chapter 16 — Using GmailFS 219


For the catcommand to access the file, the operating system first opens the file


that represents the directory. Within that is a list of filenames, each with a corre-
sponding name of an inode file.


The operating system then opens the inode, and it is the inode that tells the oper-
ating system where the file is on the disk and all of the rest of the data about the


file. This metadatais quite extensive and contains the following information:


The location of the item’s contents on the disk

What the item is (such as a file, directory, or symbolic link)

The item’s size, in bytes

The time the file’s inode was last modified — also called the ctime

The time the file’s contents were last modified — the mtime

The time the file was last accessed — the atime

The number of names the file has — hard links

The file’s owner — the UID

The file’s group — the GID

The file’s permissions — for example, 755

Because the file’s contents, the inode, and the pointer to it from the directory are
all separate, a single file can have many names. Each name is called a hard link.


Deleting a link doesn’t delete the file or the inode itself, only the link, as there may
be other links pointing to the inode, and hence to the contents of the file. When a


file has no hard links left, the kernel will count it as deleted and allow it to be
physically overwritten on the disk itself.


So, so far you have two types of file that dictate the file system: the directory file,
which matches the filename to the inode, and the inode, which matches lots of


metadata to a block of data on the disk.


The third part of the file system, then, is the physical block on the disk. For most


file systems, this is indeed a physical address, but as different types of storage have
different ways of addressing their own bits (pun intended), this section, too, can


be abstracted away into a file.


So, you have the directory pointing to the inode, the inode pointing to the data-


block, and the datablock pointing to the actual data — and then, as shown in
Figure 16-2, the data pointing to world domination. Excellent.

Free download pdf