Code Confidencebuild 3.0.0.201402161939

Chapter 21. Initialization and Mounting

As mentioned previously, mount table entries can be sourced from two places. Static entries may be defined by using the MTAB_ENTRY() macro. Such entries will be automatically mounted on system startup. For each entry in the mount table that has a non-null name field the filesystem table is searched for a match with the fsname field. If a match is found the filesystem's mount entry is called and if successful the mount table entry marked valid and the fs field initialized. The mount() function is responsible for initializing the root field.

The size of the mount table is defined by the configuration value CYGNUM_FILEIO_MTAB_MAX. Any entries that have not been statically defined are available for use by dynamic mounts.

A filesystem may be mounted dynamically by calling mount(). This function has the following prototype:

int mount( const char *devname,
           const char *dir,
	   const char *fsname);

The devname argument identifies a device that will be used by this filesystem and will be assigned to the devname field of the mount table entry.

The dir argument is the mount point name, it will be assigned to the name field of the mount table entry.

The fsname argument is the name of the implementing filesystem, it will be assigned to the fsname entry of the mount table entry.

The process of mounting a filesystem dynamically is as follows. First a search is made of the mount table for an entry with a NULL name field to be used for the new mount point. The filesystem table is then searched for an entry whose name matches fsname. If this is successful then the mount table entry is initialized and the filesystem's mount() operation called. If this is successful, the mount table entry is marked valid and the fs field initialized.

Unmounting a filesystem is done by the umount() function. This can unmount filesystems whether they were mounted statically or dynamically.

The umount() function has the following prototype:

int umount( const char *name );

The mount table is searched for a match between the name argument and the entry name field. When a match is found the filesystem's umount() operation is called and if successful, the mount table entry is invalidated by setting its valid field false and the name field to NULL.