Error codes closer to Posix.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15183 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
c56242ebfa
commit
d11ba7310f
|
@ -110,9 +110,10 @@ void chSemObjectInit(semaphore_t *sp, cnt_t n) {
|
||||||
* performing checks that make sure that the object is in a
|
* performing checks that make sure that the object is in a
|
||||||
* state compatible with operations stop.
|
* state compatible with operations stop.
|
||||||
* @note If the option @p CH_CFG_ENABLE_HARDENING is enabled then the
|
* @note If the option @p CH_CFG_ENABLE_HARDENING is enabled then the
|
||||||
* object is cleared, attempts to use the object would likely
|
* object is also cleared, attempts to use the object would likely
|
||||||
* result in a clean memory access violation because dereferencing
|
* result in a clean memory access violation because dereferencing
|
||||||
* of @p NULL pointers.
|
* of @p NULL pointers rather than dereferencing previously valid
|
||||||
|
* pointers.
|
||||||
*
|
*
|
||||||
* @param[in] sp pointer to a @p semaphore_t structure
|
* @param[in] sp pointer to a @p semaphore_t structure
|
||||||
*
|
*
|
||||||
|
@ -120,9 +121,7 @@ void chSemObjectInit(semaphore_t *sp, cnt_t n) {
|
||||||
*/
|
*/
|
||||||
void chSemObjectDispose(semaphore_t *sp) {
|
void chSemObjectDispose(semaphore_t *sp) {
|
||||||
|
|
||||||
chDbgAssert(chMemIsAreaWritableX((void *)sp,
|
chDbgCheck(chMemIsAreaWritableX((void *)sp, sizeof (semaphore_t), MEM_NATURAL_ALIGN));
|
||||||
sizeof (semaphore_t),
|
|
||||||
MEM_NATURAL_ALIGN), "pointer error");
|
|
||||||
chDbgAssert(ch_queue_isempty(&sp->queue), "object in use");
|
chDbgAssert(ch_queue_isempty(&sp->queue), "object in use");
|
||||||
|
|
||||||
#if 0 /*CH_CFG_ENABLE_HARDENING == TRUE*/
|
#if 0 /*CH_CFG_ENABLE_HARDENING == TRUE*/
|
||||||
|
|
|
@ -120,28 +120,28 @@ static msg_t translate_error(FRESULT res) {
|
||||||
msg = VFS_RET_TIMEOUT;
|
msg = VFS_RET_TIMEOUT;
|
||||||
break;
|
break;
|
||||||
case FR_NOT_ENOUGH_CORE:
|
case FR_NOT_ENOUGH_CORE:
|
||||||
|
msg = VFS_RET_ENOMEM;
|
||||||
|
break;
|
||||||
case FR_TOO_MANY_OPEN_FILES:
|
case FR_TOO_MANY_OPEN_FILES:
|
||||||
msg = VFS_RET_NO_RESOURCE;
|
msg = VFS_RET_ENFILE;
|
||||||
break;
|
break;
|
||||||
case FR_DISK_ERR:
|
case FR_DISK_ERR:
|
||||||
case FR_NOT_READY:
|
case FR_NOT_READY:
|
||||||
case FR_INVALID_DRIVE:
|
case FR_INVALID_DRIVE:
|
||||||
case FR_NO_FILESYSTEM:
|
case FR_NO_FILESYSTEM:
|
||||||
msg = VFS_RET_MEDIA_ERROR;
|
msg = VFS_RET_EIO;
|
||||||
break;
|
break;
|
||||||
case FR_NO_FILE:
|
case FR_NO_FILE:
|
||||||
msg = VFS_RET_NOT_FOUND;
|
|
||||||
break;
|
|
||||||
case FR_NO_PATH:
|
case FR_NO_PATH:
|
||||||
case FR_INVALID_NAME:
|
case FR_INVALID_NAME:
|
||||||
msg = VFS_RET_INVALID_PATH;
|
msg = VFS_RET_ENOENT;
|
||||||
break;
|
break;
|
||||||
case FR_DENIED:
|
case FR_DENIED:
|
||||||
case FR_WRITE_PROTECTED:
|
case FR_WRITE_PROTECTED:
|
||||||
msg = VFS_RET_ACCESS_DENIED;
|
msg = VFS_RET_EACCES;
|
||||||
break;
|
break;
|
||||||
case FR_EXIST:
|
case FR_EXIST:
|
||||||
msg = VFS_RET_EXIST;
|
msg = VFS_RET_EEXIST;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg = VFS_RET_INNER_ERROR;
|
msg = VFS_RET_INNER_ERROR;
|
||||||
|
@ -226,7 +226,7 @@ static msg_t drv_open_file(void *instance,
|
||||||
|
|
||||||
mode = translate_oflag(oflag);
|
mode = translate_oflag(oflag);
|
||||||
if (mode == (BYTE)0) {
|
if (mode == (BYTE)0) {
|
||||||
err = VFS_RET_INVALID_MODE;
|
err = VFS_RET_EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ msg_t drvFatFSMount(const char *name, bool mountnow) {
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
fs = chPoolAlloc(&vfs_fatfs.fs_nodes_pool);
|
fs = chPoolAlloc(&vfs_fatfs.fs_nodes_pool);
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
return VFS_RET_NO_RESOURCE;
|
return VFS_RET_ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ msg_t drvFatFSUnmount(const char *name) {
|
||||||
|
|
||||||
fs = f_getfs(name);
|
fs = f_getfs(name);
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
return VFS_RET_MEDIA_ERROR;
|
return VFS_RET_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_unmount(name);
|
res = f_unmount(name);
|
||||||
|
|
|
@ -95,7 +95,7 @@ static msg_t match_driver(vfs_overlay_driver_t *odp,
|
||||||
pp++;
|
pp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = VFS_RET_NO_DRIVER;
|
err = VFS_RET_ENOENT;
|
||||||
}
|
}
|
||||||
while (false);
|
while (false);
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ static msg_t drv_open_file(void *instance,
|
||||||
(void)instance;
|
(void)instance;
|
||||||
|
|
||||||
/* Always not found, there are no files in the root.*/
|
/* Always not found, there are no files in the root.*/
|
||||||
err = VFS_RET_NOT_FOUND;
|
err = VFS_RET_ENOENT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
vfs_driver_t *dp;
|
vfs_driver_t *dp;
|
||||||
|
@ -300,7 +300,7 @@ msg_t drvOverlayRegisterDriver(vfs_overlay_driver_t *vodp,
|
||||||
msg_t err;
|
msg_t err;
|
||||||
|
|
||||||
if (vodp->next_driver >= DRV_CFG_OVERLAY_DRV_MAX) {
|
if (vodp->next_driver >= DRV_CFG_OVERLAY_DRV_MAX) {
|
||||||
err = VFS_RET_NO_RESOURCE;
|
err = VFS_RET_ENOMEM;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
vodp->drivers[vodp->next_driver++] = vdp;
|
vodp->drivers[vodp->next_driver++] = vdp;
|
||||||
|
|
|
@ -119,7 +119,7 @@ static msg_t drv_open_dir(void *instance,
|
||||||
return VFS_RET_SUCCESS;
|
return VFS_RET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = VFS_RET_NO_RESOURCE;
|
err = VFS_RET_ENOMEM;
|
||||||
}
|
}
|
||||||
while (false);
|
while (false);
|
||||||
|
|
||||||
|
@ -166,13 +166,13 @@ static msg_t drv_open_file(void *instance,
|
||||||
return VFS_RET_SUCCESS;
|
return VFS_RET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return VFS_RET_NO_RESOURCE;
|
return VFS_RET_ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
dsep++;
|
dsep++;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = VFS_RET_NOT_FOUND;
|
err = VFS_RET_ENOENT;
|
||||||
}
|
}
|
||||||
while (false);
|
while (false);
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,17 @@
|
||||||
#ifndef VFSERRORS_H
|
#ifndef VFSERRORS_H
|
||||||
#define VFSERRORS_H
|
#define VFSERRORS_H
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module constants. */
|
/* Module constants. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Error codes compatible with HAL streams
|
* @name Error codes compatible with HAL and Posix
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
#define VFS_RET_SUCCESS 0
|
#define VFS_RET_SUCCESS 0
|
||||||
#define VFS_RET_TIMEOUT -1
|
#define VFS_RET_TIMEOUT -1
|
||||||
#define VFS_RET_EOF -2
|
#define VFS_RET_EOF -2
|
||||||
|
@ -49,6 +52,26 @@
|
||||||
#define VFS_RET_MEDIA_ERROR -10
|
#define VFS_RET_MEDIA_ERROR -10
|
||||||
#define VFS_RET_INNER_ERROR -11
|
#define VFS_RET_INNER_ERROR -11
|
||||||
#define VFS_RET_INVALID_MODE -12
|
#define VFS_RET_INVALID_MODE -12
|
||||||
|
#endif
|
||||||
|
#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_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 */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -64,7 +64,7 @@ msg_t vfs_parse_match_separator(const char **pathp) {
|
||||||
const char *p = *pathp;
|
const char *p = *pathp;
|
||||||
|
|
||||||
if (*p++ != '/') {
|
if (*p++ != '/') {
|
||||||
err = VFS_RET_INVALID_PATH;
|
err = VFS_RET_ENOENT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
err = VFS_RET_SUCCESS;
|
err = VFS_RET_SUCCESS;
|
||||||
|
@ -83,7 +83,7 @@ msg_t vfs_parse_match_end(const char **pathp) {
|
||||||
msg_t err;
|
msg_t err;
|
||||||
|
|
||||||
if (**pathp != '\0') {
|
if (**pathp != '\0') {
|
||||||
err = VFS_RET_INVALID_PATH;
|
err = VFS_RET_ENOENT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
err = VFS_RET_SUCCESS;
|
err = VFS_RET_SUCCESS;
|
||||||
|
@ -113,7 +113,7 @@ msg_t vfs_parse_filename(const char **pathp, char *fname) {
|
||||||
|
|
||||||
/* Consecutive separators are not valid.*/
|
/* Consecutive separators are not valid.*/
|
||||||
if (n == 0U) {
|
if (n == 0U) {
|
||||||
return VFS_RET_INVALID_PATH;
|
return VFS_RET_ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Advancing the path pointer past the file name in the path and
|
/* Advancing the path pointer past the file name in the path and
|
||||||
|
@ -125,11 +125,11 @@ msg_t vfs_parse_filename(const char **pathp, char *fname) {
|
||||||
|
|
||||||
/* Valid characters for path names.*/
|
/* Valid characters for path names.*/
|
||||||
if (!isalnum(c) && (c != '_') && (c != '-') && (c != '.')) {
|
if (!isalnum(c) && (c != '_') && (c != '-') && (c != '.')) {
|
||||||
return VFS_RET_INVALID_PATH;
|
return VFS_RET_ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n > VFS_CFG_MAX_NAMELEN) {
|
if (n > VFS_CFG_MAX_NAMELEN) {
|
||||||
return VFS_RET_INVALID_PATH;
|
return VFS_RET_ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
*fname++ = c;
|
*fname++ = c;
|
||||||
|
|
Loading…
Reference in New Issue