mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 19:24:37 +00:00
Use opaque packet for device context.
This commit is contained in:
41
linux/usb.c
41
linux/usb.c
@@ -23,23 +23,26 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
uint8_t LinuxGetUsbData(const char* device_path,
|
||||
uint16_t* desc_len,
|
||||
char* descriptors,
|
||||
uint16_t* id_vendor,
|
||||
uint16_t* id_product,
|
||||
char* manufacturer,
|
||||
char* product,
|
||||
char* serial)
|
||||
uint8_t LinuxGetUsbData(void* device_ctx,
|
||||
uint16_t* desc_len,
|
||||
char* descriptors,
|
||||
uint16_t* id_vendor,
|
||||
uint16_t* id_product,
|
||||
char* manufacturer,
|
||||
char* product,
|
||||
char* serial)
|
||||
{
|
||||
char* dev_path;
|
||||
char tmp_path[4096];
|
||||
char resolved_link[4096];
|
||||
struct stat sb;
|
||||
ssize_t len;
|
||||
char* rchr;
|
||||
int found = 1;
|
||||
FILE* file;
|
||||
LinuxDeviceContext* ctx = device_ctx;
|
||||
char* dev_path;
|
||||
char tmp_path[4096];
|
||||
char resolved_link[4096];
|
||||
struct stat sb;
|
||||
ssize_t len;
|
||||
char* rchr;
|
||||
int found = 1;
|
||||
FILE* file;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
*desc_len = 0;
|
||||
*id_vendor = 0;
|
||||
@@ -47,11 +50,11 @@ uint8_t LinuxGetUsbData(const char* device_path,
|
||||
memset(tmp_path, 0, 4096);
|
||||
memset(resolved_link, 0, 4096);
|
||||
|
||||
if(strncmp(device_path, "/dev/sd", 7) != 0 && strncmp(device_path, "/dev/sr", 7) != 0 &&
|
||||
strncmp(device_path, "/dev/st", 7) != 0)
|
||||
if(strncmp(ctx->device_path, "/dev/sd", 7) != 0 && strncmp(ctx->device_path, "/dev/sr", 7) != 0 &&
|
||||
strncmp(ctx->device_path, "/dev/st", 7) != 0)
|
||||
return 0;
|
||||
|
||||
dev_path = (char*)device_path + 5;
|
||||
dev_path = (char*)ctx->device_path + 5;
|
||||
|
||||
snprintf(tmp_path, 4096, "/sys/block/%s", dev_path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user