[2nd try with text/plain attachment] Hi,
the attached patch adds device_id() for Cygwin. Tested with 32- and 64-bit Cygwin.
Should be safe to include in 1.21 as no other platform is affected. Regards, Christian PS: No issues found in 1.21-pre2 so far
2015-12-16 Christian Franke <fra...@computer.org> * non_posix.cc: Add device_id() for Cygwin. diff --git a/non_posix.cc b/non_posix.cc index 480c71d..80fe4a7 100644 --- a/non_posix.cc +++ b/non_posix.cc @@ -56,6 +56,39 @@ const char * device_id( const int fd ) return id_str.c_str(); } +#elif defined(__CYGWIN__) + +#include <io.h> +#include <windows.h> + +const char * device_id( const int fd ) + { + HANDLE h = (HANDLE) _get_osfhandle( fd ); + if( h == INVALID_HANDLE_VALUE ) + return 0; + + STORAGE_PROPERTY_QUERY query = { StorageDeviceProperty, PropertyStandardQuery, {0} }; + union { + char raw[256]; + STORAGE_DEVICE_DESCRIPTOR desc; + } data = {0, }; + DWORD nout = 0; + + if( !DeviceIoControl( h, IOCTL_STORAGE_QUERY_PROPERTY, &query, sizeof(query), + &data, sizeof(data), &nout, (LPOVERLAPPED)0 ) ) + return 0; + + if( !data.desc.VendorIdOffset || !data.desc.ProductIdOffset ) + return 0; + + static std::string id_str; + id_str = &data.raw[data.desc.VendorIdOffset]; + id_str += ' '; + id_str += &data.raw[data.desc.ProductIdOffset]; + sanitize_string(id_str); + return id_str.c_str(); + } + #else // use linux by default #include <linux/hdreg.h>
_______________________________________________ Bug-ddrescue mailing list Bug-ddrescue@gnu.org https://lists.gnu.org/mailman/listinfo/bug-ddrescue