FAT

FatVolClose()

PROTOTYPE

#include <fsdriver.h>

int FatVolClose(FAT **fatp);

DESCRIPTION

FatVolClose() frees an unmounted FAT volume previously reserved by FatVolOpen(), releasing access to its read sector/write sector driver interface. fatp points to a handle previously returned by FatVolOpen().

If the volume uses an FTL or smart media layer (eMMc device, SD card, etc.), FatVolClose() synchronizes the volume by calling the report function in TargetFAT’s driver interface with the FS_SYNC request code.

Also, if the configuration definition FAT_VOL_GC is TRUE, FatVolClose() passes the request code FS_MARK_UNUSED to the report callback function for every range of sectors recorded as unused in the volume’s first FAT table. This TRIM operation helps FTL performance.

If successful, FatVolClose() returns 0 after setting *fatp to NULL. Otherwise, it sets errno and returns -1.

ERROR CODES

EFAULT fatp equals NULL.
EINVAL *fatp is not a volume handle returned by FatVolOpen().
ENOMEM Failed to allocate memory for a temporary buffer.

EXAMPLE

      /*---------------------------------------------------------------*/
      /* Release volume and close access to its sector interface.      */
      /*---------------------------------------------------------------*/
      if (FatVolClose(&fat))
        return -1;