Skip to content

extmod/vfs: Return mount table from no-args mount call. #16939

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 4 commits into from
Mar 27, 2025

Conversation

AJMansfield
Copy link
Contributor

Summary

This is a more minimal version of #16849, that overloads vfs.mount to output the current vfs mount table when called with no arguments.

Testing

This PR includes full automated tests; I have verified that these tests pass with the feature code and fail without it.

Trade-offs and Alternatives

In order to overload vfs.mount to accept a zero-argument call, it's necessary to change the two existing arguments from fixed positional arguments into dynamic positional arguments handled by mp_arg_parse_all.

I've re-defined them as required nameless arguments in the table for now so that their current positional-only behavior doesn't change:

        { MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
        { MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },

This avoids introducing new QSTRs for the argument names fsobj and mount_point and avoids committing to those specific argument names as a visible part of the API (i.e. mount(fsobj=..., mount_point=...) remains an error). This may be a design decision worth revisiting (perhaps along with the argument names themselves).

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:  +120 +0.014% standard
      stm32:   +64 +0.016% PYBV10
     mimxrt:   +64 +0.017% TEENSY40
        rp2:   +72 +0.008% RPI_PICO_W
       samd:   +64 +0.024% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:   +60 +0.013% VIRT_RV32

Copy link

codecov bot commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base (fa42487) to head (c68a40a).
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #16939   +/-   ##
=======================================
  Coverage   98.54%   98.54%           
=======================================
  Files         169      169           
  Lines       21878    21887    +9     
=======================================
+ Hits        21559    21568    +9     
  Misses        319      319           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dpgeorge dpgeorge added the extmod Relates to extmod/ directory in source label Mar 15, 2025
@projectgus projectgus self-requested a review March 18, 2025 00:08
Copy link
Member

@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

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

This looks good! And it's nice how it mirrors the Linux mount command, which with no arguments outputs a list of mounted filesystems.

Tested on PYBD_SF2 (with a ROMFS mounted) and RPI_PICO_W (which mounts at the root).

Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
This extends the existing `vfs.mount()` function to accept zero arguments,
in which case it returns a list of tuples of mounted filesystem objects
and their mount location.

Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
@dpgeorge dpgeorge merged commit c68a40a into micropython:master Mar 27, 2025
64 checks passed
@AJMansfield AJMansfield deleted the mountinfo2 branch April 23, 2025 02:14
@AJMansfield AJMansfield mentioned this pull request Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extmod Relates to extmod/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy