Added tests for global state stealing

State stealing is a tricky part of managing the xored-globals. When
removing a metadata-pair from the metadata chain, whichever
metadata-pair does the removing is also responsible for stealing the
removed metadata-pair's global delta and incorporating it into it's own
global delta. Otherwise the global state would become corrupted.
This commit is contained in:
Christopher Haster
2018-08-04 18:55:04 -05:00
parent 1941bbda76
commit f369f80540
2 changed files with 46 additions and 2 deletions

2
lfs.c
View File

@@ -2513,7 +2513,6 @@ int lfs_remove(lfs_t *lfs, const char *path) {
lfs_globaldeorphaned(lfs, true);
// steal state
// TODO test for global state stealing?
cwd.tail[0] = dir.tail[0];
cwd.tail[1] = dir.tail[1];
lfs_globalxor(&lfs->locals, &dir.locals);
@@ -2626,7 +2625,6 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
lfs_globaldeorphaned(lfs, true);
// steal state
// TODO test for global state stealing?
newcwd.tail[0] = prevdir.tail[0];
newcwd.tail[1] = prevdir.tail[1];
lfs_globalxor(&lfs->locals, &prevdir.locals);