If it is necessary to create a new type of file system, file system helpers and mount helpers must be created. The following sections provide information about the implementation specifics and execution syntax of file system and mount helpers.
To enable support of multiple file system types, most file system commands do not contain the code that communicates with individual file systems. Instead, the commands collect parameters, file system names, and other information not specific to one file system type and then pass all this information to a back-end program (the helper).
The back end understands specific information about the relevant file system type and does the detail work of communicating with the file system. Back-end programs used by file system commands are known as file system and mount helpers.
To determine the appropriate file system helper for each file system type, the front-end command examines the /etc/vfs file. This file contains a line for each file system type. Each line includes a field defining the appropriate helper program.
There are two helper fields in the /etc/vfs file: one for the mount helper and one for the file system helper. The file system helper is a single executable that handles all requests for file system specifics, except for file system mounting, which is controlled by the mount helper.
fsck -fp /users
invokes the fsck command on a file system named /users . /users is a journaled file system (JFS). JFS is the default file system type.
In this example, the fsck command does several things including:
The actual invocation of the helper by the fsck command includes an indication of which operation to perform, which file system or device to perform the action on, and any options requested (fast and preen in the preceding example).
The following table lists the possible operations requested of a helper in the /usr/include/fshelp.h file:
However, the JFS file system supports only the following operations:
Operation Value Corresponding Command #define FSHOP_CHECK 1 fsck #define FSHOP_CHGSIZ 2 chfs #define FSHOP_MAKE 5 mkfs #define FSHOP_STATFS 7 df #define FSHOP_NAMEI 10 ff
The execution syntax of the file system helper is:
OpName OpKey FilsysFileDescriptor PipeFileDescriptor Modeflags DebugLevel OpFlags
Field | Definition |
---|---|
OpName | Specifies the arg0 parameter when the program invokes the helper. The value of the OpName field appears in a list of processes (see the ps command). |
OpKey | Corresponds to the available helper operations. Thus, if the OpKey value is 1, the fsck (file system check) operation is being requested. |
FilsysFileDescriptor | Indicates the file descriptor on which the file system has been opened by the program. |
PipeFileDescriptor | Indicates the file descriptor of the pipe (see the pipe subroutine) that is open between the original program and the helper program. This channel allows the helper to communicate with the front-end program.
For example, the helper sends an indication of its success or failure through the pipe, which can affect further front-end processing. Also, if the debug level is high enough, the helper can have additional information to send to the original program. |
Modeflags | Provides an indication of how the helper is being invoked and can affect the behavior of the helper, especially in regard to error reporting. Mode flags are defined in the /usr/include/fshelp.h file:
For example, the FSHMOD_INTERACT flag indicates whether the command is being run interactively (determined by testing the isatty subroutine on the standard input). Not every operation uses all (or any) of these modes. |
DebugLevel | Determines the amount of debugging information required: the higher the debugging level, the more detailed the information returned. |
OpFlags | Includes the actual device (or devices) on which the operation is to be performed and any other options specified by the front end. |
The actual invocation of the file system helper for fsck -fp /user is:
execl("/etc/helpers/v3fshelpers","fshop_check","1","3","5","ifp", "0","devices=/dev/lv02,fast,preen,mounted")
Another example of how file system helpers are invoked uses the mkfs command. To create a JFS file system on the existing logical volume named /dev/lv02, enter:
mkfs /junk
which creates a mount point. If you want to create a file system and only know the device you wish to mount it to, enter:
mkfs /dev/lv02
Either way, the following file system helper is invoked:
execl ("/etc/helpers/v3fshelpers", "fshop_make", "5", "3", "5", "-ip", "0", "name=/junk,label=/junk,dev=/dev/lv02")
The operation requested is now FSHOP_MAKE. The mode is interactive and perror . The OpFlags string includes both the mount point and the device.
The mount command is a front-end program that uses a helper to communicate with specific file systems. Helper programs for the mount and umount (or unmount) commands are called mount helpers.
Like other file system-specific commands, the mount command collects the parameters and options given at the command line and interprets that information within the context of the file system configuration information found in the /etc/filesystems file. Using the information in the /etc/filesystems file, the command invokes the appropriate mount helper for the type of file system involved. For example, if the user enters:
mount /test
the mount command checks the /etc/filesystems file for the stanza that describes the /test file system. From the /etc/filesystems file, the mount command determines that the /test file system is a remote NFS mount from the node named host1 . The mount command also notes any options associated with the mount.
An example /etc/filesystems file stanza is:
/test: dev = /export vfs = nfs nodename = host1 options = ro,fg,hard,intr
The file system type (nfs in our example) determines which mount helper to invoke. The command compares the file system type to the first fields in the /etc/vfs file. The field that matches will have the mount helper as its third field.
The following is a sample of the execution syntax of the mount helper:
/etc/helpers/nfsmnthelp M 0 host1 /export /test ro,fg,hard,intr
Both the mount and unmount commands have six parameters. The first four parameters are the same for both commands:
The remaining parameters for the mount command are:
The remaining parameters for the unmount command are:
The File Systems Overview for System Management explains types and characteristics of file systems.
Files, Directories, and File Systems for Programmers gives an overiew and orientation to the journaled file system (JFS).
Logical Volume Programming Overview.
Understanding Generic I-nodes (G-nodes).
The chfs command, df command, ff command, fsck command, mkfs command, mount command, ps command, umount or unmount command.
The vfs file, filesystems file.
The vmount or mount subroutine, umount or uvmount subroutine.