Skip to content
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

mountinfo.Mounted(): fix #90

Merged
merged 3 commits into from
Nov 3, 2021
Merged

mountinfo.Mounted(): fix #90

merged 3 commits into from
Nov 3, 2021

Commits on Oct 28, 2021

  1. mountinfo: Mounted: normalize path, return ENOENT

    1. In case the argument does not exist, Mounted now returns an
       appropriate error. Previously, this condition was treated as
       "not a mount point", with no error returned, but in fact such
       path could be a mount point, overshadowed by another mount.
       Since the mount is still unreachable, it can not be unmounted
       anyway, so we do not fall back to mountedByMountinfo, returning
       an error instead.
    
       In case callers are not interested in ENOENT, they should filter it
       out. Amend the function doc accordingly.
    
    2. There are some corner cases in which mountedByOpenat2 or mountedByStat
       do not work properly. In particular,
    
        - neither work if there's an ending slash;
        - neither work for a symlink to a mounted directory;
        - mountedByStat do not work a parent of path is a symlink residing on
          different filesystem.
    
       To solve these cases, we have to call normalizePath() before path is used
       for any of mountedBy* functions, not just before mountedByMountinfo
       like it was done earlier.
    
       More tests are to be added by the next commit.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Oct 28, 2021
    Configuration menu
    Copy the full SHA
    dbd468b View commit details
    Browse the repository at this point in the history
  2. mountinfo: revamp TestMountedBy

    The way prepareMounts was written was very complicated from the
    maintainability perspective, with all the test cases in the same basket.
    
    Rewrite this in a much cleaner way, with individual subtests.
    
    Add some more test cases that were failing before the previous commit.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Oct 28, 2021
    Configuration menu
    Copy the full SHA
    3925d0b View commit details
    Browse the repository at this point in the history
  3. mountinfo: Mounted: document/check false is returned on error

    In case of any error, Mounted() always returns false. Document and check
    that.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Oct 28, 2021
    Configuration menu
    Copy the full SHA
    90da438 View commit details
    Browse the repository at this point in the history