mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 19:24:37 +00:00
Add packet to close device.
This commit is contained in:
9
device.c
9
device.c
@@ -32,6 +32,15 @@ int DeviceOpen(const char* device_path)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceClose(int device_fd)
|
||||||
|
{
|
||||||
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
return LinuxCloseDevice(device_fd);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int32_t GetDeviceType(const char* device_path)
|
int32_t GetDeviceType(const char* device_path)
|
||||||
{
|
{
|
||||||
#if defined(__linux__) && !defined(__ANDROID__)
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
#define DICMOTE_PACKET_TYPE_RESPONSE_GET_FIREWIRE_DATA 22
|
#define DICMOTE_PACKET_TYPE_RESPONSE_GET_FIREWIRE_DATA 22
|
||||||
#define DICMOTE_PACKET_TYPE_COMMAND_GET_PCMCIA_DATA 23
|
#define DICMOTE_PACKET_TYPE_COMMAND_GET_PCMCIA_DATA 23
|
||||||
#define DICMOTE_PACKET_TYPE_RESPONSE_GET_PCMCIA_DATA 24
|
#define DICMOTE_PACKET_TYPE_RESPONSE_GET_PCMCIA_DATA 24
|
||||||
|
#define DICMOTE_PACKET_TYPE_COMMAND_CLOSE_DEVICE 25
|
||||||
#define DICMOTE_PROTOCOL_MAX 1
|
#define DICMOTE_PROTOCOL_MAX 1
|
||||||
#define DICMOTE_PACKET_NOP_REASON_OOO 0
|
#define DICMOTE_PACKET_NOP_REASON_OOO 0
|
||||||
#define DICMOTE_PACKET_NOP_REASON_NOT_IMPLEMENTED 1
|
#define DICMOTE_PACKET_NOP_REASON_NOT_IMPLEMENTED 1
|
||||||
@@ -418,12 +419,18 @@ typedef struct
|
|||||||
char cis[65536];
|
char cis[65536];
|
||||||
} DicPacketResGetPcmciaData;
|
} DicPacketResGetPcmciaData;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
DicPacketHeader hdr;
|
||||||
|
} DicPacketCmdClose;
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
DeviceInfoList* ListDevices();
|
DeviceInfoList* ListDevices();
|
||||||
void FreeDeviceInfoList(DeviceInfoList* start);
|
void FreeDeviceInfoList(DeviceInfoList* start);
|
||||||
uint16_t DeviceInfoListCount(DeviceInfoList* start);
|
uint16_t DeviceInfoListCount(DeviceInfoList* start);
|
||||||
int DeviceOpen(const char* device_path);
|
int DeviceOpen(const char* device_path);
|
||||||
|
void DeviceClose(int device_fd);
|
||||||
int32_t GetDeviceType(const char* device_path);
|
int32_t GetDeviceType(const char* device_path);
|
||||||
int32_t SendScsiCommand(int device_fd,
|
int32_t SendScsiCommand(int device_fd,
|
||||||
char* cdb,
|
char* cdb,
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ int LinuxOpenDevice(const char* device_path)
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinuxCloseDevice(int device_fd) { close(device_fd); }
|
||||||
|
|
||||||
int32_t LinuxGetDeviceType(const char* device_path)
|
int32_t LinuxGetDeviceType(const char* device_path)
|
||||||
{
|
{
|
||||||
#ifdef HAS_UDEV
|
#ifdef HAS_UDEV
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
DeviceInfoList* LinuxListDevices();
|
DeviceInfoList* LinuxListDevices();
|
||||||
|
|
||||||
int LinuxOpenDevice(const char* device_path);
|
int LinuxOpenDevice(const char* device_path);
|
||||||
|
void LinuxCloseDevice(int device_fd);
|
||||||
|
|
||||||
int32_t LinuxGetDeviceType(const char* device_path);
|
int32_t LinuxGetDeviceType(const char* device_path);
|
||||||
|
|
||||||
|
|||||||
4
worker.c
4
worker.c
@@ -1019,6 +1019,10 @@ void* WorkingLoop(void* arguments)
|
|||||||
free(pkt_cmd_sdhci);
|
free(pkt_cmd_sdhci);
|
||||||
free(pkt_res_sdhci);
|
free(pkt_res_sdhci);
|
||||||
continue;
|
continue;
|
||||||
|
case DICMOTE_PACKET_TYPE_COMMAND_CLOSE_DEVICE:
|
||||||
|
DeviceClose(device_fd);
|
||||||
|
skip_next_hdr = 1;
|
||||||
|
continue;
|
||||||
default:
|
default:
|
||||||
pkt_nop->reason_code = DICMOTE_PACKET_NOP_REASON_NOT_RECOGNIZED;
|
pkt_nop->reason_code = DICMOTE_PACKET_NOP_REASON_NOT_RECOGNIZED;
|
||||||
memset(&pkt_nop->reason, 0, 256);
|
memset(&pkt_nop->reason, 0, 256);
|
||||||
|
|||||||
Reference in New Issue
Block a user