-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
WIP: Allow to mount VFS at root dir #2950
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
Conversation
e717047
to
ffa050f
Compare
Thanks for working on this! I'm just back from the road, so it may take me some time to review the changes in detail, but I think the code size increase is worth it to support such a feature. |
612811f
to
0a860db
Compare
0a860db
to
2f59625
Compare
93a1640
to
e5a6608
Compare
So, I had more detailed look finally, and this looks very good. Yes, this adds some code, but for very useful functionality. I see that various corner cases are handled, so I'm +1 to merge this ASAP unless big issues are known. |
Well, from my point of view there was not a full discussion about this functionality. I still er on the side of keeping the VFS simple (ie no mounting at root) because 1) this VFS code needs to go in every port that wants to have compatible filesystem behaviour, even ports that have little ROM (eg possibly microbit); 2) having this feature will increase differences between stmhal/pyboard and esp8266. |
Well, we do due diligence on keeping the code size small. Sometimes however, in the sake of cross-port generality in a very user-visible places, we need to go for a compromise like that.
Having this feature first of all decreases differences between Unix and bare-metal ports, and that's very important win. It has various implications, e.g. suitability of MicroPython to be a real "OS" like environment, without very crude compromises, like like of a true root of filesystem. Otherwise, that feature isn't going to increase differences short term, because esp8266 already had filesystem mounted at /. And longer term, next version of uPy is 1.9, then 2.0 is on the horizon, and that will be a great opportunity to leave old "pyb" baggage behind. But for that to be truly viable, we need to have a truly common featureset, and it should account for basic requirements of bigger systems too (that being not that they're bigger, but that saving 100 bytes while subjecting users to non-least surprise regarding filesystem behavior isn't a good compromise). |
I can guess what this means but please can you explain in detail what you actually mean by this.
This is not something I want to do. And I anyway think that the way stmhal does the filesystem is "better" for embedded applications: you have a set of filesystems, none of which are particularly suited to mounting at root because at any given time none of them may be available. Eg flash may not be available if you turn that feature off, sd not when there's no SD card, you may have a romfs for a recovery mode, a ramfs at certain times to do fast filesystem access, extflash for external SPI when that is powered up, etc. So the official suggestion that I'd like to make to users is to have a blank root FS, and then you mount devices at a mount point in the root when you use said device. You chdir to the mount point that you want to use as the "current" working FS, and then add to sys.path any locations on other mount points that you want to use as sources for libraries. |
The current PR is up to 150+ and last I looked at it I was still finding corner cases with the root filesystem not behaving as expected. |
But we discussed all this already. Doing it the natural way, by allowing root to be mounted on root, we can switch Unix port to VFS implementation, where it interfaces to the underlying POSIX FS. Doing so will allow to have a common FS handling scheme for all ports, and thus consistency and generality.
No problem, but please don't make pyboard be a brake on MicroPython progress ;-)
I certainly agree. But what's "better" for adhoc limited embedded application is a toy-like, random arbitrary restriction for real-world usage. The litmus test would be a question "Can MicroPython replace a small system based on Linux and Linux shell?" And while MicroPython offers much wider and more expressive programming environment, such arbitrary restriction with FS handling turn it down to be, again, "toy-like". Why we went all this way just to purposedly cripple it in a pretty user-visible place in the end? Let's make it up to the real world!
That's very niche, peculiar case I'd say. Usually, there's a "default" filesystem, if a user disables one type of it, they should set another as such, as the most obvious solution.
Well, your code allows to have "unmounted" root, but mount VFSes beneath it, right? Then that scenario will work, it's just not natural comparing with how we have it on the rest of systems around us. So, it may confuse users (as it doesn't follow the principle of least surprise), and I don't understand why you hold onto that.
But you see, sticks already pop up from the ducktape of your solution. That's not how people usually do it! There's a well-known by convention path, and people usually mount something to make user it's available, not other way around - it may seem easier to change paths, but multiplies by time and space, that leads to configuration hell. And natural standard path is "/lib" (not the whole filesystem just for libs of course!) |
Good. That's why we're conservative on adding features which could be not added. 300 bytes, 1K is ok to make it real-world useful. Otherwise we can go straight to CP/M times of single flat FS - indeed, most of esp8266 systems have just that "and nobody even complains". So again, why did we go such a long way to just stop one step away from making it real? |
Forgot to add another comment I had in mind during previous review: And I don't even propose to make support for mounting at "/" to be configurable - doesn't make sense. Instead, we should support option if having just one VFS mounted, and then it will be mounted - tadam - at root, as an obvious way to keep the code the most minimal, which is the requirement here. So, all pieces of the puzzle fall into their place by following standard well-known rules of handling file systems. |
This patch allows mounting of VFS objects right at the root directory, eg os.mount(vfs, '/'). It still allows VFS's to be mounted at a path within the root, eg os.mount(vfs, '/flash'), and such mount points will override any paths within a VFS that is mounted at the root.
Ok, I'm happy that we had enough discussion on this and I guess it's good to try and be general in this case. Merged in c9a3a68 up to e62235f The tests that were added are still WIP, and for the moment just serve to check basic behaviour. All the VFS tests need to be revisited anyway and possibly refactored. |
Thanks! |
This is WIP to server as a proof of concept (or not) for #2920. It allows to mount a VFS at the root dir, and also at other (1st level) dirs within the root. Eg you can do:
Current increases in code size are (for those ports that changed): stmhal: 120, cc3200: 128, esp8266: 112.