fs: fs_mount parameter verification before mutex locked block

The commit moves fs_mount parameter verification above mutex lock.
The list of mount points is now checked before attempting to obtain
file system API pointer.
All modifications to mount point data structure, given as a parameter
to the fs_mount, are only applied after every other operation needed
have completed successfully, immediately before adding the mount point
to the list of mount points.
The fs_mount will a warning when mounted file system does not support
unmount.
When a file system does not provide mount function, the -ENOTSUP error
will be returned instead of -EINVAL.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2020-10-15 13:12:41 +00:00 committed by Carles Cufí
commit 5faf3750bc
3 changed files with 45 additions and 31 deletions

View file

@ -392,10 +392,17 @@ int fs_closedir(struct fs_dir_t *zdp);
* calling the file system specific mount function and adding
* the mount point to mounted file system list.
*
* @param mp Pointer to the fs_mount_t structure
* @param mp Pointer to the fs_mount_t structure. Referenced object
* is not changed if the mount operation failed.
* A reference is captured in the fs infrastructure if the
* mount operation succeeds, and the application must not
* mutate the structure contents until fs_unmount is
* successfully invoked on the same pointer.
*
* @retval 0 on success;
* @retval <0 a negative errno code on error.
* @retval -ENOENT when file system type has not been registered;
* @retval -ENOTSUP when not supported by underlying file system driver;
* @retval <0 a other negative errno code on error.
*/
int fs_mount(struct fs_mount_t *mp);