Skip to content

Commit

Permalink
Make it so mark_written has to be used
Browse files Browse the repository at this point in the history
Make it so mark_written has to be used
  • Loading branch information
AliceGrey authored and jwise committed Mar 18, 2020
1 parent 7cf2a61 commit 7eb0d27
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/neographics
2 changes: 0 additions & 2 deletions rcore/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,6 @@ struct fd *fs_creat_replacing(struct fd *fd, const char *name, size_t bytes, con
filehdr.flag_2 &= ~HDR_FLAG_2_HAS_FILENAME;
assert(strlen(name) < MAX_FILENAME_LEN);
filehdr.filename_len = strlen(name);
if (!previous)
filehdr.st_tmp_file = 0x0;

int rv = _fs_write_page_ofs(pg, 0, &filehdr, sizeof(filehdr));
assert(rv >= 0);
Expand Down
15 changes: 9 additions & 6 deletions rcore/fs_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ TEST(fs_two_files) {
fdp = fs_creat(&fd1, "hello", 5);
if (!fdp) { *artifact = 1; return TEST_FAIL; }
fs_write(&fd1, "Hello", 5);
fs_mark_written(fdp);

fdp = fs_creat(&fd2, "world", 5);
if (!fdp) { *artifact = 2; return TEST_FAIL; }
fs_write(&fd2, "World", 5);
fs_mark_written(fdp);

char buf[5];

Expand Down Expand Up @@ -89,8 +91,9 @@ TEST(fs_replace_file_basic) {

//create a file with contents a
fdp = fs_creat(&fd, "hello", 5);
if (!fdp) { *artifact = 1; return TEST_FAIL; }
fs_write(&fd, "Hello", 5);
if (!fdp) { *artifact = 1; return TEST_FAIL; }
fs_write(&fd, "Hello", 5);
fs_mark_written(fdp);

//create a file replacing that file with contents B
rv = fs_find_file(&file, "hello");
Expand All @@ -113,11 +116,11 @@ TEST(fs_replace_file_basic) {

//open the file for read and make sure you get contents B;
rv = fs_find_file(&file, "hello");
if (rv < 0) { *artifact = 5; return TEST_FAIL; }
if (rv < 0) { *artifact = 5; return TEST_FAIL; }

fs_open(&fd, &file);
rv = fs_read(&fd, buf, 5);
if (memcmp(buf, "World", 5)) { *artifact = 6; return TEST_FAIL; }
fs_open(&fd, &file);
rv = fs_read(&fd, buf, 5);
if (memcmp(buf, "World", 5)) { *artifact = 6; return TEST_FAIL; }

*artifact = 0;
return TEST_PASS;
Expand Down
1 change: 1 addition & 0 deletions rcore/service/blob_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ uint8_t blobdb_insert(uint16_t database_id, uint8_t *key, uint16_t key_size, uin
LOG_ERROR("nope, that did not work either, I give up");
return Blob_DatabaseFull;
}
fs_mark_written(&fd);
}

int pos = 0;
Expand Down

0 comments on commit 7eb0d27

Please sign in to comment.