os/fs/smartfs : Apply basic recovery logic of SMART_JOURNAL_TYPE_RELEASE
1. Add basic recovery logic
@@ -5428,6 +5428,8 @@ static int smart_journal_recovery(FAR struct smart_struct_s *dev, journal_log_t
{
int ret;
int type;
+ uint8_t status;
+ size_t offset;
uint32_t address = smart_journal_get_writeaddress(dev);
fvdbg("Printf recovery data journal_seq : %d!!\n", dev->journal_seq);
@@ -5444,13 +5446,26 @@ static int smart_journal_recovery(FAR struct smart_struct_s *dev, journal_log_t
return -EINVAL;
}
+ fvdbg("address : %u\n", address);
type = GET_JOURNAL_TYPE(log->status);
/* TODO Recovery Logic Will be added, after recovery we should update dev structure too(cf.freecount) */
switch (type) {
case SMART_JOURNAL_TYPE_COMMIT:
+
break;
case SMART_JOURNAL_TYPE_RELEASE:
+#if CONFIG_SMARTFS_ERASEDSTATE == 0xFF
+ status &= ~SMART_STATUS_RELEASED;
+#else
+ status |= SMART_STATUS_RELEASED;
+#endif
+ offset = UINT8TOUINT16(log->psector) * dev->sectorsize + offsetof(struct smart_sect_header_s, status);
+ ret = MTD_WRITE(dev->mtd, offset, 1, &status);
+ if (ret < 0) {
+ fdbg("Error %d releasing duplicate sector\n", -ret);
+ return -EIO;
+ }
break;
case SMART_JOURNAL_TYPE_ERASE:
