HAL_ChibiOS: added support for AP_Terrain for ChibiOS

This commit is contained in:
Andrew Tridgell 2018-01-14 17:25:23 +11:00
parent cde930f5c8
commit e2a65c8c60
1 changed files with 42 additions and 8 deletions

View File

@ -1598,18 +1598,17 @@ int mkdir(const char *pathname, mode_t mode)
{
errno = 0;
if(mode)
{
if(chmod(pathname, mode))
return(-1);
}
int res = f_mkdir(pathname);
if(res != FR_OK)
{
errno = fatfs_to_errno(res);
return(-1);
}
if (mode) {
chmod(pathname, mode);
}
return(0);
}
@ -2115,8 +2114,9 @@ int fatfs_to_errno( FRESULT Result )
case FR_DENIED: /* FatFS (7) Access denied due to prohibited access or directory full */
return (EACCES); /* POSIX Permission denied (POSIX.1) */
case FR_EXIST: /* FatFS (8) Access denied due to prohibited access */
return (EACCES); /* POSIX Permission denied (POSIX.1) */
case FR_EXIST: /* file exists */
return (EEXIST); /* file exists */
case FR_INVALID_OBJECT: /* FatFS (9) The file/directory object is invalid */
return (EINVAL); /* POSIX Invalid argument (POSIX.1) */
@ -2519,3 +2519,37 @@ fprintf(FILE *fp, const char *fmt, ...)
return len;
}
/*
fsync file
*/
int
fsync(int fileno)
{
FILE *stream;
FIL *fh;
int res;
errno = 0;
// checks if fileno out of bounds
stream = fileno_to_stream(fileno);
if(stream == NULL)
{
return(-1);
}
// fileno_to_fatfs checks for fileno out of bounds
fh = fileno_to_fatfs(fileno);
if(fh == NULL)
{
return(-1);
}
res = f_sync(fh);
if (res != FR_OK)
{
errno = fatfs_to_errno(res);
return(-1);
}
return(0);
}