18.6 Resources Required

Each file requires the dedication of certain system resources. When a file exists, but is not being referenced in any way, it requires:

(a)

a directory entry (16 characters in a directory file);

(b)

a disk “inode” entry (32 characters in a table stored on the disk);

(c)

zero, one or more blocks of disk storage (512 characters each).

In addition if the file is being referenced for some purpose, it requires

(d)

a core “inode” entry (32 characters in the “inode” array);

Finally if a user program has “opened” the file for reading or writing, a number of resources are required:

(e)

a “file” array entry (8 characters);

(f)

an entry in the user program’s “u.u_ofile” array (one word per file, pointing to a “file” array entry);

Mechanisms have to be set up for allocating and deallocating each of these resources in an orderly manner. The following table gives the names of the principal procedures involved:

resource

obtain

free

directory entry

namei

namei

disk “inode” entry

ialloc

ifree

disk storage block

alloc

free

core “inode” entry

iget

iput

“file” table entry

falloc

closef

“u_ofile” entry

ufalloc

close