Skip to content

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

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
May 3, 2018

Conversation

geky
Copy link
Contributor

@geky 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 littlefs-project/littlefs#51
cc @deepikabhavnani, @kegilbert

Pull request type

[x] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

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;

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 littlefs: Fixed issue with trailing dots in file paths littlefs: Fix issue with trailing dots in file paths May 3, 2018
@0xc0170
Copy link
Contributor

0xc0170 commented May 3, 2018

/morph build

@mbed-ci
Copy link

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
Copy link

mbed-ci commented May 3, 2018

@mbed-ci
Copy link

mbed-ci commented May 3, 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.

5 participants