Commit graph

13 commits

Author SHA1 Message Date
Dominik Ermel a5b3e86339 subsys/fs: Fix fs_* operations crashing when file closed
Attempt to perform fs_read, fs_write, fs_seek, fs_tell, fs_truncate
and fs_sync on file that has been closed, prior to attempt, would cause
NULL pointer dereference.
With this fix, such operations would instead return -EBADF.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-03 12:16:11 -04:00
Dominik Ermel 54492c2748 subsys/fs: Fix fs_close on closed file causing NULL dereference
If fs_close gets invoked on closed file (e.g. double close) it would
cause NULL dereference and system crash. Instead now it will just
return with success, as the file is already closed anyway.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-03 12:16:11 -04:00
Peter A. Bigot 452d3dea7a subsys/fs: correct misinterpretation of Zephyr API
The Zephyr fs readdir abstraction returns OK with a zero-length file
name when the last directory entry has been found.  The loop to build
multiple entries instead checked for a non-file entry type.

Correct the loop exit condition.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-10-23 07:59:01 -04:00
Peter A. Bigot a8b7a21524 subsys/fs: remove ambiguity in readdir results
Existing file system implementations do not provide the special "."
(current) and ".." (parent) directory entries in the readdir results.
littlefs does.

Remove these entries in the abstraction layer.  This simplifies code in
higher level consumers that aren't prepared to see them.  Consumers like
FUSE that need them can put them back without having to worry about
conflicts.

Closes issue #17951

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-08-06 19:39:26 +02:00
Jim Paris fae62fc4fc fs: add support for mount point listing on vfs root
This will list all mount points in response to opendir("/").

This isn't perfect; mount points in subdirectories will show up as
their full path in this listing.  But it's better than just returning
-EINVAL.

Signed-off-by: Jim Paris <jim@jtan.com>
2019-07-26 14:20:00 +02:00
Peter A. Bigot 4d8726aad1 subsys/fs: hide non-public API
fs_get_mnt_point is not prototyped and should not be public.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-25 06:39:55 +03:00
Peter A. Bigot 0b2725a4dc subsys/fs: fix log messages requiring strdup
Use log_strdup for mount point paths.  Reduce redundancy in the log
messages.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-24 12:19:27 +02:00
Anas Nashif 656f4dfdac cleanup: include/: move fs.h to fs/fs.h
move fs.h to fs/fs.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Jan Van Winkel 3815ae6f7f fs: Added API to read mount point
Added API the read mount point names

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-06-11 08:31:54 -04:00
Varun Sharma 3de44b748c subsys: fs: Use template to define CONFIG_FS_LOG_LEVEL
Use "subsys/logging/Kconfig.template.log_config" as template

Signed-off-by: Varun Sharma <varun.sharma@intel.com>
2018-10-15 09:18:03 -04:00
Varun Sharma 7622fc37a0 subsys: fs: Migrate to new logging subsys
subsys:fs : Migrate from `SYS_LOG` to `LOG` logging mechanism.

tests: subsys: fs: Enabled CONFIG_LOG in prj.conf

Signed-off-by: Varun Sharma <varun.sharma@intel.com>
2018-10-15 09:18:03 -04:00
Ramakrishna Pallala dd5449a77b subsys: fs: Add the support for multiple instances of fs
Add support for multiple instances of a file system by
making use of mount point as the disk volume name which
is used by the file system library while formatting or
mounting a disk.

Also moved out file system specific data structures from
public fs.h header and handled them in corresponding
file system interface files by introducing open files and
open directories concept which is already being used in
NFFS interface module. Now it is extended to FatFs as well.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-05-08 08:53:01 -04:00
Ramakrishna Pallala 25302b1980 subsys: fs: Add Virtual File system Switch (VFS) support
Add support for Virtual File system Switch (VFS) by
introducing mount point concept to Zephyr. This allows
the applications to mount multiple file systems at
different mount points (ex: "/fatfs" and "/nffs"). The
mount point structure contains all the necessary info
required to instantiate, mount and operate on file system.

Decouple applications from directly accessing individual
file systems API's or internal functions by introducing
file system registration mechanism in VFS.

Move the file system defination and mount responsibility
to application so that application can decide which file system
to use and where to mount.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-03-10 21:38:04 -05:00