Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

Section 4.14 File Systems 113

4.14 File Systems


To appreciate the concept of links to a file, we need a conceptual understanding of the
structure of the UNIX file system. Understanding the difference between an i-node and
adirectory entry that points to an i-node is also useful.
Various implementations of the UNIX file system areinuse today.Solaris, for
example, supports several types of disk file systems: the traditional BSD-derived UNIX
file system (calledUFS), a file system (calledPCFS) to read and write DOS-formatted
diskettes, and a file system (called HSFS) to read CD file systems. We saw one
difference between file system types in Figure2.20. UFSis based on the Berkeley fast
file system, which we describe in this section.

Each file system type has its own characteristic features — and some of these features can be
confusing. For example, most UNIX file systems support case-sensitive filenames. Thus, if
you create one file namedfile.txtand another namedfile.TXT,then two distinct files are
created. On Mac OS X, however,theHFSfile system is case-preserving with case-insensitive
comparisons. Thus, if you createfile.txt,when you try to createfile.TXT,you will
overwritefile.txt.However,only the name used when the file was created is stored in the
file system (the case-preserving aspect). In fact, any permutation of uppercase and lowercase
letters in the sequencef,i,l,e,.,t,x,twill match when searching for the file (the case-
insensitive comparison aspect). As a consequence, besidesfile.txtandfile.TXT,wecan
access the file with the namesFile.txt,fILE.tXt,andFiLe.TxT.

We can think of a disk drive being divided into one or morepartitions. Each
partition can contain a file system, as shown in Figure4.13. The i-nodes arefixed-length
entries that contain most of the information about a file.

disk drive partition partition partition


file system cylinder group 0 cylinder group 1 ... cylinder groupn

super
block
copy

cg
info

i-node
map

block
bitmap i-nodes data blocks

i-node i-node ... i-node

boot block(s)
super block

Figure 4.13 Disk drive, partitions, and a file system
Free download pdf