@@ -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+
15461576static 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
16061640static void hidraw_set_quirks (struct hidraw_device * impl , DWORD bus_type , WORD vid , WORD pid )
0 commit comments