f_mount

The f_mount fucntion registers/unregisters file system object to the FatFs module.

FRESULT f_mount (
  FATFS*       fs,    /* [IN] File system object */
  const TCHAR* path,  /* [IN] Logical drive number */
  BYTE         opt    /* [IN] Initialization option */
);

Parameters

fs
Pointer to the file system object to be registered and cleared. Null pointer unregisters the registered file system object.
path
Pointer to the null-terminated string that specifies the logical drive. The string without drive number means the default drive.
opt
Mounting option. 0: Do not mount now (to be mounted on the first access to the volume), 1: Force mounted the volume to check if it is ready to work.

Return Values

FR_OK, FR_INVALID_DRIVE, FR_DISK_ERR, FR_NOT_READY, FR_NO_FILESYSTEM

Description

The f_mount function registers/unregisters a file system object used for the volume (logical drive) to the FatFs module as follows:

  1. Determines the logical drive which specified by path.
  2. Clears and unregisters the regsitered work area of the drive if exist.
  3. Clears and registers the new work area to the drive if fs is not NULL.
  4. Performs volume mount process to the drive if forced mounting is specified.

The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any API functions except for f_mkfs/f_fdisk function to the logical drive.

If forced mounting is not specified (opt = 0), this function always succeeds regardless of the physical drive status. It only clears (de-initializes) the given work area and registers its address to the internal table and no activity of the physical drive in this function. To unregister the work area, specify a NULL to the fs, and then the work area can be discarded. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.

If the function with forced mounting (opt = 1) failed, it means that the file system object has been registered successfully but the volume is currently not ready to work. The volume mount process will be attempted at subsequent file access functions if the file system object is not initialized. (delayed mounting)

If implementation of the disk I/O layer lacks media change detection, application program needs to perform a f_mount function after each media change to force cleared the file system object.

QuickInfo

Always available.

See Also

f_open, FATFS

Return