Skip to content

Add ability to get, set filesystem label from CircuitPython#712

Merged
tannewt merged 5 commits into
adafruit:masterfrom
jepler:fslabel
Mar 28, 2018
Merged

Add ability to get, set filesystem label from CircuitPython#712
tannewt merged 5 commits into
adafruit:masterfrom
jepler:fslabel

Conversation

@jepler
Copy link
Copy Markdown

@jepler jepler commented Mar 26, 2018

In #530 we discussed the idea of setting the device's label to something other than CIRCUITPYTHON (for instance, named after the board type or incorporating part of the board's unique serial number). This PR adds the ability to get and set the filesystem label with a sequence like storage.getmount("/").label

However, it's not particularly satisfactory as in normal usage you can't setlabel the main storage from main.py, since it is mounted to the PC and is readonly to CircuitPython during normal operation. Doing it from boot.py seems about 1000% fiddlier than doing it via your favorite desktop envirionment's GUI or commandline.

@jepler
Copy link
Copy Markdown
Author

jepler commented Mar 26, 2018

In light of the problems I outline in the summary, I don't think this one's actually worthy of being merged into CircuitPython. It takes up a small amount of flash for no real benefit.

Comment thread shared-module/storage/__init__.c Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need to have a break after a return.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Cleaned it up in one of my rebases. Thanks.

Copy link
Copy Markdown
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

I really like this change and think cross-platform instructions are well worth the small amount of extra space.

How about having label be a property of the mount object?

Also, returning a friendly error message (not OSError) when its not writable would be nice too.

@jepler
Copy link
Copy Markdown
Author

jepler commented Mar 26, 2018

OK, I took care of making it a property. I'm not sure what to do about the exception in setlabel; do we want just a special case for the "read only" case, and otherwise return the current numeric error?

@jepler
Copy link
Copy Markdown
Author

jepler commented Mar 26, 2018

It looks like I pushed the wrong branch when trying to update this PR, will fix it when I get home and can double check things.

@tannewt
Copy link
Copy Markdown
Member

tannewt commented Mar 26, 2018

Yeah, limiting to the read-only case would be good. :-) Thanks!

Comment thread extmod/vfs_fat.c Outdated
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

should this use MICROPY_FATFS_USE_LABEL instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure!

jepler added 5 commits March 27, 2018 21:28
These allow accessing the filesystem label.  For instance,
in boot.py, you can set the label on the built-in storage with:
   storage.remount('/', False)
   storage.getmount('/').label = "NEWLABEL"
   storage.remount('/', True)

Users with multiple CIRCUITPY boards may find it desirable to
choose a different label for each board they own.
Copy link
Copy Markdown
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks again!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants