X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/70702af1370e44e32fb2c3c507e4759a187b4fe5..289f6a146c0b2087607d8d8659531ea90142779a:/fatfs/documents/doc/mount.html diff --git a/fatfs/documents/doc/mount.html b/fatfs/documents/doc/mount.html new file mode 100644 index 0000000..901ffc0 --- /dev/null +++ b/fatfs/documents/doc/mount.html @@ -0,0 +1,113 @@ + + + + + + + + +FatFs - f_mount + + + + +
+

f_mount

+

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

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

Parameters

+
+
fs
+
Pointer to the filesystem object to be registered and cleared. Null pointer unregisters the registered filesystem 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_NOT_ENABLED, +FR_NO_FILESYSTEM +

+
+ + +
+

Description

+

FatFs requires work area (filesystem object) for each logical drives (FAT volumes). Prior to perform file/directory operations, a filesystem object needs to be registered with f_mount function to the logical drive. The file/directory API functions get ready to work after this procedure. If there is any open object of file or directory on the logical drive, the object will be invalidated by this function.

+

The f_mount function registers/unregisters a filesystem object to the FatFs module as follows:

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

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. The volume mount process will be attempted on subsequent file/directroy function if the filesystem object is not initialized. (delayed mounting) The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and then initialize the work area, is performed in the subsequent file/directory functions when either of following conditions is true.

+ +

If the function with forced mounting (opt = 1) failed with FR_NOT_READY, it means that the filesystem object has been registered successfully but the volume is currently not ready to work. The volume mount process will be attempted on subsequent file/directroy function.

+

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

+

To unregister the work area, specify a NULL to the fs, and then the work area can be discarded.

+
+ + +
+

QuickInfo

+

Always available.

+
+ + +
+

Example

+
+int main (void)
+{
+    FATFS *fs;     /* Ponter to the filesystem object */
+
+
+    fs = malloc(sizeof (FATFS));           /* Get work area for the volume */
+    f_mount(fs, "", 0);                    /* Mount the default drive */
+
+    f_open(...                             /* Here any file API can be used */
+
+    ...
+
+    f_mount(fs, "", 0);                    /* Re-mount the default drive to reinitialize the filesystem */
+
+    ...
+
+    f_mount(0, "", 0);                     /* Unmount the default drive */
+    free(fs);                              /* Here the work area can be discarded */
+
+    ...
+}
+
+
+ + +
+

See Also

+

f_open, FATFS

+
+ +

Return

+ +