Add validation checking when redo delete [Description] N/A [Module] FS [Board] all [Verification] [Reference] N/A [Author] tj80.kwon
@@ -2690,16 +2690,32 @@ static int smartfs_redo_write(struct smartfs_mountpt_s *fs)
****************************************************************************/
static int smartfs_redo_delete(struct smartfs_mountpt_s *fs)
{
+ int ret;
struct smartfs_entry_s direntry;
struct smartfs_logging_entry_s *entry;
+ struct smart_read_write_s readwrite;
+ struct smartfs_entry_header_s entryread;
entry = (struct smartfs_logging_entry_s *)(fs->journal->buffer);
+
+ readwrite.logsector = entry->curr_sector;
+ readwrite.offset = entry->offset;
+ readwrite.count = sizeof(struct smartfs_entry_header_s);
+ readwrite.buffer = (uint8_t *)&entryread;
+ ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite);
+ if (ret < 0) {
+ return OK;
+ }
+ if (ENTRY_VALID(&entryread)) {
direntry.dsector = entry->curr_sector;
direntry.doffset = entry->offset;
direntry.dfirst = entry->datalen;
direntry.firstsector = entry->generic_1;
smartfs_deleteentry(fs, &direntry);
+ } else {
+ fdbg("No redo delete required\n");
+ }
return OK;
}
