Files Associated with a Process

We mentioned in Section 1.5 that each process has its own current working directory and its own root directory. These are just two examples of data that must be maintained by the kernel to represent the interactions between a process and a filesystem. A whole data structure of type fs_struct is used for that purpose (see Table 12-6) and each process descriptor has an fs field that points to the process fs_struct structure.

Table 12-6. The fields of the fs struct structure

Type

Field

Description

atomic t

count

Number of processes sharing this table

rwlock t

lock

Read/write spin lock for the table fields

int

umask

Bit mask used when opening the file to set the file permissions

struct dentry *

root

Dentry of the root directory

struct dentry *

pwd

Dentry of the current working directory

struct dentry *

altroot

Dentry of the emulated root directory (always null for the 80 x 86 architecture)

struct vfsmount *

rootmnt

Mounted filesystem object of the root directory

struct vfsmount *

pwdmnt

Mounted filesystem object of the current working directory

struct vfsmount *

altrootmnt

Mounted filesystem object of the emulated root directory (always null for the 80 x 86 architecture)

A second table, whose address is contained in the files field of the process descriptor, specifies which files are currently opened by the process. It is a files_struct structure whose fields are illustrated in Table 12-7.

Continue reading here: Description

Was this article helpful?

0 0