Thank VikingOSX for your reply.
But I need to find the BSD name of a USB disk from some fixed information, namely a unique number. In this case, we use the serial number of the USB disk.
In new versions of macOS, I could not determine the rule that connects the serial number with the BSD name. For example, when I run the command 'system_profiler SPUSBHostDataType -detailLevel full' in the terminal, I obtain the following information:
//------------------------------------------------------
USB 3.1 Bus:
Location ID: 0x00000000
Connection Type: Built-in
Driver: AppleT8112USBXHCI
Sabrent:
Location ID: 0x00100000
Connection Type: Removable
Manufacturer: Sabrent
Serial Number: 012345678922
Link Speed: 480 Mb/s
USB Vendor ID: 0x0bda
USB Product ID: 0x9210
USB Product Version: 0x2100
Power Allocated: 2.5 W (500 mA)
//------------------------------------------------------
I can identify the USB disk I want from its serial number, but the information is insufficient to determine the BSD name of the disk. Alternatively, when I run the command 'system_profiler SPStorageDataType' in the terminal, the output is as follows:
//--------------------------------------------------------
SSI_Disk02:
Free: 231.91 GB (231,913,226,240 bytes)
Capacity: 240.02 GB (240,023,306,240 bytes)
Mount Point: /Volumes/SSI_Disk02
File System: ExFAT
Writable: Yes
Ignore Ownership: Yes
BSD Name: disk4s2
Volume UUID: B1BFBA4E-54DD-3A1C-861A-18EBFC7F3670
Physical Drive:
Media Name: Sabrent Media
Protocol: USB
Internal: No
Partition Map Type: GPT (GUID Partition Table)
//-----------------------------------------------------------------------
The data display the BSD name of the USB disk, but I cannot be certain that the disk is my intended target. This issue may arise when two identical USB disks are connected.
I need some methods to connect the serial number and the BSD name of a USB disk. C or C++ example code would also be helpful.
Thanks again.