Skip to content

littlefs: Fix file truncation without writes #5832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2018

Conversation

geky
Copy link
Contributor

@geky geky commented Jan 11, 2018

In the open call, the LFS_O_TRUNC flag was correctly zeroing the file, but it wasn't actually writing the change out to disk. This went unnoticed because in the cases where the truncate was followed by a file write, the updated contents would be written out correctly.

Marking the file as dirty if the file isn't already truncated fixes the problem with the least impact. Also added better test cases around truncating files.

resolves #5820
from littlefs-project/littlefs#7
note: intended for patch

In the open call, the LFS_O_TRUNC flag was correctly zeroing the file, but
it wasn't actually writing the change out to disk. This went unnoticed because
in the cases where the truncate was followed by a file write, the
updated contents would be written out correctly.

Marking the file as dirty if the file isn't already truncated fixes the
problem with the least impact. Also added better test cases around
truncating files.
Copy link

@deepikabhavnani deepikabhavnani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 16, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jan 16, 2018

Build : SUCCESS

Build number : 877
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5832/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build

@mbed-ci
Copy link

mbed-ci commented Jan 16, 2018

@mbed-ci
Copy link

mbed-ci commented Jan 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LittleFS fopen in 'w' mode removes existing file
5 participants