Skip to content

Commit

Permalink
Fix #262, Deprecates OS_FS_* defines that aren't unique to FS
Browse files Browse the repository at this point in the history
  • Loading branch information
dmknutsen committed Apr 20, 2020
1 parent 7d9c4c8 commit 78f4aba
Show file tree
Hide file tree
Showing 23 changed files with 580 additions and 579 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This distribution contains:
## Version Notes:

- 5.0.11: DEVELOPMENT
- The more descriptive return value OS_ERR_NAME_NOT_FOUND (instead of OS_FS_ERROR) will now be returned from the following functions (): OS_rmfs, OS_mount, OS_unmount, OS_FS_GetPhysDriveName
- The more descriptive return value OS_ERR_NAME_NOT_FOUND (instead of OS_ERROR) will now be returned from the following functions (): OS_rmfs, OS_mount, OS_unmount, OS_FS_GetPhysDriveName
- Wraps OS_ShMem* prototype and unit test wrapper additions in OSAL_OMIT_DEPRECATED
- Minor updates (see https://github.com/nasa/osal/pull/408)
- 5.0.10: DEVELOPMENT
Expand Down
19 changes: 10 additions & 9 deletions src/os/inc/osapi-os-filesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,20 @@
#define OS_FS_ERR_DEVICE_NOT_FREE (-107) /**< @brief FS device not free */
#define OS_FS_ERR_PATH_INVALID (-108) /**< @brief FS path invalid */


#ifndef OSAL_OMIT_DEPRECATED
/*
* Map some codes used by the file API back to the generic counterparts
* where there is overlap between them. Do not duplicate error codes.
*/
#define OS_FS_SUCCESS OS_SUCCESS /**< @brief Successful execution */
#define OS_FS_ERROR OS_ERROR /**< @brief Failed execution */
#define OS_FS_ERR_INVALID_POINTER OS_INVALID_POINTER /**< @brief Invalid pointer */
#define OS_FS_ERR_NO_FREE_FDS OS_ERR_NO_FREE_IDS /**< @brief No free IDs */
#define OS_FS_ERR_INVALID_FD OS_ERR_INVALID_ID /**< @brief Invalid ID */
#define OS_FS_UNIMPLEMENTED OS_ERR_NOT_IMPLEMENTED /**< @brief Not implemented */
/**@}*/
#define OS_FS_SUCCESS OS_SUCCESS /**< @deprecated Successful execution */
#define OS_FS_ERROR OS_ERROR /**< @deprecated Failed execution */
#define OS_FS_ERR_INVALID_POINTER OS_INVALID_POINTER /**< @deprecated Invalid pointer */
#define OS_FS_ERR_NO_FREE_FDS OS_ERR_NO_FREE_IDS /**< @deprecated No free IDs */
#define OS_FS_ERR_INVALID_FD OS_ERR_INVALID_ID /**< @deprecated Invalid ID */
#define OS_FS_UNIMPLEMENTED OS_ERR_NOT_IMPLEMENTED /**< @deprecated Not implemented */
#endif

/**@}*/

/* This typedef is for OS_FS_GetErrorName(), to ensure
* everyone is making an array of the same length
Expand Down Expand Up @@ -775,7 +776,7 @@ int32 OS_FileSysAddFixedMap(uint32 *filesys_id, const char *phys_path,
* @retval #OS_INVALID_POINTER if devname is NULL
* @retval #OS_FS_ERR_DRIVE_NOT_CREATED if the OS calls to create the the drive failed
* @retval #OS_FS_ERR_DEVICE_NOT_FREE if the volume table is full
* @retval #OS_FS_SUCCESS on creating the disk
* @retval #OS_SUCCESS on creating the disk
*/
int32 OS_mkfs (char *address, const char *devname, const char *volname,
uint32 blocksize, uint32 numblocks);
Expand Down
22 changes: 11 additions & 11 deletions src/os/portable/os-impl-posix-dirs.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ int32 OS_DirCreate_Impl(const char *local_path, uint32 access)

if ( mkdir(local_path, S_IFDIR |S_IRWXU | S_IRWXG | S_IRWXO) < 0 )
{
return_code = OS_FS_ERROR;
return_code = OS_ERROR;

if (errno == EEXIST)
{
/* it exists, but not necessarily a directory */
if ( stat(local_path, &st) == 0 && S_ISDIR(st.st_mode) )
{
return_code = OS_FS_SUCCESS;
return_code = OS_SUCCESS;
}
}
}
else
{
return_code = OS_FS_SUCCESS;
return_code = OS_SUCCESS;
}

return return_code;
Expand All @@ -86,9 +86,9 @@ int32 OS_DirOpen_Impl(uint32 local_id, const char *local_path)
OS_impl_dir_table[local_id] = opendir(local_path);
if (OS_impl_dir_table[local_id] == NULL)
{
return OS_FS_ERROR;
return OS_ERROR;
}
return OS_FS_SUCCESS;
return OS_SUCCESS;
} /* end OS_DirOpen_Impl */

/*----------------------------------------------------------------
Expand All @@ -103,7 +103,7 @@ int32 OS_DirClose_Impl(uint32 local_id)
{
closedir(OS_impl_dir_table[local_id]);
OS_impl_dir_table[local_id] = NULL;
return OS_FS_SUCCESS;
return OS_SUCCESS;
} /* end OS_DirClose_Impl */

/*----------------------------------------------------------------
Expand All @@ -130,13 +130,13 @@ int32 OS_DirRead_Impl(uint32 local_id, os_dirent_t *dirent)
de = readdir(OS_impl_dir_table[local_id]);
if (de == NULL)
{
return OS_FS_ERROR;
return OS_ERROR;
}

strncpy(dirent->FileName, de->d_name, OS_MAX_PATH_LEN - 1);
dirent->FileName[OS_MAX_PATH_LEN - 1] = 0;

return OS_FS_SUCCESS;
return OS_SUCCESS;
} /* end OS_DirRead_Impl */

/*----------------------------------------------------------------
Expand All @@ -150,7 +150,7 @@ int32 OS_DirRead_Impl(uint32 local_id, os_dirent_t *dirent)
int32 OS_DirRewind_Impl(uint32 local_id)
{
rewinddir(OS_impl_dir_table[local_id]);
return OS_FS_SUCCESS;
return OS_SUCCESS;
} /* end OS_DirRewind_Impl */

/*----------------------------------------------------------------
Expand All @@ -165,8 +165,8 @@ int32 OS_DirRemove_Impl(const char *local_path)
{
if ( rmdir(local_path) < 0 )
{
return OS_FS_ERROR;
return OS_ERROR;
}

return OS_FS_SUCCESS;
return OS_SUCCESS;
} /* end OS_DirRemove_Impl */
14 changes: 7 additions & 7 deletions src/os/portable/os-impl-posix-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int
os_perm = O_RDWR;
break;
default:
return OS_FS_ERROR;
return OS_ERROR;
}

if (flags & OS_FILE_FLAG_CREATE)
Expand All @@ -88,7 +88,7 @@ int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int
if (OS_impl_filehandle_table[local_id].fd < 0)
{
OS_DEBUG("open(%s): %s\n", local_path, strerror(errno));
return OS_FS_ERROR;
return OS_ERROR;
}

/*
Expand All @@ -98,7 +98,7 @@ int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int
OS_impl_filehandle_table[local_id].selectable =
((os_perm & O_NONBLOCK) != 0);

return OS_FS_SUCCESS;
return OS_SUCCESS;
} /* end OS_FileOpen_Impl */

/*----------------------------------------------------------------
Expand All @@ -118,7 +118,7 @@ int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *FileStats)

if ( stat(local_path, &st) < 0 )
{
return OS_FS_ERROR;
return OS_ERROR;
}

FileStats->FileSize = st.st_size;
Expand Down Expand Up @@ -164,7 +164,7 @@ int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *FileStats)
FileStats->FileModeBits |= OS_FILESTAT_MODE_EXEC;
}

return OS_FS_SUCCESS;
return OS_SUCCESS;
} /* end OS_FileStat_Impl */


Expand Down Expand Up @@ -193,7 +193,7 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
*/
if ( stat(local_path, &st) < 0 )
{
return OS_FS_ERROR;
return OS_ERROR;
}

/* always check world bits */
Expand Down Expand Up @@ -239,7 +239,7 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
/* finally, write the modified mode back to the file */
if ( chmod(local_path, st.st_mode) < 0 )
{
return OS_FS_ERROR;
return OS_ERROR;
}

return OS_SUCCESS;
Expand Down
8 changes: 4 additions & 4 deletions src/os/portable/os-impl-posix-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int32 OS_GenericClose_Impl(uint32 local_id)
OS_DEBUG("close: %s\n",strerror(errno));
}
OS_impl_filehandle_table[local_id].fd = -1;
return OS_FS_SUCCESS;
return OS_SUCCESS;
} /* end OS_GenericClose_Impl */

/*----------------------------------------------------------------
Expand Down Expand Up @@ -96,7 +96,7 @@ int32 OS_GenericSeek_Impl (uint32 local_id, int32 offset, uint32 whence)
where = SEEK_END;
break;
default:
return OS_FS_ERROR;
return OS_ERROR;
}

result = lseek(OS_impl_filehandle_table[local_id].fd, (off_t)offset, where);
Expand All @@ -111,15 +111,15 @@ int32 OS_GenericSeek_Impl (uint32 local_id, int32 offset, uint32 whence)
* Use a different error code to differentiate from an
* error involving a bad whence/offset
*/
result = OS_FS_UNIMPLEMENTED;
result = OS_ERR_NOT_IMPLEMENTED;
}
else
{
/*
* Most likely the "whence" and/or "offset" combo was not valid.
*/
OS_DEBUG("lseek: %s\n",strerror(errno));
result = OS_FS_ERROR;
result = OS_ERROR;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/os/posix/osfilesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id)
}


return OS_FS_SUCCESS;
return OS_SUCCESS;

} /* end OS_FileSysMountVolume_Impl */

Expand All @@ -281,7 +281,7 @@ int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id)
* This is a no-op. The mount point that was created during
* the mount process can stay for the next mount.
*/
return OS_FS_SUCCESS;
return OS_SUCCESS;

} /* end OS_FileSysUnmountVolume_Impl */

Expand All @@ -307,7 +307,7 @@ int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result)
result->blocks_free = stat_buf.f_bfree;
result->total_blocks = stat_buf.f_blocks;

return(OS_FS_SUCCESS);
return(OS_SUCCESS);
} /* end OS_FileSysStatVolume_Impl */


Expand Down
2 changes: 1 addition & 1 deletion src/os/rtems/osfileapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char *Cmd)

if (Result != 0)
{
return OS_FS_ERROR;
return OS_ERROR;
}
return OS_SUCCESS;
} /* end OS_ShellOutputToFile_Impl */
Expand Down
12 changes: 6 additions & 6 deletions src/os/rtems/osfilesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id)
OS_DEBUG("OSAL: Error: RAM disk too large, %lu blocks requested, %lu available.\n",
(unsigned long)local->numblocks,
(unsigned long)rtems_ramdisk_configuration[os_idx].block_num);
return_code = OS_FS_ERROR;
return_code = OS_ERROR;
break;
}
if ( local->blocksize != rtems_ramdisk_configuration[os_idx].block_size )
{
OS_DEBUG("OSAL: Error: RAM Disk needs a block size of %lu.\n",
(unsigned long)rtems_ramdisk_configuration[os_idx].block_size);
return_code = OS_FS_ERROR;
return_code = OS_ERROR;
break;
}

Expand Down Expand Up @@ -326,7 +326,7 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id)
{
OS_DEBUG("OSAL: Error: mount of %s to %s failed: %s\n",
impl->blockdev_name, local->system_mountpt, strerror(errno));
return OS_FS_ERROR;
return OS_ERROR;
}

return OS_SUCCESS;
Expand All @@ -352,7 +352,7 @@ int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id)
if ( unmount(local->system_mountpt) < 0)
{
OS_DEBUG("OSAL: RTEMS unmount of %s failed :%s\n",local->system_mountpt, strerror(errno));
return OS_FS_ERROR;
return OS_ERROR;
}

return OS_SUCCESS;
Expand All @@ -375,14 +375,14 @@ int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result)

if ( statvfs(local->system_mountpt, &stat_buf) != 0 )
{
return OS_FS_ERROR;
return OS_ERROR;
}

result->block_size = stat_buf.f_bsize;
result->blocks_free = stat_buf.f_bfree;
result->total_blocks = stat_buf.f_blocks;

return(OS_FS_SUCCESS);
return(OS_SUCCESS);
} /* end OS_FileSysStatVolume_Impl */


Expand Down
10 changes: 5 additions & 5 deletions src/os/shared/osapi-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int32 OS_mkdir (const char *path, uint32 access)
char local_path[OS_MAX_LOCAL_PATH_LEN];

return_code = OS_TranslatePath(path, local_path);
if (return_code == OS_FS_SUCCESS)
if (return_code == OS_SUCCESS)
{
return_code = OS_DirCreate_Impl(local_path, access);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ int32 OS_DirectoryOpen(uint32 *dir_id, const char *path)
}

return_code = OS_TranslatePath(path, local_path);
if (return_code == OS_FS_SUCCESS)
if (return_code == OS_SUCCESS)
{
/* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */
return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, NULL, &local_id, &record);
Expand Down Expand Up @@ -209,7 +209,7 @@ int32 OS_DirectoryRead(uint32 dir_id, os_dirent_t *dirent)

if (dirent == NULL)
{
return OS_FS_ERR_INVALID_POINTER;
return OS_INVALID_POINTER;
}

/* Make sure the file descriptor is legit before using it */
Expand Down Expand Up @@ -275,7 +275,7 @@ int32 OS_rmdir (const char *path)
char local_path [OS_MAX_LOCAL_PATH_LEN];

return_code = OS_TranslatePath(path, local_path);
if (return_code == OS_FS_SUCCESS)
if (return_code == OS_SUCCESS)
{
OS_DirRemove_Impl(local_path);
}
Expand Down Expand Up @@ -320,7 +320,7 @@ int32 OS_closedir (os_dirp_t directory)

if (directory == NULL)
{
return OS_FS_ERR_INVALID_POINTER;
return OS_INVALID_POINTER;
}
dirdescptr.dirp = directory;

Expand Down
Loading

0 comments on commit 78f4aba

Please sign in to comment.