Skip to content

Commit d54dcd5

Browse files
authored
Merge pull request #61 from davidgfnet/master
Minor fixes and changes for the PC side software
2 parents 4ea253f + 0471faf commit d54dcd5

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

.github/workflows/compilation.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Set up Cygwin
4141
uses: egor-tensin/setup-cygwin@v4
4242
with:
43-
packages: gcc-core gcc-g++ make libreadline8 libreadline-devel libusb1.0 libusb1.0-devel libncursesw10
43+
packages: gcc-core gcc-g++ make libreadline8 libreadline-devel libusb1.0 libusb1.0-devel
4444

4545
- name: Compile project
4646
run: |
@@ -49,12 +49,15 @@ jobs:
4949
mkdir build
5050
cp usbhostfs_pc\usbhostfs_pc.exe build
5151
cp pspsh\pspsh.exe build
52-
cp C:\tools\cygwin\bin\cygwin1.dll build
53-
cp C:\tools\cygwin\bin\cygstdc++-6.dll build
54-
cp C:\tools\cygwin\bin\cyggcc_s-seh-1.dll build
55-
cp C:\tools\cygwin\bin\cygreadline8.dll build
56-
cp C:\tools\cygwin\bin\cygusb-1.0.dll build
57-
cp C:\tools\cygwin\bin\cygncursesw-10.dll build
52+
53+
- name: Collect and copy Cygwin DLL dependencies
54+
shell: C:\tools\cygwin\bin\bash.exe --norc -eo pipefail -o igncr '{0}'
55+
run: |
56+
for exe in build/usbhostfs_pc.exe build/pspsh.exe; do
57+
cygcheck "$exe" | grep -E '\.dll$' | grep "\\\\cyg" | while read -r dll; do
58+
[[ -f "$dll" ]] && cp "$dll" build/
59+
done
60+
done
5861
5962
- name: Upload artifacts
6063
if: ${{ success() }}

usbhostfs_pc/main.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
#define MAX_TOKENS 256
5959

6060
#define BASE_PORT 10000
61+
#define USB_CONFIG_NUM 1
62+
#define USB_IFACE_NUM 0
6163

6264
#ifdef __CYGWIN__
6365
#define USB_TIMEOUT 1000
@@ -272,14 +274,25 @@ libusb_device_handle *open_device(libusb_device *usbdev)
272274
return NULL;
273275
}
274276
if (!r) {
275-
r = libusb_set_configuration(ret, 1);
277+
int cfgn;
278+
r = libusb_get_configuration(ret, &cfgn);
276279
if (r) {
277280
seteuid(getuid());
278281
setegid(getgid());
279-
fprintf(stderr, "Failed at selecting USB configuration: %d\n", r);
282+
fprintf(stderr, "Failed at reading selected USB configuration: %d\n", r);
280283
return NULL;
281284
}
282-
r = libusb_claim_interface(ret, 0);
285+
if (cfgn != USB_CONFIG_NUM)
286+
{
287+
r = libusb_set_configuration(ret, 1);
288+
if (r) {
289+
seteuid(getuid());
290+
setegid(getgid());
291+
fprintf(stderr, "Failed at selecting USB configuration: %d\n", r);
292+
return NULL;
293+
}
294+
}
295+
r = libusb_claim_interface(ret, USB_IFACE_NUM);
283296
if (r) {
284297
seteuid(getuid());
285298
setegid(getgid());

0 commit comments

Comments
 (0)