Skip to content

fatfs: Add full support for multiple fs volume prefixes #4561

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
Jul 10, 2017

Conversation

geky
Copy link
Contributor

@geky geky commented Jun 14, 2017

In the Chan implementation of the fatfs, paths can be prefixed with a drive number (ie "2:/hi/hello/filehere.txt" for drive 2). This is used internally to lookup the storage that is in use. Full support of multiple fatfs simultaneously requires path prefixes being applied for every function that takes a path.

Note: This is only an issue when multiple fatfss are used simultaneously. Repeated use of a single fatfs instance (even with different storages) do not show this issue.

Note: this is only required filesystems after the first mounted filesystem. The first filesystem has no penalty.

related issue #4526
cc @netanelgonen


// Adds prefix needed internally by fatfs, this can be avoided for the first fatfs
// (id 0) otherwise a prefix of "id:/" is inserted in front of the string.
static Deferred<const char*> fat_path_prefix(int id, const char *path)
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens when id > 256?

Copy link
Contributor Author

@geky geky Jun 14, 2017

Choose a reason for hiding this comment

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

  • The fsid will break.
  • The chanfs will fail to mount.
  • MBR will fail with >4 partitions
  • GPT will fail with >128 partitions.
  • Linux won't recognize >255 partitions.
  • Windows won't recognize >1 partition.
  • You will need ~800KB of ram to mount all of the filesystems at once.
  • With 160MB of storage you will be wasting 10% on metadata alone.

Oh and this code may break.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 😆

Copy link
Contributor

@theotherjimmy theotherjimmy Jun 14, 2017

Choose a reason for hiding this comment

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

Actually, reading tha GPT article, the format supports >128 partitions. The maximum should be 4,294,967,295 or 0xFFFFFFFF

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah looks like you're right, glad we won't have to reinvent partitioning to get your 300 fs cluster working.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could it just be uint8? we don't loose anything by doing that.

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 15, 2017

retest uvisor

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 19, 2017

retest uvisor

@adbridge
Copy link
Contributor

@geky could you address the issues raised by @theotherjimmy please ?

@JanneKiiskila
Copy link
Contributor

We need this on a patch release as well (5.5.x).

@theotherjimmy
Copy link
Contributor

@adbridge That "review" was not blocking, and just a question

@theotherjimmy
Copy link
Contributor

/morph test-nightly

@geky
Copy link
Contributor Author

geky commented Jun 26, 2017

@adbridge, @theotherjimmy, sorry, I've been out and unable to update the pr. Feel free to push another commit to change the id type if you'd like.

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 639

Test failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 29, 2017

/morph test-nightly

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 29, 2017

retest uvisor

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 685

Test failed!

@theotherjimmy
Copy link
Contributor

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

This is only an issue when multiple fatfss are used simultaneously.
Repeated use of a single fatfs instance (even with different storages)
do not show this issue.

Full support requires path prefixes being applied for every function
that takes a path. Note: this is only required filesystems after the
first mounted filesystem. The first filesystem has no penalty.
@geky geky force-pushed the fat-fs-volume-prefixes branch from 4846541 to 1775e1f Compare June 29, 2017 21:56
@geky
Copy link
Contributor Author

geky commented Jun 29, 2017

merge conflict, took a bit of effort but is rebased now
/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 704

Test failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 30, 2017

I aborted this, as this requires one fix to be functional, waiting for CI to complete #4672

@theotherjimmy
Copy link
Contributor

#4672 on master. /morph test-nightly

@mbed-bot
Copy link

mbed-bot commented Jul 8, 2017

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 748

All builds and test passed!

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.

7 participants