Skip to content

Commit 918108a

Browse files
de-nordicMaureenHelm
authored andcommitted
fs: Document return values to VFS API calls
The commit adds missing documentation for various retrun values of VFS API calls. Signed-off-by: Dominik Ermel <[email protected]>
1 parent bd6cc1f commit 918108a

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

include/fs/fs.h

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,13 @@ static inline void fs_dir_t_init(struct fs_dir_t *zdp)
253253
* @param flags The mode flags
254254
*
255255
* @retval 0 on success;
256+
* @retval -EBUSY when zfp is already used;
256257
* @retval -EINVAL when a bad file name is given;
257258
* @retval -EROFS when opening read-only file for write, or attempting to
258259
* create a file on a system that has been mounted with the
259260
* FS_MOUNT_FLAG_READ_ONLY flag;
260261
* @retval -ENOENT when the file path is not possible (bad mount point);
262+
* @retval -ENOTSUP when not implemented by underlying file system driver;
261263
* @retval <0 an other negative errno code, depending on a file system back-end.
262264
*/
263265
int fs_open(struct fs_file_t *zfp, const char *file_name, fs_mode_t flags);
@@ -270,6 +272,7 @@ int fs_open(struct fs_file_t *zfp, const char *file_name, fs_mode_t flags);
270272
* @param zfp Pointer to the file object
271273
*
272274
* @retval 0 on success;
275+
* @retval -ENOTSUP when not implemented by underlying file system driver;
273276
* @retval <0 a negative errno code on error.
274277
*/
275278
int fs_close(struct fs_file_t *zfp);
@@ -282,6 +285,7 @@ int fs_close(struct fs_file_t *zfp);
282285
* @param path Path to the file or directory to delete
283286
*
284287
* @retval 0 on success;
288+
* @retval -EINVAL when a bad file name is given;
285289
* @retval -EROFS if file is read-only, or when file system has been mounted
286290
* with the FS_MOUNT_FLAG_READ_ONLY flag;
287291
* @retval -ENOTSUP when not implemented by underlying file system driver;
@@ -307,6 +311,10 @@ int fs_unlink(const char *path);
307311
* @param to The destination path
308312
*
309313
* @retval 0 on success;
314+
* @retval -EINVAL when a bad file name is given, or when rename would cause move
315+
* between mount points;
316+
* @retval -EROFS if file is read-only, or when file system has been mounted
317+
* with the FS_MOUNT_FLAG_READ_ONLY flag;
310318
* @retval -ENOTSUP when not implemented by underlying file system driver;
311319
* @retval <0 an other negative errno code on error.
312320
*/
@@ -324,6 +332,8 @@ int fs_rename(const char *from, const char *to);
324332
* @param size Number of bytes to be read
325333
*
326334
* @retval >=0 a number of bytes read, on success;
335+
* @retval -EBADF when invoked on zfp that represents unopened/closed file;
336+
* @retval -ENOTSUP when not implemented by underlying file system driver;
327337
* @retval <0 a negative errno code on error.
328338
*/
329339
ssize_t fs_read(struct fs_file_t *zfp, void *ptr, size_t size);
@@ -343,6 +353,7 @@ ssize_t fs_read(struct fs_file_t *zfp, void *ptr, size_t size);
343353
* @param size Number of bytes to be written
344354
*
345355
* @retval >=0 a number of bytes written, on success;
356+
* @retval -EBADF when invoked on zfp that represents unopened/closed file;
346357
* @retval -ENOTSUP when not implemented by underlying file system driver;
347358
* @retval <0 an other negative errno code on error.
348359
*/
@@ -362,6 +373,7 @@ ssize_t fs_write(struct fs_file_t *zfp, const void *ptr, size_t size);
362373
* - @c FS_SEEK_END for the end of the file.
363374
*
364375
* @retval 0 on success;
376+
* @retval -EBADF when invoked on zfp that represents unopened/closed file;
365377
* @retval -ENOTSUP if not supported by underlying file system driver;
366378
* @retval <0 an other negative errno code on error.
367379
*/
@@ -375,6 +387,7 @@ int fs_seek(struct fs_file_t *zfp, off_t offset, int whence);
375387
* @param zfp Pointer to the file object
376388
*
377389
* @retval >= 0 a current position in file;
390+
* @retval -EBADF when invoked on zfp that represents unopened/closed file;
378391
* @retval -ENOTSUP if not supported by underlying file system driver;
379392
* @retval <0 an other negative errno code on error.
380393
*
@@ -398,6 +411,7 @@ off_t fs_tell(struct fs_file_t *zfp);
398411
* @param length New size of the file in bytes
399412
*
400413
* @retval 0 on success;
414+
* @retval -EBADF when invoked on zfp that represents unopened/closed file;
401415
* @retval -ENOTSUP when not implemented by underlying file system driver;
402416
* @retval <0 an other negative errno code on error.
403417
*/
@@ -415,6 +429,8 @@ int fs_truncate(struct fs_file_t *zfp, off_t length);
415429
* @param zfp Pointer to the file object
416430
*
417431
* @retval 0 on success;
432+
* @retval -EBADF when invoked on zfp that represents unopened/closed file;
433+
* @retval -ENOTSUP when not implemented by underlying file system driver;
418434
* @retval <0 a negative errno code on error.
419435
*/
420436
int fs_sync(struct fs_file_t *zfp);
@@ -427,6 +443,8 @@ int fs_sync(struct fs_file_t *zfp);
427443
* @param path Path to the directory to create
428444
*
429445
* @retval 0 on success;
446+
* @retval -EROFS if file is read-only, or when file system has been mounted
447+
* with the FS_MOUNT_FLAG_READ_ONLY flag;
430448
* @retval -ENOTSUP when not implemented by underlying file system driver;
431449
* @retval <0 an other negative errno code on error
432450
*/
@@ -441,6 +459,9 @@ int fs_mkdir(const char *path);
441459
* @param path Path to the directory to open
442460
*
443461
* @retval 0 on success;
462+
* @retval -EINVAL when a bad directory path is given;
463+
* @retval -EBUSY when zdp is already used;
464+
* @retval -ENOTSUP when not implemented by underlying file system driver;
444465
* @retval <0 a negative errno code on error.
445466
*/
446467
int fs_opendir(struct fs_dir_t *zdp, const char *path);
@@ -459,7 +480,9 @@ int fs_opendir(struct fs_dir_t *zdp, const char *path);
459480
* @param zdp Pointer to the directory object
460481
* @param entry Pointer to zfs_dirent structure to read the entry into
461482
*
462-
* @retval 0 on success or end-of-dir;;
483+
* @retval 0 on success or end-of-dir;
484+
* @retval -ENOENT when no such directory found;
485+
* @retval -ENOTSUP when not implemented by underlying file system driver;
463486
* @retval <0 a negative errno code on error.
464487
*/
465488
int fs_readdir(struct fs_dir_t *zdp, struct fs_dirent *entry);
@@ -472,6 +495,7 @@ int fs_readdir(struct fs_dir_t *zdp, struct fs_dirent *entry);
472495
* @param zdp Pointer to the directory object
473496
*
474497
* @retval 0 on success;
498+
* @retval -ENOTSUP when not implemented by underlying file system driver;
475499
* @retval <0 a negative errno code on error.
476500
*/
477501
int fs_closedir(struct fs_dir_t *zdp);
@@ -547,6 +571,9 @@ int fs_readmount(int *index, const char **name);
547571
* directory exists.
548572
*
549573
* @retval 0 on success;
574+
* @retval -EINVAL when a bad directory or file name is given;
575+
* @retval -ENOENT when no such directory or file is found;
576+
* @retval -ENOTSUP when not supported by underlying file system driver;
550577
* @retval <0 negative errno code on error.
551578
*/
552579
int fs_stat(const char *path, struct fs_dirent *entry);
@@ -558,9 +585,10 @@ int fs_stat(const char *path, struct fs_dirent *entry);
558585
*
559586
* @param path Path to the mounted directory
560587
* @param stat Pointer to the zfs_statvfs structure to receive the fs
561-
* statistics
588+
* statistics.
562589
*
563590
* @retval 0 on success;
591+
* @retval -EINVAL when a bad path to a directory, or a file, is given;
564592
* @retval -ENOTSUP when not implemented by underlying file system driver;
565593
* @retval <0 an other negative errno code on error.
566594
*/
@@ -570,12 +598,16 @@ int fs_statvfs(const char *path, struct fs_statvfs *stat);
570598
* @brief Register a file system
571599
*
572600
* Register file system with virtual file system.
601+
* Number of allowed file system types to be registered is controlled with the
602+
* CONFIG_FILE_SYSTEM_MAX_TYPES Kconfig option.
573603
*
574604
* @param type Type of file system (ex: @c FS_FATFS)
575605
* @param fs Pointer to File system
576606
*
577607
* @retval 0 on success;
578-
* @retval <0 negative errno code on error.
608+
* @retval -EALREADY when a file system of a given type has already been registered;
609+
* @retval -ENOSCP when there is no space left, in file system registry, to add
610+
* this file system type.
579611
*/
580612
int fs_register(int type, const struct fs_file_system_t *fs);
581613

@@ -588,7 +620,7 @@ int fs_register(int type, const struct fs_file_system_t *fs);
588620
* @param fs Pointer to File system
589621
*
590622
* @retval 0 on success;
591-
* @retval <0 negative errno code on error.
623+
* @retval -EINVAL when file system of a given type has not been registered.
592624
*/
593625
int fs_unregister(int type, const struct fs_file_system_t *fs);
594626

0 commit comments

Comments
 (0)