MacVRefNum and Monterey

It is not that hard.
Make a new project and drop a Text Area in the Window.
In its open Event put following code

For i As Integer = 0 To FolderItem.LastDriveIndex
  Dim path As String = FolderItem.DriveAt(i).NativePath
  Me.AddText "*** " + path + " ***" + EndOfLine
  Me.AddText statfsForPath(path) + EndOfLine
Next

Now add a Method to the Window:

Public Function statfsForPath(path as String) As String
  Soft Declare Function statfs Lib "libc.dylib" (path As Ptr, buff As Ptr) As Int32
  
  Const statfsStructSize = 2168 //sizeof(struct statfs): 2168
  Const MAXPATHLEN     = 1024
  Dim statfsResult As New MemoryBlock(statfsStructSize)
  Dim lines() As String
  
  Dim pathBuf As New MemoryBlock(LenB(path)+1)
  pathBuf.StringValue(0, LenB(path)) = path
  
  Dim result As Integer = statfs(pathBuf, statfsResult)
  If result <> 0 Then
    lines.append "Error "+Str(result) + EndOfLine
    Return String.FromArray(lines, EndOfLine)
  End
  
  Const MFSTYPENAMELEN = 16
  Const MNAMELEN       = MAXPATHLEN
  Dim pos As Int32 = 0
  
  lines.append "f_bsize:  """ + statfsResult.UInt32Value(pos).tostring + """" + EndOfLine
  pos = pos + 4
  lines.append "f_iosize: """ + statfsResult.Int32Value(pos).tostring + """" + EndOfLine
  pos = pos + 4
  lines.append "f_blocks: """ + statfsResult.UInt64Value(pos).tostring + """" + EndOfLine
  pos = pos + 8
  lines.append "f_bfree:  """ + statfsResult.UInt64Value(pos).tostring + """" + EndOfLine
  pos = pos + 8
  lines.append "f_bavail: """ + statfsResult.UInt64Value(pos).tostring + """" + EndOfLine
  pos = pos + 8
  lines.append "f_files:  """ + statfsResult.UInt64Value(pos).tostring + """" + EndOfLine
  pos = pos + 8
  lines.append "f_ffree:  """ + statfsResult.UInt64Value(pos).tostring + """" + EndOfLine
  pos = pos + 8
  lines.append "fsid_:    """ + statfsResult.UInt32Value(pos).tostring + """" + EndOfLine
  pos = pos + 4
  lines.append "f_owner:  """ + statfsResult.UInt32Value(pos).tostring + """" + EndOfLine
  pos = pos + 4
  lines.append "f_type:   """ + statfsResult.UInt32Value(pos).tostring + """" + EndOfLine
  pos = pos + 4
  lines.append "f_flags:  """ + statfsResult.UInt32Value(pos).tostring + """" + EndOfLine
  pos = pos + 4
  lines.append "f_fssubtype: """ + statfsResult.UInt32Value(pos).tostring + """" + EndOfLine
  pos = pos + 4
  lines.append "f_fstypename[MFSTYPENAMELEN]: """ + DefineEncoding(statfsResult.StringValue(pos, MFSTYPENAMELEN), Encodings.UTF8) + """" + EndOfLine
  pos = pos + MFSTYPENAMELEN
  lines.append "f_mntonname[MAXPATHLEN]:      """ + DefineEncoding(statfsResult.StringValue(pos, MAXPATHLEN), Encodings.UTF8) + """" + EndOfLine
  pos = pos + MAXPATHLEN
  lines.append "f_mntonname[MAXPATHLEN]:      """ + DefineEncoding(statfsResult.StringValue(pos, MAXPATHLEN), Encodings.UTF8) + """" + EndOfLine
  
  Return String.FromArray(lines, "")
End Function

You are interested in the “fsid_” field of the returned values.
Just modify the code to return this field as UInt32.

1 Like