diff --git a/os/sb/host/sb.h b/os/sb/host/sb.h index 3f72f3238..a752406aa 100644 --- a/os/sb/host/sb.h +++ b/os/sb/host/sb.h @@ -163,9 +163,9 @@ extern "C" { /*===========================================================================*/ #include "sberr.h" +#include "sbposix.h" #include "sbhost.h" #include "sbapi.h" -#include "sbposix.h" #endif /* SBHOST_H */ diff --git a/os/vfs/drivers/streams/drvstreams.c b/os/vfs/drivers/streams/drvstreams.c index 9c3d703c8..07dfefc3d 100644 --- a/os/vfs/drivers/streams/drvstreams.c +++ b/os/vfs/drivers/streams/drvstreams.c @@ -296,7 +296,7 @@ static msg_t node_file_setpos(void *instance, vfs_offset_t offset) { (void)instance; (void)offset; - return VFS_RET_NOT_IMPLEMENTED; + return VFS_RET_ENOSYS; } static vfs_offset_t node_file_getpos(void *instance) { diff --git a/os/vfs/include/vfserrors.h b/os/vfs/include/vfserrors.h index 528e6efd9..22973805a 100644 --- a/os/vfs/include/vfserrors.h +++ b/os/vfs/include/vfserrors.h @@ -35,31 +35,37 @@ /*===========================================================================*/ /** - * @name Error codes compatible with HAL and Posix + * @name VFS error codes * @{ */ -#define VFS_RET_SUCCESS 0 /* Success */ -#define VFS_RET_TIMEOUT -1 /* Timeout */ -#define VFS_RET_EOF -2 /* End-of-file */ -#define VFS_RET_NOT_IMPLEMENTED -3 /* Not implemented functionality */ -#define VFS_RET_INNER_ERROR -4 /* Unspecified error */ -#define VFS_RET_ENOENT (-32 - ENOENT) /* No such file or directory */ -#define VFS_RET_EIO (-32 - EIO) /* I/O error */ -#define VFS_RET_EBADF (-32 - EBADF) /* Bad file number */ -#define VFS_RET_ENOMEM (-32 - ENOMEM) /* Not enough space */ -#define VFS_RET_EACCES (-32 - EACCES) /* Permission denied */ -#define VFS_RET_EEXIST (-32 - EEXIST) /* File exists */ -#define VFS_RET_ENOTDIR (-32 - ENOTDIR) /* Not a directory */ -#define VFS_RET_EISDIR (-32 - EISDIR) /* Is a directory */ -#define VFS_RET_EINVAL (-32 - EINVAL) /* Invalid argument */ -#define VFS_RET_EMFILE (-32 - EMFILE) /* Too many open files in process */ -#define VFS_RET_ENFILE (-32 - ENFILE) /* Too many open files in system */ -#define VFS_RET_EFBIG (-32 - EFBIG) /* File too large */ -#define VFS_RET_ENOSPC (-32 - ENOSPC) /* No space left on device */ -#define VFS_RET_ESPIPE (-32 - ESPIPE) /* Illegal seek */ -#define VFS_RET_EROFS (-32 - EROFS) /* Read-only file system */ -#define VFS_RET_ERANGE (-32 - ERANGE) /* Result too large */ -#define VFS_RET_ENAMETOOLONG (-32 - ENAMETOOLONG)/* File or path name too long */ +#define VFS_RET_SUCCESS (msg_t)MSG_OK /* Success */ +#define VFS_RET_TIMEOUT (msg_t)MSG_TIMEOUT /* Timeout */ +#define VFS_RET_EOF (msg_t)-3 /* End-of-file */ +#define VFS_RET_INNER_ERROR (msg_t)-4 /* Unexpected condition */ +/** @} */ + +/** + * @name Error codes compatible with Posix + * @{ + */ +#define VFS_RET_ENOENT VFS_ERROR(ENOENT) /* No such file or directory */ +#define VFS_RET_EIO VFS_ERROR(EIO) /* I/O error */ +#define VFS_RET_EBADF VFS_ERROR(EBADF) /* Bad file number */ +#define VFS_RET_ENOMEM VFS_ERROR(ENOMEM) /* Not enough space */ +#define VFS_RET_EACCES VFS_ERROR(EACCES) /* Permission denied */ +#define VFS_RET_EEXIST VFS_ERROR(EEXIST) /* File exists */ +#define VFS_RET_ENOTDIR VFS_ERROR(ENOTDIR) /* Not a directory */ +#define VFS_RET_EISDIR VFS_ERROR(EISDIR) /* Is a directory */ +#define VFS_RET_EINVAL VFS_ERROR(EINVAL) /* Invalid argument */ +#define VFS_RET_EMFILE VFS_ERROR(EMFILE) /* Too many open files in process */ +#define VFS_RET_ENFILE VFS_ERROR(ENFILE) /* Too many open files in system */ +#define VFS_RET_EFBIG VFS_ERROR(EFBIG) /* File too large */ +#define VFS_RET_ENOSPC VFS_ERROR(ENOSPC) /* No space left on device */ +#define VFS_RET_ESPIPE VFS_ERROR(ESPIPE) /* Illegal seek */ +#define VFS_RET_EROFS VFS_ERROR(EROFS) /* Read-only file system */ +#define VFS_RET_ERANGE VFS_ERROR(ERANGE) /* Result too large */ +#define VFS_RET_ENAMETOOLONG VFS_ERROR(ENAMETOOLONG)/* File or path name too long */ +#define VFS_RET_ENOSYS VFS_ERROR(ENOSYS) /** @} */ /*===========================================================================*/ @@ -78,7 +84,13 @@ /* Module macros. */ /*===========================================================================*/ -#define VFS_IS_ERROR(err) ((msg_t)(err) < VFS_RET_SUCCESS) +/** + * @name Errors handling macros + * @{ + */ +#define VFS_ERRORS_MASK (msg_t)((msg_t)-1 & ~(msg_t)0xFF) +#define VFS_ERROR(posixerr) (VFS_ERRORS_MASK | (msg_t)(posixerr)) +#define VFS_IS_ERROR(x) (((msg_t)(x) & VFS_ERRORS_MASK) == VFS_ERRORS_MASK) #define VFS_BREAK_ON_ERROR(err) \ if (VFS_IS_ERROR(err)) break @@ -89,6 +101,7 @@ return __ret; \ } \ } while (false) +/** @} */ /*===========================================================================*/ /* External declarations. */