Littlefs: Support truncate function

Created on 11 Jan 2018  路  4Comments  路  Source: littlefs-project/littlefs

If possible support for truncate would be useful, e.g.

int truncate(const char *path, off_t length);

or using the file handle like ftruncate

Most helpful comment

That's a good suggestions. I'm hesitant, since I want to keep the scope of this project small and contained. But a truncate function would be more efficient than existing functions, since it can reuse old data on the disk.

I'm thinking of adding a function with this API when I get the chance:

int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size);

All 4 comments

That's a good suggestions. I'm hesitant, since I want to keep the scope of this project small and contained. But a truncate function would be more efficient than existing functions, since it can reuse old data on the disk.

I'm thinking of adding a function with this API when I get the chance:

int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size);

Here we go: https://github.com/geky/littlefs/commit/d88f0ac02ff93b549418d38d464b5591fce4f688

Let me know if you run into any issues.

Is it possible to update littlefs-fuse as well?

You might want to take a look at the git submodule feature. This way you don't have to update such projects by its own.

Sure thing, here you go: https://github.com/geky/littlefs-fuse/commit/ed8713cc0f72bca9e0327553aaea135b84d7fda5

Instead of using git submodules, littlefs-fuse is using git subtrees. If you wanted to switch to the most up to date branch, you could merge in littlefs's master yourself:

$ cd littlefs-fuse
$ git remote add -f littlefs [email protected]:geky/littlefs
$ git subtree merge --prefix=littlefs littlefs/master --squash

The reason for not using submodules is that submodules adds an extra user step that isn't intuitive, whereas with subtrees all the user needs to do is clone and they're ready to go.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roceh picture roceh  路  8Comments

umanayana picture umanayana  路  5Comments

davidefer picture davidefer  路  7Comments

FrederikTB picture FrederikTB  路  4Comments

PoppaChubby picture PoppaChubby  路  6Comments