FatFs: Apply patch ff_12c_p2.diff.

This commit is contained in:
Jared Boone 2017-05-03 12:52:59 +01:00
parent fd8f5e62e1
commit dfc1eab4ae

View File

@ -1332,8 +1332,22 @@ FRESULT remove_chain ( /* FR_OK(0):succeeded, !=0:error */
if (pclst == 0) { /* Does the object have no chain? */
obj->stat = 0; /* Change the object status 'initial' */
} else {
if (obj->stat == 3 && pclst >= obj->sclust && pclst <= obj->sclust + obj->n_cont) { /* Did the chain get contiguous? */
obj->stat = 2; /* Change the object status 'contiguous' */
if (obj->stat == 0) { /* Is it a fragmented chain from the beginning of this session? */
clst = obj->sclust; /* Follow the chain to check if it gets contiguous */
while (clst != pclst) {
nxt = get_fat(obj, clst);
if (nxt < 2) return FR_INT_ERR;
if (nxt == 0xFFFFFFFF) return FR_DISK_ERR;
if (nxt != clst + 1) break; /* Not contiguous? */
clst++;
}
if (clst == pclst) { /* Has the chain got contiguous again? */
obj->stat = 2; /* Change the chain status 'contiguous' */
}
} else {
if (obj->stat == 3 && pclst >= obj->sclust && pclst <= obj->sclust + obj->n_cont) { /* Was the chain fragmented in this session and got contiguous again? */
obj->stat = 2; /* Change the chain status 'contiguous' */
}
}
}
}