Creating new file system types
If it is necessary to create a new type of file system, file system helpers and mount helpers must be created.
This section provides information about the implementation specifics and execution syntax of file system helpers and mount helpers.
File system 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 this information to a back-end program. 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 helpers and mount helpers.
To determine the appropriate file system helper, the front-end command looks for a helper under the /sbin/helpers/vfstype/command file, where vfstype matches the file system type found in the /etc/vfs file and command matches the name of the command being executed. The flags passed to the front-end command are passed to the file system helper.
- The helper returns 0 if the logical volume does not contain a file system of its type. A return value of 0 indicates the logical volume does not contain a log.
- The helper returns 1 if the logical volume does contain a file system of its type and the file system does not need a separate device for a log. A return value of 1 indicates the logical volume does contain a log.
- The helper returns 2 if the logical volume does contain a file system of its type and the file system does need a separate device for a log. If the -l flag is specified, the fstype helper should check for a log of its file system type on the specified logical volume.
Obsolete file system helper mechanism
This section describes the obsolete file system helper mechanism that was used on previous versions of AIX®. This mechanism is still available but should not be used anymore.
File system helper operations
Helper operations | Value |
---|---|
#define FSHOP_NULL | 0 |
#define FSHOP_CHECK | 1 |
#define FSHOP_CHGSIZ | 2 |
#define FSHOP_FINDATA | 3 |
#define FSHOP_FREE | 4 |
#define FSHOP_MAKE | 5 |
#define FSHOP_REBUILD | 6 |
#define FSHOP_STATFS | 7 |
#define FSHOP_STAT | 8 |
#define FSHOP_USAGE | 9 |
#define FSHOP_NAMEI | 10 |
#define FSHOP_DEBUG | 11 |
However, the JFS file system supports only the following operations:
#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
File system helper execution syntax
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:
Flags Indicator #define FSHMOD_INTERACT_FLAG "i" #define FSHMOD_FORCE_FLAG "f" #define FSHMOD_NONBLOCK_FLAG "n" #define FSHMOD_PERROR_FLAG "p" #define FSHMOD_ERRDUMP_FLAG "e" #define FSHMOD_STANDALONE_FLAG "s" #define FSHMOD_IGNDEVTYPE_FLAG "I"
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.
Sample helper invocations
execl("/etc/helpers/v3fshelpers","fshop_check","1","3","5","ifp",
"0","devices=/dev/lv02,fast,preen,mounted")
- The executable execd is /etc/helper/v3fshelpers.
- The name appearing in a listing of processes (ps command) is fshop_check.
- The operation requested is FSHOP_CHECK as represented by the value "1".
- The file system is open on file descriptor "3".
- The pipe through which the helper can send information to the front-end program is open on file descriptor "5".
- The ModeFlags string is "-ifp", indicating interactive mode plus force and perror modes.
- The DebugLevel is 0, so no extra debugging output is returned to the fsck command.
- The OpFlags string tells the back-end programs which device the operation is to be performed on (/dev/lv02), the options requested (fast and preen), and notes that the device is mounted. For the fsck command, no changes will be made because the fsck command does not work on mounted file systems.
mkfs /junk
mkfs /dev/lv02
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.
Mount helpers
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.
mount /test
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.
/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.
Mount helper execution syntax
/etc/helpers/nfsmnthelp M 0 host1 /export /test ro,fg,hard,intr
- 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.
- 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 as follows:
- 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.