Update Reliance Edge fail safe file system to the latest version.

This commit is contained in:
Richard Barry 2017-01-24 00:20:35 +00:00
parent 8d041c8e21
commit 67def3c14b
30 changed files with 5877 additions and 5544 deletions

View file

@ -65,7 +65,7 @@ VOLUME * CONST_IF_ONE_VOLUME gpRedVolume = &gaRedVolume[0U];
COREVOLUME * CONST_IF_ONE_VOLUME gpRedCoreVol = &gaCoreVol[0U];
METAROOT *gpRedMR = &gaCoreVol[0U].aMR[0U];
CONST_IF_ONE_VOLUME uint8_t gbRedVolNum;
CONST_IF_ONE_VOLUME uint8_t gbRedVolNum = 0;
/** @brief Initialize the Reliance Edge file system driver.
@ -1235,7 +1235,7 @@ REDSTATUS RedCoreLookup(
@param pszSrcName The name of the file or directory to rename.
@param ulDstPInode The new parent directory inode number of the file or
directory after the rename.
@param pszNewPath The new name of the file or directory after the rename.
@param pszDstName The new name of the file or directory after the rename.
@return A negated ::REDSTATUS code indicating the operation result.
@ -1314,7 +1314,7 @@ REDSTATUS RedCoreRename(
@param pszSrcName The name of the file or directory to rename.
@param ulDstPInode The new parent directory inode number of the file or
directory after the rename.
@param pszNewPath The new name of the file or directory after the rename.
@param pszDstName The new name of the file or directory after the rename.
@return A negated ::REDSTATUS code indicating the operation result.

View file

@ -199,21 +199,23 @@ REDSTATUS RedDirEntryDelete(
}
else if((DirEntryIndexToOffset(ulDeleteIdx) + DIRENT_SIZE) == pPInode->pInodeBuf->ullSize)
{
uint32_t ulTruncIdx = ulDeleteIdx;
/* Start searching one behind the index to be deleted.
*/
uint32_t ulTruncIdx = ulDeleteIdx - 1U;
bool fDone = false;
/* We are deleting the last dirent in the directory, so search
backwards to find the last populated dirent, allowing us to truncate
the directory to that point.
*/
while((ret == 0) && (ulTruncIdx > 0U) && !fDone)
while((ret == 0) && (ulTruncIdx != UINT32_MAX) && !fDone)
{
ret = RedInodeDataSeekAndRead(pPInode, ulTruncIdx / DIRENTS_PER_BLOCK);
if(ret == 0)
{
const DIRENT *pDirents = CAST_CONST_DIRENT_PTR(pPInode->pbData);
uint32_t ulBlockIdx = (ulTruncIdx - 1U) % DIRENTS_PER_BLOCK;
uint32_t ulBlockIdx = ulTruncIdx % DIRENTS_PER_BLOCK;
do
{
@ -242,6 +244,12 @@ REDSTATUS RedDirEntryDelete(
}
}
/* Currently ulTruncIdx represents the last valid dirent index, or
UINT32_MAX if the directory is now empty. Increment it so that it
represents the first invalid entry, which will be truncated.
*/
ulTruncIdx++;
/* Truncate the directory, deleting the requested entry and any empty
dirents at the end of the directory.
*/
@ -449,7 +457,7 @@ REDSTATUS RedDirEntryLookup(
#if (REDCONF_API_POSIX_READDIR == 1) || (REDCONF_CHECKER == 1)
/** @brief Read the next entry from a directory, given a starting index.
@param pInode A pointer to the cached inode structure of the directory to
@param pPInode A pointer to the cached inode structure of the directory to
read from.
@param pulIdx On entry, the directory index to start reading from. On
successful return, populated with the directory index to use

View file

@ -158,6 +158,7 @@ REDSTATUS RedImapBlockSet(
}
/* Adjust the free/almost free block count if the block was allocable.
Discard the block if required.
*/
if((ret == 0) && (ulBlock >= gpRedCoreVol->ulFirstAllocableBN))
{

View file

@ -63,6 +63,10 @@ REDSTATUS RedVolMount(void)
if(ret != 0)
{
/* If we fail to mount, invalidate the buffers to prevent any
confusion that could be caused by stale or corrupt metadata.
*/
(void)RedBufferDiscardRange(0U, gpRedVolume->ulBlockCount);
(void)RedOsBDevClose(gbRedVolNum);
}
}