ftl: add buffer length to ftl_read()

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent cd44b4866b
commit e31a852225
  1. 2
      include/ftl.h
  2. 12
      source/ftl/ftl.c

@ -31,7 +31,7 @@ struct ftl_journal {
int ftl_init_journal(struct ftl_journal *j, struct flash_dev *dev);
int ftl_resume_journal(struct ftl_journal *j);
int ftl_write(struct ftl_journal *j, uint32_t addr, const uint8_t *data);
int ftl_read(struct ftl_journal *j, uint8_t *data, uint32_t va);
int ftl_read(struct ftl_journal *j, uint8_t *data, size_t len, uint32_t va);
int ftl_trim(struct ftl_journal *j, uint32_t va);
uint32_t ftl_get_size(const struct ftl_journal *j);
uint32_t ftl_get_capacity(const struct ftl_journal *j);

@ -582,21 +582,21 @@ static int ftl_write_upage(struct ftl_journal *j, const uint8_t *page,
return ftl_write_page_desc(j, page_desc);
}
int ftl_read(struct ftl_journal *j, uint8_t *data, uint32_t va)
int ftl_read(struct ftl_journal *j, uint8_t *data, size_t len, uint32_t va)
{
int ret;
uint32_t page;
if ((ret = trace_path(j, NULL, &page, va)) < 0) {
if (ret != -ERR_NOT_FOUND)
return -1;
memset(data, 0, len);
return ret;
}
memset(data, 0, j->log2_page_size);
if (!data)
return 0;
}
return flash_read(j->dev, page << j->log2_page_size, data,
j->log2_page_size);
min(j->log2_page_size, len));
}
int ftl_write(struct ftl_journal *j, uint32_t va, const uint8_t *data)

Loading…
Cancel
Save