Skip to content

Commit ccfe78a

Browse files
Claire GirkaClearlyClaire
authored andcommitted
[draft] winebus: store container sysfs path from udev backend.
Store the sysfs path of container USB devices detected by the udev backend so a container ID can be assigned.
1 parent defd8a8 commit ccfe78a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

dlls/winebus.sys/bus_udev.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,36 @@ static const struct hid_device_vtbl lnxev_device_vtbl =
15431543
};
15441544
#endif /* HAS_PROPER_INPUT_HEADER */
15451545

1546+
static void get_device_container_syspath(const char *syspath, struct device_desc *desc)
1547+
{
1548+
char path[MAX_PATH], buffer[10], *p;
1549+
1550+
if (strlen(syspath) + strlen("/removable") + 1 > MAX_PATH)
1551+
return;
1552+
1553+
strcpy(path, syspath);
1554+
1555+
while ((p = strrchr(path, '/'))) {
1556+
FILE *f;
1557+
1558+
strcpy(p, "/removable");
1559+
f = fopen(path, "r");
1560+
*p = 0;
1561+
1562+
if (f) {
1563+
if (fgets(buffer, 10, f) && strcmp(buffer, "fixed") != 0) {
1564+
/* It's a potentially removable device, so treat it as a container */
1565+
fclose(f);
1566+
break;
1567+
}
1568+
fclose(f);
1569+
}
1570+
}
1571+
1572+
if (p && (p - path) > 12)
1573+
lstrcpynA(desc->container_syspath, path, sizeof(desc->container_syspath));
1574+
}
1575+
15461576
static void get_device_subsystem_info(struct udev_device *dev, char const *subsystem, struct device_desc *desc,
15471577
int *bus)
15481578
{
@@ -1601,6 +1631,10 @@ static void get_device_subsystem_info(struct udev_device *dev, char const *subsy
16011631

16021632
if (!desc->serialnumber[0] && (tmp = udev_device_get_sysattr_value(dev, "serial")))
16031633
ntdll_umbstowcs(tmp, strlen(tmp) + 1, desc->serialnumber, ARRAY_SIZE(desc->serialnumber));
1634+
1635+
if (!desc->container_syspath[0] && (tmp = udev_device_get_syspath(dev))) {
1636+
get_device_container_syspath(tmp, desc);
1637+
}
16041638
}
16051639

16061640
static void hidraw_set_quirks(struct hidraw_device *impl, DWORD bus_type, WORD vid, WORD pid)

dlls/winebus.sys/unixlib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct device_desc
4242
WCHAR manufacturer[MAX_PATH];
4343
WCHAR product[MAX_PATH];
4444
WCHAR serialnumber[MAX_PATH];
45+
char container_syspath[MAX_PATH];
4546
};
4647

4748
struct sdl_bus_options

0 commit comments

Comments
 (0)