WIP cleaned up TODOs

This commit is contained in:
Christopher Haster
2018-04-03 08:29:28 -05:00
parent 3a12b40fff
commit 9b4530f8de

14
lfs.c
View File

@@ -712,7 +712,6 @@ relocate:
return 0;
}
// TODO zeros?
static int lfs_dir_get(lfs_t *lfs, const lfs_dir_t *dir,
lfs_off_t off, void *buffer, lfs_size_t size) {
return lfs_bd_read(lfs, dir->pair[0], off, buffer, size);
@@ -1170,8 +1169,6 @@ int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
break;
}
// TODO common info constructor?
// TODO also used in lfs_stat
info->type = 0xf & entry.d.type;
if (entry.d.type == (LFS_STRUCT_CTZ | LFS_TYPE_REG)) {
info->size = entry.d.u.file.size;
@@ -1697,7 +1694,6 @@ int lfs_file_sync(lfs_t *lfs, lfs_file_t *file) {
return err;
}
// TODO entry read function?
lfs_entry_t entry = {.off = file->poff};
err = lfs_dir_get(lfs, &cwd, entry.off, &entry.d, sizeof(entry.d));
lfs_entry_fromle32(&entry.d);
@@ -1768,7 +1764,6 @@ lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file,
nsize = size;
while (nsize > 0) {
// TODO can this be collapsed?
// check if we need a new block
if (!(file->flags & LFS_F_READING) ||
file->off == lfs->cfg->block_size) {
@@ -1838,12 +1833,9 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file,
}
}
// TODO combine with block allocation?
// TODO need to move out if no longer fits in block also
// TODO store INLINE_MAX in superblock?
// TODO what if inline files is > block size (ie 128)
if ((file->flags & LFS_F_INLINE) &&
file->pos + nsize >= file->inline_size) {
// inline file doesn't fit anymore
file->block = 0xfffffffe;
file->off = file->pos;
@@ -1859,9 +1851,6 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file,
}
while (nsize > 0) {
// TODO can this be collapsed?
// TODO can we reduce this now that block 0 is never allocated?
// TODO actually, how does this behave if inline max == 0?
// check if we need a new block
if (!(file->flags & LFS_F_WRITING) ||
file->off == lfs->cfg->block_size) {
@@ -1959,7 +1948,6 @@ lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file,
return file->pos;
}
// TODO handle inlining?
int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
if ((file->flags & 3) == LFS_O_RDONLY) {
return LFS_ERR_BADF;