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

FATFileSystem: provide working dir_rewind and dir_seek #5503

Merged
merged 1 commit into from Nov 20, 2017

Conversation

Projects
None yet
8 participants
@infinnovation-dev
Contributor

infinnovation-dev commented Nov 14, 2017

Description

Working implementations of dir_rewind and dir_seek are provided for FATFileSystem,
I believe that this fixes #5440 and obviates the need for API changes proposed in #5441.

Status

READY

Migrations

NO

@0xc0170 0xc0170 requested a review from geky Nov 15, 2017

@deepikabhavnani

This comment has been minimized.

Contributor

deepikabhavnani commented Nov 15, 2017

@infinnovation - We will upgrade to ChanFs 0.13a version and index element is not available in directory structure.
Please see : #5490

finfo.lfname = lfname;
finfo.lfsize = NAME_MAX;
#endif // _USE_LFN
res = f_readdir(dh, &finfo);

This comment has been minimized.

@deepikabhavnani

deepikabhavnani Nov 15, 2017

Contributor

Return value/error here will not be propagated to application.

This comment has been minimized.

@infinnovation-dev

infinnovation-dev Nov 15, 2017

Contributor

The only useful thing an application can do after dir_seek() is dir_read(), at which point it will receive an error.

@@ -660,7 +660,24 @@ void FATFileSystem::dir_seek(fs_dir_t dir, off_t offset) {
FATFS_DIR *dh = static_cast<FATFS_DIR*>(dir);
lock();
dh->index = offset;
if (offset < dh->index) {

This comment has been minimized.

@infinnovation-dev

infinnovation-dev Nov 15, 2017

Contributor

This optimisation assumes that index is monotonic increasing (which appears to be the case in the current version of ChaN FatFs). If not, rewind unconditionally and use an equality test in the while loop.

@infinnovation-dev

This comment has been minimized.

Contributor

infinnovation-dev commented Nov 15, 2017

@deepikabhavnani Although index is not present in 0.13a, it appears that dptr has similar properties so could be used for the telldir / seekdir token.

My priority is to have a working rewinddir.

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Nov 16, 2017

My priority is to have a working rewinddir.

Thanks for this patch ! As the update is already up, would it be possible to rebase this on top of the updated version ?

@deepikabhavnani please advise

Colin Hogben
FATFileSystem: provide working dir_rewind and dir_seek
The index field of FATFS_DIR does not encapsulate all the context
required to reposition the directory traversal.  ChaN provides
f_rewinddir() but no directory seek, so rewind if necessary then step
through until the desired index is reached.

@infinnovation-dev infinnovation-dev force-pushed the infinnovation-dev:rewinddir branch to 452e290 Nov 16, 2017

@deepikabhavnani

This comment has been minimized.

Contributor

deepikabhavnani commented Nov 16, 2017

@0xc0170 - Patch will require changes (apart from rebase) to be compatible with FAT upgrade, we can go ahead with this fix for old version, and I can update the patch to be compatible with FAT upgrade. This way we can have working API's in both versions.

@geky

geky approved these changes Nov 16, 2017

This looks great, thanks for this 👍

LGTM

@deepikabhavnani

This comment has been minimized.

Contributor

deepikabhavnani commented Nov 16, 2017

/morph build

1 similar comment
@studavekar

This comment has been minimized.

Collaborator

studavekar commented Nov 17, 2017

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Nov 17, 2017

Build : SUCCESS

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

Triggering tests

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

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Nov 17, 2017

uvisor CI manually triggered, should be completed soon

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Nov 20, 2017

Restart uvisor, as the last one did not report back the status.

@theotherjimmy theotherjimmy merged commit ac891af into ARMmbed:master Nov 20, 2017

6 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter 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
@bmcdonnell-ionx

This comment has been minimized.

Contributor

bmcdonnell-ionx commented Jan 10, 2018

I get (2) compiler warnings when building mbed OS 5.7.2 on ARM_GCC:

../mbed-os/features/filesystem/fat/FATFileSystem.cpp: In member function 'virtual void FATFileSystem::dir_seek(mbed::fs_dir_t, off_t)':
../mbed-os/features/filesystem/fat/FATFileSystem.cpp:661:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (offset < dh->dptr) {
         ~~~~~~~^~~~~~~~~~
../mbed-os/features/filesystem/fat/FATFileSystem.cpp:664:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (dh->dptr < offset) {
            ~~~~~~~~~^~~~~~~~

I think the right thing to do would be to static_cast<off_t>(dh->dptr). But can dh->dptr be > max off_t? In which case it would do the wrong thing.

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