Files are one of the most important abstractions an OS can provide. The concept of files predates computers, so they are a metaphor that everyone understands. Programmers do not want to think about disk drives, tapes, or any other media. They want to think about the data they are processing, and they think of the data as a collection. In a computer, that collection is abstracted as a file. Programs need data to work on. File Systems Basics Introduction We usually keep that data on secondary storage devices because primary storage is too expensive to keep all the data we need to have access to. Today, these devices are almost always rotating magnetic disk drives.
As application programmers, we do not want to be concerned with the details of the operation of the thousands of different types of disk drives. We want to think of our data in terms of some abstraction. Usually, we think in terms of a file as being a collection of records or bytes. File Systems Basics Introduction, Therefore, a major function of most OSs is to provide for the abstraction of a file on secondary storage. The contents of a file are usually meaningful only to application programs. By this, we mean that the OS is typically not aware of the internal structure of the files.
There are a few exceptions such as the executable (binary) programs that the OS can run and the object modules that are used to make those files. Such files have structures that are defined by the OS itself. These structures will be known by all the linker or loader utilities that are used to make the executable files and the compilers and assemblers that are used to produce the object modules from source program files
File systems generally have layered designs, with each layer providing services to the layer above it. Every OS has a unique partitioning of the functions across these layers. Two things are true about all file systems: the top layer API is an abstraction of the concept of files and the bottom layer interacts directly with the hardware. File Systems Basics IntroductionAs an example, a Linux file system organization with the layers flowing left to right. We discuss file abstraction in this chapter and the bottom layers.
Before a program can use a file, it will need to find the file. The OS will need to provide some sort of an index to the files that the program can search. We call these indexes directories. (Since more people have begun using computers who are not very knowledgeable about them, another term has also come into common usage for these structures: folders.) Directories will obviously have to store the name of the file, but they will also store other data about the file as well. In some OS there may be a lot of other information kept for each file, but in others, there is only a small amount. This other information about a file that is not part of the file data is referred to as file metadata. Some of these other items are almost universal and others are found only rarely.
Clearly, we will need a disk address that points to the start of the file data. Usually, we also want to know the size of the file. shows some examples of metadata we might find for a file on various operating systems. File Systems Basics IntroductionIt is unlikely that any OS will have all of these items in some cases they represent different ways of accomplishing the same ends. In some OS this information is stored in the directory entry for a file. In other OSs it is stored in a separate structure most notably, UNIX-derivative OSs use an external table called an inode.