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
|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.
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:
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:
In this example:
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:
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:
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:
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:
|operation||Indicates operation requested of the helper. Values are either M (mount operation), Q (query operation), or U (unmount operation). The query operation is obsolete.|
|debuglevel||Gives the numeric parameter for the -D flag. Neither the mount nor the unmount commands support the -D flag, so the value is 0.|
|nodename||Names the node for a remote mount or a null string for local mounts. The mount or unmount commands do not invoke a mount helper if the nodename parameter is null.|
|object||Names the local or remote device, directory, or file that is being mounted or unmounted. Not all file systems support all combinations. For example, most remote file systems do not support device mounts, while most local file systems do not support anything else.|
The remaining parameters for the mount command are:
|mount point||Names the local directory or file where the object is to be mounted.|
|options||Lists any file system-specific options, separated by commas. Information for this parameter comes from the options field of the relevant stanza in the /etc/filesystems file or from the -o Options flag on the command line (mount -o Options). The mount command also recognizes the -r (read-only) flag and converts it to the string ro in this field.|
The remaining parameters for the unmount command are:
|vfsNumber||Gives the unique number that identifies the mount being undone. The unique number is returned by the vmount call and can be retrieved by calling the mntctl or stat subroutine. For the mount helper, this parameter is used as the first parameter to the uvmount subroutine call that actually does the unmount.|
|flag||Gives the value of the second parameter to the uvmount subroutine. The value is 1 if the unmount operation is forced using the -f flag (umount -f). Otherwise, the value is 0. Not all file systems support forced unmounts.|
File Systems Overview for System Management
Files, Directories, and File Systems for Programmers
Virtual File System Overview
Logical Volume Programming Overview
Understanding Generic I-nodes (G-nodes)
chfs command, df command, ff command, fsck command, mkfs command, mount command, ps command, umount or unmount command
vfs file, filesystems file
vmount or mount subroutine, umount or uvmount subroutine