Add ability to get, set filesystem label from CircuitPython#712
Conversation
|
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. |
There was a problem hiding this comment.
No need to have a break after a return.
There was a problem hiding this comment.
Cleaned it up in one of my rebases. Thanks.
tannewt
left a comment
There was a problem hiding this comment.
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.
|
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? |
|
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. |
|
Yeah, limiting to the read-only case would be good. :-) Thanks! |
There was a problem hiding this comment.
should this use MICROPY_FATFS_USE_LABEL instead?
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.
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("/").labelHowever, 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.