Skip to content

Commit

Permalink
continue adding fs methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rundb committed Nov 2, 2023
1 parent 0c98ac0 commit 1b3026d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
32 changes: 11 additions & 21 deletions firmware/src/lib/myfs/myfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,36 +252,26 @@ int myfs_file_open(myfs_t *myfs, const myfs_config& config, myfs_file_t& file, u
memset(d.reserved, 0xFF, sizeof(d.reserved));

// 2. flash needed part of the descriptor into the table
// const auto new_file_descriptor_address = myfs->next_file_descriptor_address;
// const auto descriptor_page_start = (new_file_descriptor_address / page_size) * page_size;
// const auto descriptor_page_offset = new_file_descriptor_address - descriptor_page_start;
// NRF_LOG_INFO("descriptor start 0x%x, offset 0x%x", descriptor_page_start, descriptor_page_offset);
// const auto read_result = config.read(
// &config,
// descriptor_page_start / config.block_size,
// descriptor_page_start % config.block_size,
// config.read_buffer,
// page_size
// );
// if (read_result != 0)
// {
// NRF_LOG_ERROR("myfs: read op failed");
// return -1;
// }
// print_buffer((uint8_t *)config.read_buffer, page_size);
// memcpy(config.read_buffer + descriptor_page_offset, &d, sizeof(d));
// print_buffer((uint8_t *)config.read_buffer, page_size);
const auto descr_prog_result = write_myfs_descriptor(d, myfs->next_file_descriptor_address, config);
if (0 != descr_prog_result)
{
NRF_LOG_ERROR("myfs: descr prog failed");
return descr_prog_result;
}
}

// 3. fill in required data into the file object
file.flags = flags;
file.is_open = true;
file.is_write = true;
memcpy(file.id, file_id, d.file_id_size);
return 0;
}

// 3. fill in required data into the file object
return -1;
}

int myfs_file_close(myfs_t *myfs, const myfs_config& config, myfs_file_t& file)
{
return -1;
}

Expand Down
1 change: 1 addition & 0 deletions firmware/src/lib/myfs/myfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ int myfs_format(myfs_t *myfs, const myfs_config *config);
int myfs_mount(myfs_t *myfs, const myfs_config *config);

int myfs_file_open(myfs_t *myfs, const myfs_config& config, myfs_file_t& file, uint8_t * file_id, uint8_t flags);
int myfs_file_close(myfs_t *myfs, const myfs_config& config, myfs_file_t& file);
// int lfs_unmount(lfs_t *lfs);
// lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size);
// lfs_dir_read
Expand Down

0 comments on commit 1b3026d

Please sign in to comment.