updated api, fixed tests, fixed test config

This commit is contained in:
Peter Andersson
2013-07-31 23:32:26 +02:00
parent 4d01fd24a0
commit bee35895c3
9 changed files with 81 additions and 81 deletions
+3 -3
View File
@@ -112,9 +112,9 @@
// spiffs file descriptor index type
typedef s16_t spiffs_file;
// spiffs file descriptor attributes
typedef u32_t spiffs_attr;
// spiffs file descriptor mode
// spiffs file descriptor flags
typedef u32_t spiffs_flags;
// spiffs file mode
typedef u32_t spiffs_mode;
// block index type
+5 -5
View File
@@ -251,20 +251,20 @@ void SPIFFS_unmount(spiffs *fs);
* Creates a new file.
* @param fs the file system struct
* @param path the path of the new file
* @param attr ignored, for posix compliance
* @param mode ignored, for posix compliance
*/
s32_t SPIFFS_creat(spiffs *fs, const char *path, spiffs_attr attr);
s32_t SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode mode);
/**
* Opens/creates a file.
* @param fs the file system struct
* @param path the path of the new file
* @param attr ignored, for posix compliance
* @param mode the mode for the open command, can be combinations of
* @param flags the flags for the open command, can be combinations of
* SPIFFS_APPEND, SPIFFS_TRUNC, SPIFFS_CREAT, SPIFFS_RD_ONLY,
* SPIFFS_WR_ONLY, SPIFFS_RDWR, SPIFFS_DIRECT
* @param mode ignored, for posix compliance
*/
spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_attr attr, spiffs_mode mode);
spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_flags flags, spiffs_mode mode);
/**
* Reads from given filehandle.
+13 -13
View File
@@ -94,7 +94,7 @@ s32_t SPIFFS_errno(spiffs *fs) {
return fs->errno;
}
s32_t SPIFFS_creat(spiffs *fs, const char *path, spiffs_attr attr) {
s32_t SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode mode) {
SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs);
spiffs_obj_id obj_id;
@@ -108,7 +108,7 @@ s32_t SPIFFS_creat(spiffs *fs, const char *path, spiffs_attr attr) {
return 0;
}
spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_attr attr, spiffs_mode mode) {
spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_flags flags, spiffs_mode mode) {
SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs);
@@ -119,14 +119,14 @@ spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_attr attr, spiffs_m
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
res = spiffs_object_find_object_index_header_by_name(fs, (u8_t*)path, &pix);
if ((mode & SPIFFS_CREAT) == 0) {
if ((flags & SPIFFS_CREAT) == 0) {
if (res < SPIFFS_OK) {
spiffs_fd_return(fs, fd->file_nbr);
}
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
}
if ((mode & SPIFFS_CREAT) && res == SPIFFS_ERR_NOT_FOUND) {
if ((flags & SPIFFS_CREAT) && res == SPIFFS_ERR_NOT_FOUND) {
spiffs_obj_id obj_id;
res = spiffs_obj_lu_find_free_obj_id(fs, &obj_id);
if (res < SPIFFS_OK) {
@@ -138,19 +138,19 @@ spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_attr attr, spiffs_m
spiffs_fd_return(fs, fd->file_nbr);
}
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
mode &= ~SPIFFS_TRUNC;
flags &= ~SPIFFS_TRUNC;
} else {
if (res < SPIFFS_OK) {
spiffs_fd_return(fs, fd->file_nbr);
}
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
}
res = spiffs_object_open_by_page(fs, pix, fd, attr, mode);
res = spiffs_object_open_by_page(fs, pix, fd, flags, flags);
if (res < SPIFFS_OK) {
spiffs_fd_return(fs, fd->file_nbr);
}
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
if (mode & SPIFFS_TRUNC) {
if (flags & SPIFFS_TRUNC) {
res = spiffs_object_truncate(fd, 0, 0);
if (res < SPIFFS_OK) {
spiffs_fd_return(fs, fd->file_nbr);
@@ -175,7 +175,7 @@ s32_t SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, s32_t len) {
res = spiffs_fd_get(fs, fh, &fd);
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
if ((fd->mode & SPIFFS_RDONLY) == 0) {
if ((fd->flags & SPIFFS_RDONLY) == 0) {
res = SPIFFS_ERR_NOT_READABLE;
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
}
@@ -240,7 +240,7 @@ s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len) {
res = spiffs_fd_get(fs, fh, &fd);
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
if ((fd->mode & SPIFFS_WRONLY) == 0) {
if ((fd->flags & SPIFFS_WRONLY) == 0) {
res = SPIFFS_ERR_NOT_WRITABLE;
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
}
@@ -253,7 +253,7 @@ s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len) {
fd->cache_page = spiffs_cache_page_get_by_fd(fs, fd);
}
#endif
if (fd->mode & SPIFFS_APPEND) {
if (fd->flags & SPIFFS_APPEND) {
if (fd->size == SPIFFS_UNDEFINED_LEN) {
offset = 0;
} else {
@@ -269,7 +269,7 @@ s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len) {
SPIFFS_DBG("SPIFFS_write %i %04x offs:%i len %i\n", fh, fd->obj_id, offset, len);
#if SPIFFS_CACHE_WR
if ((fd->mode & SPIFFS_DIRECT) == 0) {
if ((fd->flags & SPIFFS_DIRECT) == 0) {
if (len < SPIFFS_CFG_LOG_PAGE_SZ(fs)) {
// small write, try to cache it
u8_t alloc_cpage = 1;
@@ -433,7 +433,7 @@ s32_t SPIFFS_fremove(spiffs *fs, spiffs_file fh) {
res = spiffs_fd_get(fs, fh, &fd);
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
if ((fd->mode & SPIFFS_WRONLY) == 0) {
if ((fd->flags & SPIFFS_WRONLY) == 0) {
res = SPIFFS_ERR_NOT_WRITABLE;
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
}
@@ -520,7 +520,7 @@ static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh) {
res = spiffs_fd_get(fs, fh, &fd);
SPIFFS_API_CHECK_RES(fs, res);
if ((fd->mode & SPIFFS_DIRECT) == 0) {
if ((fd->flags & SPIFFS_DIRECT) == 0) {
if (fd->cache_page == 0) {
// see if object id is associated with cache already
fd->cache_page = spiffs_cache_page_get_by_fd(fs, fd);
+4 -4
View File
@@ -749,7 +749,7 @@ s32_t spiffs_object_open_by_id(
spiffs *fs,
spiffs_obj_id obj_id,
spiffs_fd *fd,
spiffs_attr attr,
spiffs_flags flags,
spiffs_mode mode) {
s32_t res = SPIFFS_OK;
spiffs_page_ix pix;
@@ -757,7 +757,7 @@ s32_t spiffs_object_open_by_id(
res = spiffs_obj_lu_find_id_and_span(fs, obj_id | SPIFFS_OBJ_ID_IX_FLAG, 0, 0, &pix);
SPIFFS_CHECK_RES(res);
res = spiffs_object_open_by_page(fs, pix, fd, attr, mode);
res = spiffs_object_open_by_page(fs, pix, fd, flags, mode);
return res;
}
@@ -767,7 +767,7 @@ s32_t spiffs_object_open_by_page(
spiffs *fs,
spiffs_page_ix pix,
spiffs_fd *fd,
spiffs_attr attr,
spiffs_flags flags,
spiffs_mode mode) {
s32_t res = SPIFFS_OK;
spiffs_page_object_ix_header oix_hdr;
@@ -790,7 +790,7 @@ s32_t spiffs_object_open_by_page(
fd->cursor_objix_pix = pix;
fd->cursor_objix_spix = 0;
fd->obj_id = obj_id;
fd->mode = mode;
fd->flags = flags;
SPIFFS_VALIDATE_OBJIX(oix_hdr.p_hdr, fd->obj_id, 0);
+4 -4
View File
@@ -370,8 +370,8 @@ typedef struct {
u32_t offset;
// current file descriptor offset
u32_t fdoffset;
// mode
spiffs_mode mode;
// fd flags
spiffs_flags flags;
#if SPIFFS_CACHE_WR
spiffs_cache_page *cache_page;
#endif
@@ -573,14 +573,14 @@ s32_t spiffs_object_open_by_id(
spiffs *fs,
spiffs_obj_id obj_id,
spiffs_fd *f,
spiffs_attr attr,
spiffs_flags flags,
spiffs_mode mode);
s32_t spiffs_object_open_by_page(
spiffs *fs,
spiffs_page_ix pix,
spiffs_fd *f,
spiffs_attr attr,
spiffs_flags flags,
spiffs_mode mode);
s32_t spiffs_object_append(
+3 -3
View File
@@ -10,10 +10,10 @@
#define FLASH_SIZE 2*1024*1024
#define SECTOR_SIZE 65536
#define LOG_BLOCK 65536
#define LOG_PAGE 256
#define LOG_BLOCK SECTOR_SIZE*2
#define LOG_PAGE SECTOR_SIZE/256
#define FD_BUF_SIZE 32*6
#define FD_BUF_SIZE 64*6
#define CACHE_BUF_SIZE (LOG_PAGE + 32)*8
#define ASSERT(c, m) real_assert((c),(m), __FILE__, __LINE__);
+9 -9
View File
@@ -60,7 +60,7 @@ TEST(lu_check1) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -97,7 +97,7 @@ TEST(page_cons1) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -137,7 +137,7 @@ TEST(page_cons2) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -183,7 +183,7 @@ TEST(page_cons3) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -223,7 +223,7 @@ TEST(page_cons_final) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -264,7 +264,7 @@ TEST(index_cons1) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -305,7 +305,7 @@ TEST(index_cons2) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -345,7 +345,7 @@ TEST(index_cons3) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -385,7 +385,7 @@ TEST(index_cons4) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
+39 -39
View File
@@ -45,7 +45,7 @@ int test_create_file(char *name) {
spiffs_file fd;
int res = SPIFFS_creat(FS, name, 0);
CHECK_RES(res);
fd = SPIFFS_open(FS, name, 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, name, SPIFFS_RDONLY, 0);
CHECK(fd >= 0);
res = SPIFFS_fstat(FS, fd, &s);
CHECK_RES(res);
@@ -64,7 +64,7 @@ int test_create_and_write_file(char *name, int size, int chunk_size) {
printf(" failed creation, %i\n",res);
}
CHECK(res >= 0);
fd = SPIFFS_open(FS, name, 0, SPIFFS_APPEND | SPIFFS_RDWR);
fd = SPIFFS_open(FS, name, SPIFFS_APPEND | SPIFFS_RDWR, 0);
if (res < 0) {
printf(" failed open, %i\n",res);
}
@@ -218,12 +218,12 @@ int run_file_config(int cfg_count, tfile_conf* cfgs, int max_runs, int max_concu
int pfd = open(make_test_fname(name), O_TRUNC | O_CREAT | O_RDWR);
close(pfd);
int extra_flags = tf->cfg.ttype == APPENDED ? SPIFFS_APPEND : 0;
spiffs_file fd = SPIFFS_open(FS, name, 0, extra_flags | SPIFFS_RDWR);
spiffs_file fd = SPIFFS_open(FS, name, extra_flags | SPIFFS_RDWR, 0);
CHECK(fd > 0);
tf->fd = fd;
} else {
int extra_flags = tf->cfg.ttype == APPENDED ? SPIFFS_APPEND : 0;
spiffs_file fd = SPIFFS_open(FS, name, 0, extra_flags | SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR);
spiffs_file fd = SPIFFS_open(FS, name, extra_flags | SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR, 0);
CHECK(fd > 0);
extra_flags = tf->cfg.ttype == APPENDED ? O_APPEND : 0;
int pfd = open(make_test_fname(name), extra_flags | O_TRUNC | O_CREAT | O_RDWR);
@@ -289,7 +289,7 @@ int run_file_config(int cfg_count, tfile_conf* cfgs, int max_runs, int max_concu
SPIFFS_close(FS, tf->fd);
}
if (dbg) printf(" rewriting %s\n", tf->name);
spiffs_file fd = SPIFFS_open(FS, tf->name, 0, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR);
spiffs_file fd = SPIFFS_open(FS, tf->name, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR, 0);
CHECK(fd > 0);
int pfd = open(make_test_fname(tf->name), O_TRUNC | O_CREAT | O_RDWR);
tf->fd = fd;
@@ -344,7 +344,7 @@ void teardown() {
TEST(missing_file)
{
spiffs_file fd = SPIFFS_open(FS, "this_wont_exist", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "this_wont_exist", SPIFFS_RDONLY, 0);
TEST_CHECK(fd < 0);
return TEST_RES_OK;
}
@@ -355,7 +355,7 @@ TEST(bad_fd)
{
int res;
spiffs_stat s;
spiffs_file fd = SPIFFS_open(FS, "this_wont_exist", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "this_wont_exist", SPIFFS_RDONLY, 0);
TEST_CHECK(fd < 0);
res = SPIFFS_fstat(FS, fd, &s);
TEST_CHECK(res < 0);
@@ -382,7 +382,7 @@ TEST(closed_fd)
int res;
spiffs_stat s;
res = test_create_file("file");
spiffs_file fd = SPIFFS_open(FS, "file", 0, SPIFFS_RDONLY);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd >= 0);
SPIFFS_close(FS, fd);
@@ -412,9 +412,9 @@ TEST(deleted_same_fd)
spiffs_stat s;
spiffs_file fd;
res = test_create_file("remove");
fd = SPIFFS_open(FS, "remove", 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, "remove", SPIFFS_RDWR, 0);
TEST_CHECK(fd >= 0);
fd = SPIFFS_open(FS, "remove", 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, "remove", SPIFFS_RDWR, 0);
TEST_CHECK(fd >= 0);
res = SPIFFS_fremove(FS, fd);
TEST_CHECK(res >= 0);
@@ -446,9 +446,9 @@ TEST(deleted_other_fd)
spiffs_stat s;
spiffs_file fd, fd_orig;
res = test_create_file("remove");
fd_orig = SPIFFS_open(FS, "remove", 0, SPIFFS_RDONLY);
fd_orig = SPIFFS_open(FS, "remove", SPIFFS_RDWR, 0);
TEST_CHECK(fd_orig >= 0);
fd = SPIFFS_open(FS, "remove", 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, "remove", SPIFFS_RDWR, 0);
TEST_CHECK(fd >= 0);
res = SPIFFS_fremove(FS, fd_orig);
TEST_CHECK(res >= 0);
@@ -479,7 +479,7 @@ TEST(file_by_open)
{
int res;
spiffs_stat s;
spiffs_file fd = SPIFFS_open(FS, "filebopen", 0, SPIFFS_CREAT);
spiffs_file fd = SPIFFS_open(FS, "filebopen", SPIFFS_CREAT, 0);
TEST_CHECK(fd >= 0);
res = SPIFFS_fstat(FS, fd, &s);
TEST_CHECK(res >= 0);
@@ -487,7 +487,7 @@ TEST(file_by_open)
TEST_CHECK(s.size == 0);
SPIFFS_close(FS, fd);
fd = SPIFFS_open(FS, "filebopen", 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, "filebopen", SPIFFS_RDONLY, 0);
TEST_CHECK(fd >= 0);
res = SPIFFS_fstat(FS, fd, &s);
TEST_CHECK(res >= 0);
@@ -548,7 +548,7 @@ TEST(remove_single_by_path)
TEST_CHECK(res >= 0);
res = SPIFFS_remove(FS, "remove");
TEST_CHECK(res >= 0);
fd = SPIFFS_open(FS, "remove", 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, "remove", SPIFFS_RDONLY, 0);
TEST_CHECK(fd < 0);
TEST_CHECK(SPIFFS_errno(FS) == SPIFFS_ERR_NOT_FOUND);
@@ -563,12 +563,12 @@ TEST(remove_single_by_fd)
spiffs_file fd;
res = test_create_file("remove");
TEST_CHECK(res >= 0);
fd = SPIFFS_open(FS, "remove", 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, "remove", SPIFFS_RDWR, 0);
TEST_CHECK(fd >= 0);
res = SPIFFS_fremove(FS, fd);
TEST_CHECK(res >= 0);
SPIFFS_close(FS, fd);
fd = SPIFFS_open(FS, "remove", 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, "remove", SPIFFS_RDONLY, 0);
TEST_CHECK(fd < 0);
TEST_CHECK(SPIFFS_errno(FS) == SPIFFS_ERR_NOT_FOUND);
@@ -699,13 +699,13 @@ TEST(truncate_big_file)
TEST_CHECK(res >= 0);
res = read_and_verify("bigfile");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "bigfile", 0, SPIFFS_RDWR);
spiffs_file fd = SPIFFS_open(FS, "bigfile", SPIFFS_RDWR, 0);
TEST_CHECK(fd > 0);
res = SPIFFS_fremove(FS, fd);
TEST_CHECK(res >= 0);
SPIFFS_close(FS, fd);
fd = SPIFFS_open(FS, "bigfile", 0, SPIFFS_RDWR);
fd = SPIFFS_open(FS, "bigfile", SPIFFS_RDWR, 0);
TEST_CHECK(fd < 0);
TEST_CHECK(SPIFFS_errno(FS) == SPIFFS_ERR_NOT_FOUND);
@@ -718,11 +718,11 @@ TEST(simultaneous_write) {
int res = SPIFFS_creat(FS, "simul1", 0);
TEST_CHECK(res >= 0);
spiffs_file fd1 = SPIFFS_open(FS, "simul1", 0, SPIFFS_RDWR);
spiffs_file fd1 = SPIFFS_open(FS, "simul1", SPIFFS_RDWR, 0);
TEST_CHECK(fd1 > 0);
spiffs_file fd2 = SPIFFS_open(FS, "simul1", 0, SPIFFS_RDWR);
spiffs_file fd2 = SPIFFS_open(FS, "simul1", SPIFFS_RDWR, 0);
TEST_CHECK(fd2 > 0);
spiffs_file fd3 = SPIFFS_open(FS, "simul1", 0, SPIFFS_RDWR);
spiffs_file fd3 = SPIFFS_open(FS, "simul1", SPIFFS_RDWR, 0);
TEST_CHECK(fd3 > 0);
u8_t data1 = 1;
@@ -746,7 +746,7 @@ TEST(simultaneous_write) {
TEST_CHECK(s.size == 1);
u8_t rdata;
spiffs_file fd = SPIFFS_open(FS, "simul1", 0, SPIFFS_RDONLY);
spiffs_file fd = SPIFFS_open(FS, "simul1", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
res = SPIFFS_read(FS, fd, &rdata, 1);
TEST_CHECK(res >= 0);
@@ -762,11 +762,11 @@ TEST(simultaneous_write_append) {
int res = SPIFFS_creat(FS, "simul2", 0);
TEST_CHECK(res >= 0);
spiffs_file fd1 = SPIFFS_open(FS, "simul2", 0, SPIFFS_RDWR | SPIFFS_APPEND);
spiffs_file fd1 = SPIFFS_open(FS, "simul2", SPIFFS_RDWR | SPIFFS_APPEND, 0);
TEST_CHECK(fd1 > 0);
spiffs_file fd2 = SPIFFS_open(FS, "simul2", 0, SPIFFS_RDWR | SPIFFS_APPEND);
spiffs_file fd2 = SPIFFS_open(FS, "simul2", SPIFFS_RDWR | SPIFFS_APPEND, 0);
TEST_CHECK(fd2 > 0);
spiffs_file fd3 = SPIFFS_open(FS, "simul2", 0, SPIFFS_RDWR | SPIFFS_APPEND);
spiffs_file fd3 = SPIFFS_open(FS, "simul2", SPIFFS_RDWR | SPIFFS_APPEND, 0);
TEST_CHECK(fd3 > 0);
u8_t data1 = 1;
@@ -790,7 +790,7 @@ TEST(simultaneous_write_append) {
TEST_CHECK(s.size == 3);
u8_t rdata[3];
spiffs_file fd = SPIFFS_open(FS, "simul2", 0, SPIFFS_RDONLY);
spiffs_file fd = SPIFFS_open(FS, "simul2", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
res = SPIFFS_read(FS, fd, &rdata, 3);
TEST_CHECK(res >= 0);
@@ -819,7 +819,7 @@ TEST(file_uniqueness)
sprintf(content, "%i", i);
res = test_create_file(fname);
TEST_CHECK(res >= 0);
fd = SPIFFS_open(FS, fname, 0, SPIFFS_APPEND | SPIFFS_RDWR);
fd = SPIFFS_open(FS, fname, SPIFFS_APPEND | SPIFFS_RDWR, 0);
TEST_CHECK(fd >= 0);
res = SPIFFS_write(FS, fd, content, strlen(content)+1);
TEST_CHECK(res >= 0);
@@ -831,7 +831,7 @@ TEST(file_uniqueness)
char ref_content[20];
sprintf(fname, "file%i", i);
sprintf(content, "%i", i);
fd = SPIFFS_open(FS, fname, 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, fname, SPIFFS_RDONLY, 0);
TEST_CHECK(fd >= 0);
res = SPIFFS_read(FS, fd, ref_content, strlen(content)+1);
TEST_CHECK(res >= 0);
@@ -851,7 +851,7 @@ TEST(file_uniqueness)
sprintf(content, "new%i", i);
res = test_create_file(fname);
TEST_CHECK(res >= 0);
fd = SPIFFS_open(FS, fname, 0, SPIFFS_APPEND | SPIFFS_RDWR);
fd = SPIFFS_open(FS, fname, SPIFFS_APPEND | SPIFFS_RDWR, 0);
TEST_CHECK(fd >= 0);
res = SPIFFS_write(FS, fd, content, strlen(content)+1);
TEST_CHECK(res >= 0);
@@ -867,7 +867,7 @@ TEST(file_uniqueness)
} else {
sprintf(content, "%i", i);
}
fd = SPIFFS_open(FS, fname, 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, fname, SPIFFS_RDONLY, 0);
TEST_CHECK(fd >= 0);
res = SPIFFS_read(FS, fd, ref_content, strlen(content)+1);
TEST_CHECK(res >= 0);
@@ -889,7 +889,7 @@ int create_and_read_back(int size, int chunk) {
res = test_create_file(name);
CHECK(res >= 0);
fd = SPIFFS_open(FS, name, 0, SPIFFS_APPEND | SPIFFS_RDWR);
fd = SPIFFS_open(FS, name, SPIFFS_APPEND | SPIFFS_RDWR, 0);
CHECK(fd >= 0);
res = SPIFFS_write(FS, fd, buf, size);
CHECK(res >= 0);
@@ -901,7 +901,7 @@ int create_and_read_back(int size, int chunk) {
SPIFFS_close(FS, fd);
fd = SPIFFS_open(FS, name, 0, SPIFFS_RDONLY);
fd = SPIFFS_open(FS, name, SPIFFS_RDONLY, 0);
CHECK(fd >= 0);
u8_t *rbuf = malloc(size);
@@ -967,7 +967,7 @@ TEST(bad_index_1) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -1004,7 +1004,7 @@ TEST(bad_index_2) {
res = read_and_verify("file");
TEST_CHECK(res >= 0);
spiffs_file fd = SPIFFS_open(FS, "file", 0, 0);
spiffs_file fd = SPIFFS_open(FS, "file", SPIFFS_RDONLY, 0);
TEST_CHECK(fd > 0);
spiffs_stat s;
res = SPIFFS_fstat(FS, fd, &s);
@@ -1040,7 +1040,7 @@ TEST(lseek_simple_modification) {
char *fname = "seekfile";
int i;
int len = 4096;
fd = SPIFFS_open(FS, fname, 0, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR);
fd = SPIFFS_open(FS, fname, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR, 0);
TEST_CHECK(fd > 0);
int pfd = open(make_test_fname(fname), O_TRUNC | O_CREAT | O_RDWR);
u8_t *buf = malloc(len);
@@ -1080,7 +1080,7 @@ TEST(lseek_modification_append) {
char *fname = "seekfile";
int i;
int len = 4096;
fd = SPIFFS_open(FS, fname, 0, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR);
fd = SPIFFS_open(FS, fname, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR, 0);
TEST_CHECK(fd > 0);
int pfd = open(make_test_fname(fname), O_TRUNC | O_CREAT | O_RDWR);
u8_t *buf = malloc(len);
@@ -1121,7 +1121,7 @@ TEST(lseek_modification_append_multi) {
int len = 1024;
int runs = (FS_PURE_DATA_PAGES(FS) / 2) * SPIFFS_DATA_PAGE_SIZE(FS) / (len/2);
fd = SPIFFS_open(FS, fname, 0, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR);
fd = SPIFFS_open(FS, fname, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR, 0);
TEST_CHECK(fd > 0);
int pfd = open(make_test_fname(fname), O_TRUNC | O_CREAT | O_RDWR);
u8_t *buf = malloc(len);
@@ -1164,7 +1164,7 @@ TEST(lseek_read) {
int len = (FS_PURE_DATA_PAGES(FS) / 2) * SPIFFS_DATA_PAGE_SIZE(FS);
int runs = 100000;
fd = SPIFFS_open(FS, fname, 0, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR);
fd = SPIFFS_open(FS, fname, SPIFFS_TRUNC | SPIFFS_CREAT | SPIFFS_RDWR, 0);
TEST_CHECK(fd > 0);
u8_t *refbuf = malloc(len);
memrand(refbuf, len);
+1 -1
View File
@@ -177,7 +177,7 @@ void dump_page(spiffs *fs, spiffs_page_ix p) {
int read_and_verify(char *name) {
s32_t res;
int fd = SPIFFS_open(&__fs, name, 0, 0);
int fd = SPIFFS_open(&__fs, name, SPIFFS_RDONLY, 0);
if (fd < 0) {
printf(" read_and_verify: could not open file %s\n", name);
return fd;