Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-79409

QStorageInfo.mountedVolumes() gives incomplete list on macOS

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P4: Low
    • Resolution: Unresolved
    • Affects Version/s: 5.12.5, 5.12, 5.13.1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      macOS 10.15 and 10.14
    • Platform/s:
      macOS

      Description

      QStorageInfo.mountedVolumes() does not detect volumes mounted via /etc/fstab orĀ /etc/auto_master. As far as I can it only detects network mounts created via Finder.

      Here is a link to the relative section of code.

      The problem is in the option kCFURLEnumeratorSkipInvisibles. Using virtually any other option in the CFURLEnumeratorOptions results in a complete listing of mounts.

      I was able to recreate the Qt behavior in a Swift playground file with the following contents

      import Cocoa
      
      let options = CFURLEnumeratorOptions.skipInvisibles
      let volumes = CFURLEnumeratorCreateForMountedVolumes(nil, options, nil)!
      
      var paths = [CFString]()
      var result = CFURLEnumeratorResult.success
      var urlProperty : Unmanaged<CFURL>?
      var errorProperty : Unmanaged<CFError>?
      
      repeat {
          result = CFURLEnumeratorGetNextURL(volumes, &urlProperty, &errorProperty)
          if result == CFURLEnumeratorResult.success {
              if urlProperty != nil {
                  let unpackagedUrl = urlProperty!.takeRetainedValue() as CFURL
                  let urlString = CFURLCopyFileSystemPath(unpackagedUrl, CFURLPathStyle.cfurlposixPathStyle)
                  paths.append(urlString!)
              }
          }
      } while result != CFURLEnumeratorResult.end
      print(paths)
      

      Here is a link to all the possible options that CFUrlEnumeratorCreateForMountedVolumes can be called with: https://developer.apple.com/documentation/corefoundation/cfurlenumeratoroptions

      I suggest a different option is considered such as skipPackageContents.

      Another quick sanity check is to mount a network share via /etc/fstab or /etc/auto_master and then run mount from the terminal, and compare that to the output of QStorageInfo.mountedVolumes().

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              thiago Thiago Macieira
              Reporter:
              j9ac9k Ognyan Moore
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes