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

littlefs: Fix issue with trailing dots in file paths #6774

Merged
merged 1 commit into from May 3, 2018

Conversation

Projects
None yet
5 participants
@geky
Member

geky commented Apr 30, 2018

Description

Paths such as the following were causing issues:
/tea/hottea/.
/tea/hottea/..

Unfortunately the existing structure for path lookup didn't make it very easy to introduce proper handling in this case without duplicating the entire skip logic for paths. So the lfs_dir_find function had to be restructured a bit.

One odd side-effect of this is that now lfs_dir_find includes the initial fetch operation. This kinda breaks the fetch -> op pattern of the dir functions, but does come with a nice code size reduction.

related ARMmbed/littlefs#51
cc @deepikabhavnani, @kegilbert

Pull request type

[x] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change
littlefs: Fixed issue with trailing dots in file paths
Paths such as the following were causing issues:
/tea/hottea/.
/tea/hottea/..

Unfortunately the existing structure for path lookup didn't make it very
easy to introduce proper handling in this case without duplicating the
entire skip logic for paths. So the lfs_dir_find function had to be
restructured a bit.

One odd side-effect of this is that now lfs_dir_find includes the
initial fetch operation. This kinda breaks the fetch -> op pattern of
the dir functions, but does come with a nice code size reduction.
@@ -783,26 +783,19 @@ static int lfs_dir_find(lfs_t *lfs, lfs_dir_t *dir,
lfs_entry_t *entry, const char **path) {
const char *pathname = *path;
size_t pathlen;
entry->d.type = LFS_TYPE_DIR;
entry->d.elen = sizeof(entry->d) - 4;

This comment has been minimized.

@deepikabhavnani

deepikabhavnani Apr 30, 2018

Contributor

Will sizeof(entry->d) be ever < 4? Will that be corner case considering elen is uint8_t?

This comment has been minimized.

@geky

geky May 2, 2018

Member

No, the prefix for the entry stored on disk is a 4 byte header. If entry->d is less than 4, than the struct is malformed.

Also GCC is actually smart enough to warn on underflow for constants like these.

@0xc0170 0xc0170 changed the title from littlefs: Fixed issue with trailing dots in file paths to littlefs: Fix issue with trailing dots in file paths May 3, 2018

@0xc0170 0xc0170 added needs: CI and removed needs: review labels May 3, 2018

@0xc0170

This comment has been minimized.

Member

0xc0170 commented May 3, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented May 3, 2018

Build : SUCCESS

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

Triggering tests

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

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@0xc0170 0xc0170 merged commit 1a5a2f0 into ARMmbed:master May 3, 2018

12 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Passed, runtime is 10706 cycles (+528 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/littlefs Passed, code size is 9964B (-1.46%)
Details
travis-ci/tools Local tools testing has passed
Details

@0xc0170 0xc0170 removed the ready for merge label May 3, 2018

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