this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

IOKit: "BSD Names" support

+18
+17
src/IOKit/io_device.cpp
··· 3 3 #include <cstring> 4 4 #include "cfutil.h" 5 5 6 + static CFTypeRef ListDevSymlinks(io_device* d, CFAllocatorRef a); 7 + 6 8 static const property_mapping generic_properties[] = { 7 9 property_mapping{ CFSTR("IOVendor"), [](io_device* d, CFAllocatorRef a) -> CFTypeRef { if (const char* name = d->property("ID_VENDOR")) return strToCF(name, a); else return strToCF(d->property("ID_VENDOR_FROM_DATABASE"), a); } }, 8 10 property_mapping{ CFSTR("IOModel"), [](io_device* d, CFAllocatorRef a) -> CFTypeRef { if (const char* name = d->property("ID_MODEL")) return strToCF(name, a); else return strToCF(d->property("ID_MODEL_FROM_DATABASE"), a); } }, 9 11 property_mapping{ CFSTR("BSD Name"), [](io_device* d, CFAllocatorRef a) -> CFTypeRef { if (const char* name = d->sysname()) return strToCF(name, a); else return strToCF(d->property("INTERFACE"), a); } }, // name or property INTERFACE 12 + property_mapping{ CFSTR("BSD Names"), ListDevSymlinks }, 10 13 property_mapping{ CFSTR("BSD Major"), [](io_device* d, CFAllocatorRef a) -> CFTypeRef { return intToCF(d->property("MAJOR"), a); } }, 11 14 property_mapping{ CFSTR("BSD Minor"), [](io_device* d, CFAllocatorRef a) -> CFTypeRef { return intToCF(d->property("MINOR"), a); } }, 12 15 }; ··· 138 141 { 139 142 return retrieve(generic_properties, sizeof(generic_properties) / sizeof(generic_properties[0]), name, allocator); 140 143 } 144 + 145 + CFTypeRef ListDevSymlinks(io_device* d, CFAllocatorRef a) 146 + { 147 + CFMutableDictionaryRef dict = CFDictionaryCreateMutable(a, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 148 + struct udev_list_entry* e = udev_device_get_devlinks_list_entry(d->device()); 149 + 150 + while (e != nullptr) 151 + { 152 + CFDictionarySetValue(dict, strToCF(udev_list_entry_get_name(e)), strToCF(udev_list_entry_get_value(e))); 153 + e = udev_list_entry_get_next(e); 154 + } 155 + 156 + return dict; 157 + }
+1
src/IOKit/io_device.h
··· 23 23 const char* sysattr(const char* name); 24 24 CFStringRef sysattrStr(const char* name, CFAllocatorRef allocator); 25 25 CFNumberRef sysattrNum(const char* name, CFAllocatorRef allocator); 26 + inline struct udev_device* device() { return m_device; } 26 27 protected: 27 28 CFTypeRef retrieve(const property_mapping* mapping, CFAllocatorRef allocator); 28 29 CFTypeRef retrieve(const property_mapping* mapping, size_t count, CFStringRef name, CFAllocatorRef allocator);