declare not working in 64-bit

Hello,
the following function, (maoslib-64bit, macOSFolderitemExtension) works OK when compiling in 32-bit, but it crashes in 64-bit: see below <<< crash here >>>, where OSError is supposed to return as 0 (zero).
I hope declare-expert people may find the stumbling block in order to fix it.
Help greatly appreciated. Thanks.
Sierra, Xojo 2017 2.1

[code]Public Function DeviceName(extends f as FolderItem) as String
//# DeviceName returns the BSD name of the volume containing f as found in the directory /dev. Only local volumes have such names.

#if TargetMacOS
soft declare function PBHGetVolParmsSync lib CarbonLib (ByRef paramBlock as HIOParam) as Short

dim paramBlock as HIOParam
paramBlock.ioVRefNum = f.MacVRefNum
//the following line is a trick to work around the inability to assign a pointer to a structure
//to a field of type Ptr.
dim infoBuffer as new MemoryBlock(GetVolParmsInfoBuffer.Size)
paramBlock.ioBuffer = infoBuffer
paramBlock.ioReqCount = infoBuffer.Size

dim OSError as integer = PBHGetVolParmsSync(paramBlock)//<<< crash here >>>//commenting these four lines, compilation proceeds OK
if OSError <> 0 then
  return ""
end if

dim infoBufferPtr as GetVolParmsInfoBuffer = paramBlock.ioBuffer.GetVolParmsInfoBuffer(0)
if infoBufferPtr.vMServerAddr = 0 then
  if infoBufferPtr.vMDeviceID <> nil then
    dim s as MemoryBlock = infoBufferPtr.vMDeviceID
    dim BSDName as String = s.CString(0)
    return DefineEncoding(BSDName, Encodings.SystemDefault)
  else
    return ""
  end if
else
  // vMServerAddr <> 0 means it's a network device, which apparently won't have a BSD name.
  return ""
end if

#else
#pragma unused f
#endif
End Function[/code]

The old PB… calls do no longer exist on 64 bit macOS.
You need to switch to a modern API.

So I’ll have to wait when somebody will make them available. Since I’m not expert enough to deal with such beasts.

What is wrong with

MsgBox Volume( 0 ).Name

On my Mac it displays SSD256 as it should.

You just have to figure out WHICH volume you want …

Volume(0).name (or f.name) and BSDName (above in the function) are different things. In 32-bit, BSDName results as something like disk2xx; in 64-bit, if I comment the OSError lines, it returns “”.

MsgBox Volume(0).DarwinVolumeNameMBS

gives disk1 in case you use MBS Plugins.

Yes, also the code above (32-bit) gives disk1 for volume(0), disk2xx for an external USB drive (xx stand for letters I don’t remember right now), and so on. But in 64-bit… crash.

Well, this should not that hard to get the name with a few declares. There should ne no need for a plugin at all.
As workaround you can use also a shell call, e.g.

$ /usr/sbin/diskutil list / | head -1 /dev/disk2 (internal, virtual):

At present I’m using a shell with diskutil info, and from the shell result I extract the Device Identifier of the external drive.

Quick and dirty.
How about this (for my test in the open event of a Text Area):

[code] // see “man statfs”
soft declare function statfs lib “libc.dylib”(path as Ptr, buff as Ptr) as Int32

const statfsStructSize = 2168
dim statfsResult as new MemoryBlock(statfsStructSize)
dim path 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
me.AppendText “ok” + EndOfLine
else
me.AppendText “Error, check errno” + EndOfLine
return
end

me.AppendText “f_mntonname: “”” + DefineEncoding(statfsResult.StringValue(64, 90), Encodings.UTF8) + “”"" + EndOfLine
me.AppendText “f_mntfromname: “”” + DefineEncoding(statfsResult.StringValue(154, 90), Encodings.UTF8) + “”"" + EndOfLine
[/code]

Excellent!
Since I’ll actually parse external devices only, I added a pushbutton with a selectFolder dialog in order to pass the selected volume to your code (after putting it in a method and adding a parameter f as folderitem).
Then, since the original code needs only the last part of the deviceName, I just spitted it:

dim path as String = f.nativePath//f.shellpath

dim s() as String = splitB(DefineEncoding(statfsResult.StringValue(154, 90), Encodings.UTF8), “/”)
TextArea1.AppendText “f_mntfromname: “”” + s(s.Ubound) + “”"" + EndOfLine

Thank you very much

//replaced f.shellPath with f.nativePath