Skip to content

Fix for libusb_get_port_numbers on macOS 26+#1700

Closed
mvp wants to merge 1 commit intolibusb:masterfrom
mvp:fix_libusb_get_port_numbers_macos_26
Closed

Fix for libusb_get_port_numbers on macOS 26+#1700
mvp wants to merge 1 commit intolibusb:masterfrom
mvp:fix_libusb_get_port_numbers_macos_26

Conversation

@mvp
Copy link
Copy Markdown
Contributor

@mvp mvp commented Sep 16, 2025

macOS 26 has changed port number property name:

% diff -u /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks/IOKit.framework/Headers/usb/IOUSBHostFamilyDefinitions.h /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/System/Library/Frameworks/IOKit.framework/Headers/usb/IOUSBHostFamilyDefinitions.h
...
-#define kUSBHostPortPropertyPortNumber                          "port"
+#define kUSBHostPortPropertyPortNumber                          "usb-port-number"
...

Unfortunately, we cannot just use constant kUSBHostPortPropertyPortNumber in libusb code because it would mean that the same binary that works on macOS 15 will not work on macOS 26.

Solution is to use appropriate string for port number property depending on running OS version.

Copy link
Copy Markdown
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes looks good, but I do not have macOS 26 yet to verify.

Copy link
Copy Markdown
Contributor

@seanm seanm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your commit message is great, has lots of good info. But some of that info needs to be in the code as a comment.

@sbfkcel
Copy link
Copy Markdown

sbfkcel commented Sep 16, 2025

I also found some anomalies under macos26, but I am not sure if it is caused by the same problem.

macOS 26 has changed port number property name:
```
% diff -u /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks/IOKit.framework/Headers/usb/IOUSBHostFamilyDefinitions.h /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/System/Library/Frameworks/IOKit.framework/Headers/usb/IOUSBHostFamilyDefinitions.h
...
-#define kUSBHostPortPropertyPortNumber                          "port"
+#define kUSBHostPortPropertyPortNumber                          "usb-port-number"
...
```
Unfortunately, we cannot just use constant `kUSBHostPortPropertyPortNumber`
in libusb code because it would mean that the same binary that works on macOS 15
will not work on macOS 26.

Solution is to use appropriate string for port number property depending on running OS version.
@mvp mvp force-pushed the fix_libusb_get_port_numbers_macos_26 branch from 5e39e09 to b6b65b5 Compare September 16, 2025 20:15
@mvp
Copy link
Copy Markdown
Contributor Author

mvp commented Sep 16, 2025

Your commit message is great, has lots of good info. But some of that info needs to be in the code as a comment.

Added comments, and also signed my commit (had to force push).

@mvp mvp requested a review from seanm September 16, 2025 20:19
@mvp
Copy link
Copy Markdown
Contributor Author

mvp commented Sep 17, 2025

Need someone to kick off workflows please @seanm, @mcuee.

Another question: is it possible to publish new official libusb version which includes this fix? I'm getting a lot of requests for uhubctl broken on macOS 26.

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Sep 18, 2025

I am upgrading my Mac Mini M1 to macOS 26 now. Just upgraded to 15.7.

This is the result of under 15.7.

mcuee@Macmini libusb/libusb  - (master)> ./examples/listdevs 
0781:5581 (bus 2, device 11) path: 2.4.5.1
1915:1025 (bus 2, device 10) path: 2.4.7
046d:c52b (bus 2, device 9) path: 2.4.3
1a40:0201 (bus 2, device 8) path: 2.4.5
05e3:0749 (bus 2, device 7) path: 6.1.2
1a40:0201 (bus 2, device 5) path: 2.4
0bda:5411 (bus 2, device 4) path: 2.1
0bda:5411 (bus 2, device 3) path: 2
0bda:0411 (bus 2, device 2) path: 6.1
0bda:0411 (bus 2, device 1) path: 6

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Sep 18, 2025

Just upgraded to macOS 26 and now I can reproduce the issue.

mcuee@Macmini libusb/libusb  - (master)> sw_vers 
ProductName:		macOS
ProductVersion:		26.0
BuildVersion:		25A354

mcuee@Macmini libusb/libusb  - (master)> ./examples/listdevs 
0781:5581 (bus 2, device 10)
1915:1025 (bus 2, device 9)
046d:c52b (bus 2, device 8)
1a40:0201 (bus 2, device 7)
1a40:0201 (bus 2, device 5)
0bda:5411 (bus 2, device 4)
0bda:5411 (bus 2, device 3)
0bda:0411 (bus 2, device 2)
0bda:0411 (bus 2, device 1)

And this PR is good.

mcuee@Macmini libusb/libusb_pr1700  - (fix_libusb_get_port_numbers_macos_26)> ./examples/listdevs 
0781:5581 (bus 2, device 10) path: 2.4.5.1
1915:1025 (bus 2, device 9) path: 2.4.7
046d:c52b (bus 2, device 8) path: 2.4.3
1a40:0201 (bus 2, device 7) path: 2.4.5
1a40:0201 (bus 2, device 5) path: 2.4
0bda:5411 (bus 2, device 4) path: 2.1
0bda:5411 (bus 2, device 3) path: 2
0bda:0411 (bus 2, device 2) path: 6.1
0bda:0411 (bus 2, device 1) path: 6

@mcuee
Copy link
Copy Markdown
Member

mcuee commented Sep 18, 2025

@seanm

I think you can merge this PR. Thanks.

@sonatique sonatique closed this in a409dbb Sep 18, 2025
@mvp mvp deleted the fix_libusb_get_port_numbers_macos_26 branch September 18, 2025 22:39
Chris-AC9KH pushed a commit to JS8Call-improved/libusb that referenced this pull request Feb 21, 2026
macOS 26 has changed port number property name:
```
% diff -u
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/
Frameworks/IOKit.framework/Headers/usb/IOUSBHostFamilyDefinitions.h
/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/System/Library/
Frameworks/IOKit.framework/Headers/usb/IOUSBHostFamilyDefinitions.h
...
-#define kUSBHostPortPropertyPortNumber                "port"
+#define kUSBHostPortPropertyPortNumber                "usb-port-number"
...
```
Unfortunately, we cannot just use constant `kUSBHostPortPropertyPortNumber`
in libusb code because it would mean that the same binary that works on
macOS 15 will not work on macOS 26.

Solution is to use appropriate string for port number property depending
on running OS version.

Closes libusb#1700

References libusb#1661
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants