# Return Code of API Functions

Most of API functions return common result code in enum type `FRESULT`. When an API function succeeded, it returns zero (`FR_OK`), otherwise it returns non-zero value indicates type of error.

FR_OK (0)
  The function succeeded.
FR_DISK_ERR
  The lower layer, `disk_read`, `disk_write` or `disk_ioctl` function, reported that an unrecoverable hard error occured.
  Note that if once this error occured at any operation to an open file, the file object is aborted and any operations to the file except for close will be rejected.
FR_INT_ERR
  Assertion failed and an insanity is detected in the internal process. One of the following possibilities is suspected.
  - Work area (file system object, file object or etc...) has been broken by stack overflow or something. This is the reason in most case.
  - There is an error of the FAT structure on the volume.
  - There is a bug in the FatFs module itself.
  - Wrong lower layer implementation.
  Note that if once this error occured in the operation to an open file, the file object is aborted and any operation to the file except for close will be rejected.
FR_NOT_READY
  The lower layer, `disk_initialize` function, reported that the storage device could not be got ready to work. One of the following possibilities is suspected.
  - No medium in the drive.
  - Wrong lower layer implementation.
  - Wrong hardware configuration.
  - The storage device has broken.
FR_NO_FILE
  Could not find the file in the directory.
FR_NO_PATH
  Could not find the path. A directory in the path name could not be found.
FR_INVALID_NAME
  The given string is invalid as a path name. One of the following possibilities is suspected.
  - There is a character not allowed for the file name.
  - The file name is out of 8.3 format. (at non-LFN cfg.)
  - `FF_MAX_LFN` is insufficient for the file name. (at LFN cfg.)
  - There is a character encoding error in the string.
FR_DENIED
  The required access was denied due to one of the following reasons:
  - Write mode open against the read-only file. (f_open)
  - Deleting the read-only file or directory. (f_unlink)
  - Deleting the non-empty directory or current directory. (f_unlink)
  - Reading the file opened without `FA_READ` flag. (f_read)
  - Any modification to the file opened without `FA_WRITE` flag. (f_write, f_truncate, f_expand)
  - Could not create the object due to root directory full or disk full. (f_open, f_mkdir)
  - Could not find a contiguous area for the file. (f_expand)
FR_EXIST
  Name collision. An object with the same name is already existing in the directory.
FR_INVALID_OBJECT
  The file/directory object is invalid or a null pointer is given. There are some reasons as follows:
  - It has been closed, or the structure has been collapsed.
  - It has been invalidated. Open objects on the volume are invalidated by voulme mount process.
  - Physical drive is not ready to work due to a media removal.
FR_WRITE_PROTECTED
  A write mode operation against the write-protected media.
FR_INVALID_DRIVE
  Invalid drive number is specified in the path name or a null pointer is given as the path name. (Related option: `FF_VOLUMES`)
FR_NOT_ENABLED
  Work area for the logical drive has not been registered by `f_mount` function.
FR_NO_FILESYSTEM
  Valid FAT volume could not be found in the drive. One of the following possibilities is suspected.
  - The FAT volume on the drive is collapsed.
  - Wrong lower layer implementation.
  - Wrong `VolToPart[]` settings. (`FF_MULTI_PARTITION = 1`)
FR_MKFS_ABORTED
  The `f_mkfs` function aborted before start in format due to a reason as follows:
  - It is impossible to create the volume with the given conditions.
  - The size of the volume is too small. 128 sectors minimum with `FM_SFD` option.
  - The partition associated with the logical drive is not exist. (Related option: `FF_MULTI_PARTITION`)
FR_TIMEOUT
  The function was canceled due to a timeout of thread-safe control. (Related option: `FF_TIMEOUT`)
FR_LOCKED
  The operation to the object was rejected by file sharing control. (Related option: `FF_FS_LOCK`)
FR_NOT_ENOUGH_CORE
  Not enough memory for the operation. There is one of the following reasons:
  - Could not allocate a memory for LFN working buffer. (Related option: `FF_USE_LFN`)
  - Size of the given buffer is insufficient for the size required.
FR_TOO_MANY_OPEN_FILES
  Number of open objects has been reached maximum value and no more object can be opened. (Related option: `FF_FS_LOCK`)
FR_INVALID_PARAMETER
  The given parameter is invalid or there is an inconsistent for the volume.

Return