diff --git a/CMakeSettings.json b/CMakeSettings.json
index b1e83b7..55f07fd 100644
--- a/CMakeSettings.json
+++ b/CMakeSettings.json
@@ -1,52 +1,52 @@
{
"configurations": [
{
- "name": "x64-Debug",
- "generator": "Ninja",
- "configurationType": "Debug",
- "inheritEnvironments": [ "msvc_x64_x64" ],
- "buildRoot": "${projectDir}\\out\\build\\${name}",
- "installRoot": "${projectDir}\\out\\install\\${name}",
- "cmakeCommandArgs": "",
- "buildCommandArgs": "-v",
- "ctestCommandArgs": "",
- "variables": []
+ "name": "x64-Debug",
+ "generator": "Ninja",
+ "configurationType": "Debug",
+ "inheritEnvironments": ["msvc_x64_x64"],
+ "buildRoot": "${projectDir}\\out\\build\\${name}",
+ "installRoot": "${projectDir}\\out\\install\\${name}",
+ "cmakeCommandArgs": "",
+ "buildCommandArgs": "-v",
+ "ctestCommandArgs": "",
+ "variables": []
},
{
- "name": "x86-Debug",
- "generator": "Ninja",
- "configurationType": "Debug",
- "buildRoot": "${projectDir}\\out\\build\\${name}",
- "installRoot": "${projectDir}\\out\\install\\${name}",
- "cmakeCommandArgs": "",
- "buildCommandArgs": "-v",
- "ctestCommandArgs": "",
- "inheritEnvironments": [ "msvc_x86" ],
- "variables": []
+ "name": "x86-Debug",
+ "generator": "Ninja",
+ "configurationType": "Debug",
+ "buildRoot": "${projectDir}\\out\\build\\${name}",
+ "installRoot": "${projectDir}\\out\\install\\${name}",
+ "cmakeCommandArgs": "",
+ "buildCommandArgs": "-v",
+ "ctestCommandArgs": "",
+ "inheritEnvironments": ["msvc_x86"],
+ "variables": []
},
{
- "name": "arm-Debug",
- "generator": "Ninja",
- "configurationType": "Debug",
- "buildRoot": "${projectDir}\\out\\build\\${name}",
- "installRoot": "${projectDir}\\out\\install\\${name}",
- "cmakeCommandArgs": "",
- "buildCommandArgs": "-v",
- "ctestCommandArgs": "",
- "inheritEnvironments": [ "msvc_arm" ],
- "variables": []
+ "name": "arm-Debug",
+ "generator": "Ninja",
+ "configurationType": "Debug",
+ "buildRoot": "${projectDir}\\out\\build\\${name}",
+ "installRoot": "${projectDir}\\out\\install\\${name}",
+ "cmakeCommandArgs": "",
+ "buildCommandArgs": "-v",
+ "ctestCommandArgs": "",
+ "inheritEnvironments": ["msvc_arm"],
+ "variables": []
},
{
- "name": "arm64-Debug",
- "generator": "Ninja",
- "configurationType": "Debug",
- "buildRoot": "${projectDir}\\out\\build\\${name}",
- "installRoot": "${projectDir}\\out\\install\\${name}",
- "cmakeCommandArgs": "",
- "buildCommandArgs": "-v",
- "ctestCommandArgs": "",
- "inheritEnvironments": [ "msvc_arm64" ],
- "variables": []
+ "name": "arm64-Debug",
+ "generator": "Ninja",
+ "configurationType": "Debug",
+ "buildRoot": "${projectDir}\\out\\build\\${name}",
+ "installRoot": "${projectDir}\\out\\install\\${name}",
+ "cmakeCommandArgs": "",
+ "buildCommandArgs": "-v",
+ "ctestCommandArgs": "",
+ "inheritEnvironments": ["msvc_arm64"],
+ "variables": []
}
]
}
\ No newline at end of file
diff --git a/README.md b/README.md
index 1975e91..0188ff9 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,22 @@
Aaru Remote
====================
-The Aaru Remote is a slim miniature application designed to receive device commands from a remote [Aaru](https://github.com/aaru-dps/Aaru)
+The Aaru Remote is a slim miniature application designed to receive device commands from a
+remote [Aaru](https://github.com/aaru-dps/Aaru)
instance, sends it to a local device, and returns the data to the instance.
The main motivation for this is the desire to update Aaru to the latest and greatest features of .NET and C#.
This creates a problem, as some people have old devices that do not work in modern Linux distributions.
-This remote will be supported in older versions of Linux, and will in future versions be supported in FreeBSD, Windows, and possibly
+This remote will be supported in older versions of Linux, and will in future versions be supported in FreeBSD, Windows,
+and possibly
network-enabled game consoles (like PSP, Wii, etc).
While some people will suggest porting the whole Aaru to C or C++, that won't happen, and for the only situation that
would be needed (accessing devices where C# does not run) this slim is more than enough.
-The usage is very simple, just run the remote and it will listen for a connection over TCP/IP in port 6666, and print you
+The usage is very simple, just run the remote and it will listen for a connection over TCP/IP in port 6666, and print
+you
the available IPs. Running as non-root user only works with some SCSI devices, so better run as root.
On the other side, you can use the Aaru with the *remote* command and one of those IP addresses to test the
@@ -25,12 +28,13 @@ All commands that support devices are supported, with a URI with the following s
Feature matrix
==============
-| |Minimum OS*1| SCSI |CHS ATA |28-bit LBA ATA |48-bit LBA ATA |Secure Digital|MultiMediaCard|USB |FireWire |PCMCIA |Special*2|
-|------------|-----------------------|---------------|---------------|---------------|---------------|--------------|--------------|--------------------|--------------------|----------------|-------|
-|FreeBSD | 12 |Yes |Yes |Yes |Yes |Not yet |Not yet |Not yet*4|Not yet*4|No*5 ||
-|Linux |2.6 |Yes |Yes |Yes |Yes |Yes |Yes |Yes |Yes |Yes*6||
-|Nintendo Wii|4.3 |No*3|No*3|No*3|No*3|Not yet |Not yet |Not yet |No*3 |No*3 |Not yet|
-|Windows NT | XP |Yes |Yes |Yes |Yes |Yes |Yes |Yes |Not yet*4|No*5 ||
+
+| | Minimum OS*1 | SCSI | CHS ATA | 28-bit LBA ATA | 48-bit LBA ATA | Secure Digital | MultiMediaCard | USB | FireWire | PCMCIA | Special*2 |
+|--------------|-------------------------|-----------------|-----------------|-----------------|-----------------|----------------|----------------|----------------------|----------------------|------------------|----------------------|
+| FreeBSD | 12 | Yes | Yes | Yes | Yes | Not yet | Not yet | Not yet*4 | Not yet*4 | No*5 | |
+| Linux | 2.6 | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes*6 | |
+| Nintendo Wii | 4.3 | No*3 | No*3 | No*3 | No*3 | Not yet | Not yet | Not yet | No*3 | No*3 | Not yet |
+| Windows NT | XP | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Not yet*4 | No*5 | |
1. Minimum operating system version where aaruremote has been tested. May work on early version.
2. Special storage media only available on that environment.
@@ -41,6 +45,7 @@ Feature matrix
TODO
====
+
- More buffer overflow guards
- Support PSP
- Support Wii
diff --git a/codealike.json b/codealike.json
index 19921da..1996fe8 100644
--- a/codealike.json
+++ b/codealike.json
@@ -1 +1 @@
-{"projectId":"a013337c-1721-4682-9a63-b33e4a40f753","projectName":"aaruremote"}
\ No newline at end of file
+{"projectId": "a013337c-1721-4682-9a63-b33e4a40f753", "projectName": "aaruremote"}
\ No newline at end of file
diff --git a/freebsd/ata.c b/freebsd/ata.c
index fbe02f4..e9e91ba 100644
--- a/freebsd/ata.c
+++ b/freebsd/ata.c
@@ -32,31 +32,27 @@ static u_int32_t AtaProtocolToCamFlags(uint8_t protocol)
case AARUREMOTE_ATA_PROTOCOL_HARD_RESET:
case AARUREMOTE_ATA_PROTOCOL_NO_DATA:
case AARUREMOTE_ATA_PROTOCOL_SOFT_RESET:
- case AARUREMOTE_ATA_PROTOCOL_RETURN_RESPONSE: return CAM_DIR_NONE;
+ case AARUREMOTE_ATA_PROTOCOL_RETURN_RESPONSE:
+ return CAM_DIR_NONE;
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: return CAM_DIR_IN;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
+ return CAM_DIR_IN;
case AARUREMOTE_ATA_PROTOCOL_PIO_OUT:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: return CAM_DIR_OUT;
- default: return 0;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
+ return CAM_DIR_OUT;
+ default:
+ return 0;
}
}
-int32_t SendAtaChsCommand(void* device_ctx,
- AtaRegistersChs registers,
- AtaErrorRegistersChs* error_registers,
- uint8_t protocol,
- uint8_t transfer_register,
- char* buffer,
- uint32_t timeout,
- uint8_t transfer_blocks,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t* buf_len)
+int32_t SendAtaChsCommand(void *device_ctx, AtaRegistersChs registers, AtaErrorRegistersChs *error_registers,
+ uint8_t protocol, uint8_t transfer_register, char *buffer, uint32_t timeout,
+ uint8_t transfer_blocks, uint32_t *duration, uint32_t *sense, uint32_t *buf_len)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
*duration = 0;
*sense = false;
- union ccb* camccb;
+ union ccb *camccb;
int error;
int clock_error;
struct timespec start_tp;
@@ -76,7 +72,7 @@ int32_t SendAtaChsCommand(void* device_ctx,
camccb->ccb_h.retry_count = 1;
camccb->ccb_h.cbfcnp = NULL;
camccb->ccb_h.timeout = timeout;
- camccb->ataio.data_ptr = (u_int8_t*)buffer;
+ camccb->ataio.data_ptr = (u_int8_t *)buffer;
camccb->ataio.dxfer_len = *buf_len;
camccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
camccb->ataio.cmd.flags = CAM_ATAIO_NEEDRESULT;
@@ -86,8 +82,12 @@ int32_t SendAtaChsCommand(void* device_ctx,
case AARUREMOTE_ATA_PROTOCOL_DMA:
case AARUREMOTE_ATA_PROTOCOL_DMA_QUEUED:
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: camccb->ataio.cmd.flags |= CAM_ATAIO_DMA; break;
- case AARUREMOTE_ATA_PROTOCOL_FPDMA: camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA; break;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
+ camccb->ataio.cmd.flags |= CAM_ATAIO_DMA;
+ break;
+ case AARUREMOTE_ATA_PROTOCOL_FPDMA:
+ camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA;
+ break;
}
camccb->ataio.cmd.command = registers.command;
@@ -142,22 +142,14 @@ int32_t SendAtaChsCommand(void* device_ctx,
return error;
}
-int32_t SendAtaLba28Command(void* device_ctx,
- AtaRegistersLba28 registers,
- AtaErrorRegistersLba28* error_registers,
- uint8_t protocol,
- uint8_t transfer_register,
- char* buffer,
- uint32_t timeout,
- uint8_t transfer_blocks,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t* buf_len)
+int32_t SendAtaLba28Command(void *device_ctx, AtaRegistersLba28 registers, AtaErrorRegistersLba28 *error_registers,
+ uint8_t protocol, uint8_t transfer_register, char *buffer, uint32_t timeout,
+ uint8_t transfer_blocks, uint32_t *duration, uint32_t *sense, uint32_t *buf_len)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
*duration = 0;
*sense = false;
- union ccb* camccb;
+ union ccb *camccb;
int error;
int clock_error;
struct timespec start_tp;
@@ -177,7 +169,7 @@ int32_t SendAtaLba28Command(void* device_ctx,
camccb->ccb_h.retry_count = 1;
camccb->ccb_h.cbfcnp = NULL;
camccb->ccb_h.timeout = timeout;
- camccb->ataio.data_ptr = (u_int8_t*)buffer;
+ camccb->ataio.data_ptr = (u_int8_t *)buffer;
camccb->ataio.dxfer_len = *buf_len;
camccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
camccb->ataio.cmd.flags = CAM_ATAIO_NEEDRESULT;
@@ -187,8 +179,12 @@ int32_t SendAtaLba28Command(void* device_ctx,
case AARUREMOTE_ATA_PROTOCOL_DMA:
case AARUREMOTE_ATA_PROTOCOL_DMA_QUEUED:
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: camccb->ataio.cmd.flags |= CAM_ATAIO_DMA; break;
- case AARUREMOTE_ATA_PROTOCOL_FPDMA: camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA; break;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
+ camccb->ataio.cmd.flags |= CAM_ATAIO_DMA;
+ break;
+ case AARUREMOTE_ATA_PROTOCOL_FPDMA:
+ camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA;
+ break;
}
camccb->ataio.cmd.command = registers.command;
@@ -243,22 +239,14 @@ int32_t SendAtaLba28Command(void* device_ctx,
return error;
}
-int32_t SendAtaLba48Command(void* device_ctx,
- AtaRegistersLba48 registers,
- AtaErrorRegistersLba48* error_registers,
- uint8_t protocol,
- uint8_t transfer_register,
- char* buffer,
- uint32_t timeout,
- uint8_t transfer_blocks,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t* buf_len)
+int32_t SendAtaLba48Command(void *device_ctx, AtaRegistersLba48 registers, AtaErrorRegistersLba48 *error_registers,
+ uint8_t protocol, uint8_t transfer_register, char *buffer, uint32_t timeout,
+ uint8_t transfer_blocks, uint32_t *duration, uint32_t *sense, uint32_t *buf_len)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
*duration = 0;
*sense = false;
- union ccb* camccb;
+ union ccb *camccb;
int error;
int clock_error;
struct timespec start_tp;
@@ -280,7 +268,7 @@ int32_t SendAtaLba48Command(void* device_ctx,
camccb->ccb_h.retry_count = 1;
camccb->ccb_h.cbfcnp = NULL;
camccb->ccb_h.timeout = timeout;
- camccb->ataio.data_ptr = (u_int8_t*)buffer;
+ camccb->ataio.data_ptr = (u_int8_t *)buffer;
camccb->ataio.dxfer_len = *buf_len;
camccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
camccb->ataio.cmd.flags = CAM_ATAIO_NEEDRESULT | CAM_ATAIO_48BIT;
@@ -290,8 +278,12 @@ int32_t SendAtaLba48Command(void* device_ctx,
case AARUREMOTE_ATA_PROTOCOL_DMA:
case AARUREMOTE_ATA_PROTOCOL_DMA_QUEUED:
case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: camccb->ataio.cmd.flags |= CAM_ATAIO_DMA; break;
- case AARUREMOTE_ATA_PROTOCOL_FPDMA: camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA; break;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
+ camccb->ataio.cmd.flags |= CAM_ATAIO_DMA;
+ break;
+ case AARUREMOTE_ATA_PROTOCOL_FPDMA:
+ camccb->ataio.cmd.flags |= CAM_ATAIO_FPDMA;
+ break;
}
camccb->ataio.cmd.command = registers.command;
diff --git a/freebsd/device.c b/freebsd/device.c
index 1b29120..2cb8fbe 100644
--- a/freebsd/device.c
+++ b/freebsd/device.c
@@ -25,9 +25,9 @@
#include "../aaruremote.h"
#include "freebsd.h"
-void* DeviceOpen(const char* device_path)
+void *DeviceOpen(const char *device_path)
{
- DeviceContext* ctx;
+ DeviceContext *ctx;
ctx = malloc(sizeof(DeviceContext));
@@ -48,9 +48,9 @@ void* DeviceOpen(const char* device_path)
return ctx;
}
-void DeviceClose(void* device_ctx)
+void DeviceClose(void *device_ctx)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
if(!ctx) return;
@@ -59,10 +59,10 @@ void DeviceClose(void* device_ctx)
free(ctx);
}
-int32_t GetDeviceType(void* device_ctx)
+int32_t GetDeviceType(void *device_ctx)
{
- DeviceContext* ctx = device_ctx;
- union ccb* camccb;
+ DeviceContext *ctx = device_ctx;
+ union ccb *camccb;
int ret;
int32_t device_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN;
@@ -86,24 +86,34 @@ int32_t GetDeviceType(void* device_ctx)
switch(camccb->cgd.protocol)
{
case PROTO_ATA:
- case PROTO_SATAPM: device_type = AARUREMOTE_DEVICE_TYPE_ATA; break;
- case PROTO_ATAPI: device_type = AARUREMOTE_DEVICE_TYPE_ATAPI; break;
- case PROTO_SCSI: device_type = AARUREMOTE_DEVICE_TYPE_SCSI; break;
- case PROTO_NVME: device_type = AARUREMOTE_DEVICE_TYPE_NVME; break;
+ case PROTO_SATAPM:
+ device_type = AARUREMOTE_DEVICE_TYPE_ATA;
+ break;
+ case PROTO_ATAPI:
+ device_type = AARUREMOTE_DEVICE_TYPE_ATAPI;
+ break;
+ case PROTO_SCSI:
+ device_type = AARUREMOTE_DEVICE_TYPE_SCSI;
+ break;
+ case PROTO_NVME:
+ device_type = AARUREMOTE_DEVICE_TYPE_NVME;
+ break;
case PROTO_MMCSD:
// TODO: MMC vs SD
device_type = AARUREMOTE_DEVICE_TYPE_MMC;
break;
- default: device_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN; break;
+ default:
+ device_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN;
+ break;
}
cam_freeccb(camccb);
return device_type;
}
-int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
+int32_t ReOpen(void *device_ctx, uint32_t *closeFailed)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
int ret;
*closeFailed = 0;
@@ -116,9 +126,9 @@ int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
return ctx->device == 0 ? errno : 0;
}
-int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length, uint32_t* duration)
+int32_t OsRead(void *device_ctx, char *buffer, uint64_t offset, uint32_t length, uint32_t *duration)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
ssize_t ret;
*duration = 0;
off_t pos;
@@ -131,7 +141,7 @@ int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length,
if(pos < 0) return errno;
// TODO: Timing
- ret = read(ctx->device.fd, (void*)buffer, (size_t)length);
+ ret = read(ctx->device.fd, (void *)buffer, (size_t)length);
return ret < 0 ? errno : 0;
}
\ No newline at end of file
diff --git a/freebsd/freebsd.h b/freebsd/freebsd.h
index b7dcf20..52d7f93 100644
--- a/freebsd/freebsd.h
+++ b/freebsd/freebsd.h
@@ -19,7 +19,7 @@
#define AARUREMOTE_FREEBSD_FREEBSD_H_
// Included here as it seems to need to be after all others
-#ifndef _STDIO_H_
+#ifndef _STDIO_H_
#include
#endif
@@ -28,7 +28,7 @@
typedef struct
{
char device_path[4096];
- struct cam_device* device;
+ struct cam_device *device;
} DeviceContext;
-#endif // AARUREMOTE_FREEBSD_FREEBSD_H_
+#endif // AARUREMOTE_FREEBSD_FREEBSD_H_
diff --git a/freebsd/ieee1394.c b/freebsd/ieee1394.c
index ff17acb..44d5b7c 100644
--- a/freebsd/ieee1394.c
+++ b/freebsd/ieee1394.c
@@ -19,12 +19,8 @@
#include "../aaruremote.h"
-uint8_t GetFireWireData(void* device_ctx,
- uint32_t* id_model,
- uint32_t* id_vendor,
- uint64_t* guid,
- char* vendor,
- char* model)
+uint8_t GetFireWireData(void *device_ctx, uint32_t *id_model, uint32_t *id_vendor, uint64_t *guid, char *vendor,
+ char *model)
{
return 0;
}
diff --git a/freebsd/list_devices.c b/freebsd/list_devices.c
index 37d95cd..d2f7c21 100644
--- a/freebsd/list_devices.c
+++ b/freebsd/list_devices.c
@@ -25,13 +25,13 @@
#include "../aaruremote.h"
#include "freebsd.h"
-DeviceInfoList* ListDevices()
+DeviceInfoList *ListDevices()
{
- DeviceInfoList * list_start = NULL, *list_current = NULL, *list_next = NULL;
- DIR* dir;
- struct dirent* dirent;
- struct cam_device* camdev;
- union ccb* camccb;
+ DeviceInfoList *list_start = NULL, *list_current = NULL, *list_next = NULL;
+ DIR *dir;
+ struct dirent *dirent;
+ struct cam_device *camdev;
+ union ccb *camccb;
int ret;
int i;
@@ -89,7 +89,7 @@ DeviceInfoList* ListDevices()
continue;
}
- strncpy(list_next->this.serial, (const char*)camdev->serial_num, camdev->serial_num_len);
+ strncpy(list_next->this.serial, (const char *)camdev->serial_num, camdev->serial_num_len);
switch(camccb->cgd.protocol)
{
@@ -98,7 +98,7 @@ DeviceInfoList* ListDevices()
case PROTO_SATAPM:
// TODO: Split on space
strncpy(list_next->this.vendor, "ATA", 3);
- strncpy(list_next->this.model, (const char*)camccb->cgd.ident_data.model, 40);
+ strncpy(list_next->this.model, (const char *)camccb->cgd.ident_data.model, 40);
// Trim spaces
for(i = 40; i > 0; i--)
@@ -108,9 +108,10 @@ DeviceInfoList* ListDevices()
list_next->this.model[i] = 0;
}
- strncpy(list_next->this.serial, (const char*)camccb->cgd.ident_data.serial, 20);
+ strncpy(list_next->this.serial, (const char *)camccb->cgd.ident_data.serial, 20);
- if(strncmp(camdev->sim_name, "ahcich", 6) == 0) strncpy(list_next->this.bus, "SATA", 5);
+ if(strncmp(camdev->sim_name, "ahcich", 6) == 0)
+ strncpy(list_next->this.bus, "SATA", 5);
else
strncpy(list_next->this.bus, "ATA", 4);
diff --git a/freebsd/pcmcia.c b/freebsd/pcmcia.c
index d8a8fd1..28ea59a 100644
--- a/freebsd/pcmcia.c
+++ b/freebsd/pcmcia.c
@@ -19,4 +19,4 @@
#include "../aaruremote.h"
-uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis) { return 0; }
+uint8_t GetPcmciaData(void *device_ctx, uint16_t *cis_len, char *cis) { return 0; }
diff --git a/freebsd/scsi.c b/freebsd/scsi.c
index 356dbd3..3a0f276 100644
--- a/freebsd/scsi.c
+++ b/freebsd/scsi.c
@@ -25,24 +25,16 @@
#include "../aaruremote.h"
#include "freebsd.h"
-int32_t SendScsiCommand(void* device_ctx,
- char* cdb,
- char* buffer,
- char** sense_buffer,
- uint32_t timeout,
- int32_t direction,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t cdb_len,
- uint32_t* buf_len,
- uint32_t* sense_len)
+int32_t SendScsiCommand(void *device_ctx, char *cdb, char *buffer, char **sense_buffer, uint32_t timeout,
+ int32_t direction, uint32_t *duration, uint32_t *sense, uint32_t cdb_len, uint32_t *buf_len,
+ uint32_t *sense_len)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
*sense_len = 0;
*sense_buffer = NULL;
*duration = 0;
*sense = false;
- union ccb* camccb;
+ union ccb *camccb;
u_int32_t flags;
int error;
int clock_error;
@@ -52,10 +44,18 @@ int32_t SendScsiCommand(void* device_ctx,
switch(direction)
{
- case AARUREMOTE_SCSI_DIRECTION_NONE: flags = CAM_DIR_NONE; break;
- case AARUREMOTE_SCSI_DIRECTION_OUT: flags = CAM_DIR_OUT; break;
- case AARUREMOTE_SCSI_DIRECTION_IN: flags = CAM_DIR_IN; break;
- case AARUREMOTE_SCSI_DIRECTION_INOUT: flags = CAM_DIR_BOTH; break;
+ case AARUREMOTE_SCSI_DIRECTION_NONE:
+ flags = CAM_DIR_NONE;
+ break;
+ case AARUREMOTE_SCSI_DIRECTION_OUT:
+ flags = CAM_DIR_OUT;
+ break;
+ case AARUREMOTE_SCSI_DIRECTION_IN:
+ flags = CAM_DIR_IN;
+ break;
+ case AARUREMOTE_SCSI_DIRECTION_INOUT:
+ flags = CAM_DIR_BOTH;
+ break;
}
if(!ctx) return -1;
@@ -75,16 +75,17 @@ int32_t SendScsiCommand(void* device_ctx,
camccb->ccb_h.retry_count = 1;
camccb->ccb_h.cbfcnp = NULL;
camccb->ccb_h.timeout = timeout;
- camccb->csio.data_ptr = (u_int8_t*)buffer;
+ camccb->csio.data_ptr = (u_int8_t *)buffer;
camccb->csio.dxfer_len = *buf_len;
camccb->csio.sense_len = 32;
camccb->csio.cdb_len = cdb_len;
camccb->csio.tag_action = 0x20;
- if(cdb_len <= CAM_MAX_CDBLEN) memcpy(camccb->csio.cdb_io.cdb_bytes, cdb, cdb_len);
+ if(cdb_len <= CAM_MAX_CDBLEN)
+ memcpy(camccb->csio.cdb_io.cdb_bytes, cdb, cdb_len);
else
{
- camccb->csio.cdb_io.cdb_ptr = (u_int8_t*)cdb;
+ camccb->csio.cdb_io.cdb_ptr = (u_int8_t *)cdb;
camccb->ccb_h.flags |= CAM_CDB_POINTER;
}
@@ -127,8 +128,7 @@ int32_t SendScsiCommand(void* device_ctx,
*sense = (camccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR;
*sense_buffer = malloc(camccb->csio.sense_len - camccb->csio.sense_resid);
(*sense_buffer)[0] = camccb->csio.sense_data.error_code;
- memcpy((*sense_buffer) + 1,
- camccb->csio.sense_data.sense_buf,
+ memcpy((*sense_buffer) + 1, camccb->csio.sense_data.sense_buf,
(camccb->csio.sense_len - camccb->csio.sense_resid) - 1);
}
diff --git a/freebsd/sdhci.c b/freebsd/sdhci.c
index 3282199..5ec320c 100644
--- a/freebsd/sdhci.c
+++ b/freebsd/sdhci.c
@@ -19,42 +19,21 @@
#include "../aaruremote.h"
-int32_t SendSdhciCommand(void* device_ctx,
- uint8_t command,
- uint8_t write,
- uint8_t application,
- uint32_t flags,
- uint32_t argument,
- uint32_t block_size,
- uint32_t blocks,
- char* buffer,
- uint32_t buf_len,
- uint32_t timeout,
- uint32_t* response,
- uint32_t* duration,
- uint32_t* sense)
+int32_t SendSdhciCommand(void *device_ctx, uint8_t command, uint8_t write, uint8_t application, uint32_t flags,
+ uint32_t argument, uint32_t block_size, uint32_t blocks, char *buffer, uint32_t buf_len,
+ uint32_t timeout, uint32_t *response, uint32_t *duration, uint32_t *sense)
{
return -1;
}
-int32_t GetSdhciRegisters(void* device_ctx,
- char** csd,
- char** cid,
- char** ocr,
- char** scr,
- uint32_t* csd_len,
- uint32_t* cid_len,
- uint32_t* ocr_len,
- uint32_t* scr_len)
+int32_t GetSdhciRegisters(void *device_ctx, char **csd, char **cid, char **ocr, char **scr, uint32_t *csd_len,
+ uint32_t *cid_len, uint32_t *ocr_len, uint32_t *scr_len)
{
return -1;
}
-int32_t SendMultiSdhciCommand(void* device_ctx,
- uint64_t count,
- MmcSingleCommand commands[],
- uint32_t* duration,
- uint32_t* sense)
+int32_t SendMultiSdhciCommand(void *device_ctx, uint64_t count, MmcSingleCommand commands[], uint32_t *duration,
+ uint32_t *sense)
{
return -1;
}
\ No newline at end of file
diff --git a/freebsd/usb.c b/freebsd/usb.c
index 43c1838..2923952 100644
--- a/freebsd/usb.c
+++ b/freebsd/usb.c
@@ -19,14 +19,8 @@
#include "../aaruremote.h"
-uint8_t GetUsbData(void* device_ctx,
- uint16_t* desc_len,
- char* descriptors,
- uint16_t* id_vendor,
- uint16_t* id_product,
- char* manufacturer,
- char* product,
- char* serial)
+uint8_t GetUsbData(void *device_ctx, uint16_t *desc_len, char *descriptors, uint16_t *id_vendor, uint16_t *id_product,
+ char *manufacturer, char *product, char *serial)
{
return 0;
}
diff --git a/linux/ata.c b/linux/ata.c
index f0b733f..7fd3b90 100644
--- a/linux/ata.c
+++ b/linux/ata.c
@@ -29,33 +29,29 @@ int32_t AtaProtocolToScsiDirection(uint8_t protocol)
case AARUREMOTE_ATA_PROTOCOL_HARD_RESET:
case AARUREMOTE_ATA_PROTOCOL_NO_DATA:
case AARUREMOTE_ATA_PROTOCOL_SOFT_RESET:
- case AARUREMOTE_ATA_PROTOCOL_RETURN_RESPONSE: return AARUREMOTE_SCSI_DIRECTION_NONE;
+ case AARUREMOTE_ATA_PROTOCOL_RETURN_RESPONSE:
+ return AARUREMOTE_SCSI_DIRECTION_NONE;
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: return AARUREMOTE_SCSI_DIRECTION_IN;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
+ return AARUREMOTE_SCSI_DIRECTION_IN;
case AARUREMOTE_ATA_PROTOCOL_PIO_OUT:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT: return AARUREMOTE_SCSI_DIRECTION_OUT;
- default: return AARUREMOTE_SCSI_DIRECTION_UNSPECIFIED;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_OUT:
+ return AARUREMOTE_SCSI_DIRECTION_OUT;
+ default:
+ return AARUREMOTE_SCSI_DIRECTION_UNSPECIFIED;
}
}
-int32_t SendAtaChsCommand(void* device_ctx,
- AtaRegistersChs registers,
- AtaErrorRegistersChs* error_registers,
- uint8_t protocol,
- uint8_t transfer_register,
- char* buffer,
- uint32_t timeout,
- uint8_t transfer_blocks,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t* buf_len)
+int32_t SendAtaChsCommand(void *device_ctx, AtaRegistersChs registers, AtaErrorRegistersChs *error_registers,
+ uint8_t protocol, uint8_t transfer_register, char *buffer, uint32_t timeout,
+ uint8_t transfer_blocks, uint32_t *duration, uint32_t *sense, uint32_t *buf_len)
{
*duration = 0;
*sense = 0;
unsigned char cdb[16];
- char* sense_buf;
+ char *sense_buf;
uint32_t sense_len;
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
if(!ctx) return -1;
@@ -68,8 +64,12 @@ int32_t SendAtaChsCommand(void* device_ctx,
switch(protocol)
{
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: cdb[2] = 0x08; break;
- default: cdb[2] = 0x00; break;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
+ cdb[2] = 0x08;
+ break;
+ default:
+ cdb[2] = 0x00;
+ break;
}
if(transfer_blocks) cdb[2] |= 0x04;
@@ -85,17 +85,8 @@ int32_t SendAtaChsCommand(void* device_ctx,
cdb[13] = registers.device_head;
cdb[14] = registers.command;
- int error = SendScsiCommand(ctx,
- (char*)cdb,
- buffer,
- &sense_buf,
- timeout,
- AtaProtocolToScsiDirection(protocol),
- duration,
- sense,
- 16,
- buf_len,
- &sense_len);
+ int error = SendScsiCommand(ctx, (char *)cdb, buffer, &sense_buf, timeout, AtaProtocolToScsiDirection(protocol),
+ duration, sense, 16, buf_len, &sense_len);
if(sense_len < 22 || (sense_buf[8] != 0x09 && sense_buf[9] != 0x0C)) return error;
@@ -113,24 +104,16 @@ int32_t SendAtaChsCommand(void* device_ctx,
return error;
}
-int32_t SendAtaLba28Command(void* device_ctx,
- AtaRegistersLba28 registers,
- AtaErrorRegistersLba28* error_registers,
- uint8_t protocol,
- uint8_t transfer_register,
- char* buffer,
- uint32_t timeout,
- uint8_t transfer_blocks,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t* buf_len)
+int32_t SendAtaLba28Command(void *device_ctx, AtaRegistersLba28 registers, AtaErrorRegistersLba28 *error_registers,
+ uint8_t protocol, uint8_t transfer_register, char *buffer, uint32_t timeout,
+ uint8_t transfer_blocks, uint32_t *duration, uint32_t *sense, uint32_t *buf_len)
{
*duration = 0;
*sense = 0;
unsigned char cdb[16];
- char* sense_buf;
+ char *sense_buf;
uint32_t sense_len;
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
if(!ctx) return -1;
@@ -143,8 +126,12 @@ int32_t SendAtaLba28Command(void* device_ctx,
switch(protocol)
{
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: cdb[2] = 0x08; break;
- default: cdb[2] = 0x00; break;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
+ cdb[2] = 0x08;
+ break;
+ default:
+ cdb[2] = 0x00;
+ break;
}
if(transfer_blocks) cdb[2] |= 0x04;
@@ -162,17 +149,8 @@ int32_t SendAtaLba28Command(void* device_ctx,
cdb[13] = registers.device_head;
cdb[14] = registers.command;
- int error = SendScsiCommand(ctx,
- (char*)cdb,
- buffer,
- &sense_buf,
- timeout,
- AtaProtocolToScsiDirection(protocol),
- duration,
- sense,
- 16,
- buf_len,
- &sense_len);
+ int error = SendScsiCommand(ctx, (char *)cdb, buffer, &sense_buf, timeout, AtaProtocolToScsiDirection(protocol),
+ duration, sense, 16, buf_len, &sense_len);
if(sense_len < 22 || (sense_buf[8] != 0x09 && sense_buf[9] != 0x0C)) return error;
@@ -190,24 +168,16 @@ int32_t SendAtaLba28Command(void* device_ctx,
return error;
}
-int32_t SendAtaLba48Command(void* device_ctx,
- AtaRegistersLba48 registers,
- AtaErrorRegistersLba48* error_registers,
- uint8_t protocol,
- uint8_t transfer_register,
- char* buffer,
- uint32_t timeout,
- uint8_t transfer_blocks,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t* buf_len)
+int32_t SendAtaLba48Command(void *device_ctx, AtaRegistersLba48 registers, AtaErrorRegistersLba48 *error_registers,
+ uint8_t protocol, uint8_t transfer_register, char *buffer, uint32_t timeout,
+ uint8_t transfer_blocks, uint32_t *duration, uint32_t *sense, uint32_t *buf_len)
{
*duration = 0;
*sense = 0;
unsigned char cdb[16];
- char* sense_buf;
+ char *sense_buf;
uint32_t sense_len;
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
if(!ctx) return -1;
@@ -221,8 +191,12 @@ int32_t SendAtaLba48Command(void* device_ctx,
switch(protocol)
{
case AARUREMOTE_ATA_PROTOCOL_PIO_IN:
- case AARUREMOTE_ATA_PROTOCOL_UDMA_IN: cdb[2] = 0x08; break;
- default: cdb[2] = 0x00; break;
+ case AARUREMOTE_ATA_PROTOCOL_UDMA_IN:
+ cdb[2] = 0x08;
+ break;
+ default:
+ cdb[2] = 0x00;
+ break;
}
if(transfer_blocks) cdb[2] |= 0x04;
@@ -245,17 +219,8 @@ int32_t SendAtaLba48Command(void* device_ctx,
cdb[13] = registers.device_head;
cdb[14] = registers.command;
- int error = SendScsiCommand(ctx,
- (char*)cdb,
- buffer,
- &sense_buf,
- timeout,
- AtaProtocolToScsiDirection(protocol),
- duration,
- sense,
- 16,
- buf_len,
- &sense_len);
+ int error = SendScsiCommand(ctx, (char *)cdb, buffer, &sense_buf, timeout, AtaProtocolToScsiDirection(protocol),
+ duration, sense, 16, buf_len, &sense_len);
if(sense_len < 22 || (sense_buf[8] != 0x09 && sense_buf[9] != 0x0C)) return error;
diff --git a/linux/device.c b/linux/device.c
index a8c630b..4871e09 100644
--- a/linux/device.c
+++ b/linux/device.c
@@ -30,9 +30,9 @@
#include "../aaruremote.h"
#include "linux.h"
-void* DeviceOpen(const char* device_path)
+void *DeviceOpen(const char *device_path)
{
- DeviceContext* ctx;
+ DeviceContext *ctx;
char *real_device_path = realpath(device_path, NULL);
if(real_device_path != NULL)
@@ -68,9 +68,9 @@ void* DeviceOpen(const char* device_path)
return ctx;
}
-void DeviceClose(void* device_ctx)
+void DeviceClose(void *device_ctx)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
if(!ctx) return;
@@ -79,17 +79,17 @@ void DeviceClose(void* device_ctx)
free(ctx);
}
-int32_t GetDeviceType(void* device_ctx)
+int32_t GetDeviceType(void *device_ctx)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
if(!ctx) return -1;
#ifdef HAS_UDEV
- struct udev* udev;
- struct udev_device* udev_device;
- const char* tmp_string;
- char* chrptr;
+ struct udev *udev;
+ struct udev_device *udev_device;
+ const char *tmp_string;
+ char *chrptr;
int32_t device_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN;
udev = udev_new();
@@ -112,7 +112,7 @@ int32_t GetDeviceType(void* device_ctx)
{
device_type = AARUREMOTE_DEVICE_TYPE_ATA;
- free((void*)tmp_string);
+ free((void *)tmp_string);
tmp_string = udev_device_get_property_value(udev_device, "ID_TYPE");
if(tmp_string)
@@ -120,30 +120,30 @@ int32_t GetDeviceType(void* device_ctx)
// TODO: ATAPI removable non optical disks
if(strncmp(tmp_string, "cd", 2) == 0) { device_type = AARUREMOTE_DEVICE_TYPE_ATAPI; }
- free((void*)tmp_string);
+ free((void *)tmp_string);
}
}
else if(strncmp(tmp_string, "mmc", 3) == 0)
{
- free((void*)tmp_string);
+ free((void *)tmp_string);
tmp_string = malloc(1024);
device_type = AARUREMOTE_DEVICE_TYPE_MMC;
if(tmp_string)
{
- memset((void*)tmp_string, 0, 1024);
- snprintf((char*)tmp_string, 1024, "/sys/block/%s/device/scr", chrptr);
+ memset((void *)tmp_string, 0, 1024);
+ snprintf((char *)tmp_string, 1024, "/sys/block/%s/device/scr", chrptr);
if(access(tmp_string, R_OK) == 0) device_type = AARUREMOTE_DEVICE_TYPE_SECURE_DIGITAL;
- free((void*)tmp_string);
+ free((void *)tmp_string);
}
}
else if(strncmp(tmp_string, "scsi", 4) == 0 || strncmp(tmp_string, "ieee1394", 8) == 0 ||
strncmp(tmp_string, "usb", 3) == 0)
{
- free((void*)tmp_string);
+ free((void *)tmp_string);
tmp_string = udev_device_get_property_value(udev_device, "ID_TYPE");
if(tmp_string)
@@ -152,12 +152,12 @@ int32_t GetDeviceType(void* device_ctx)
strncmp(tmp_string, "optical", 7) == 0)
device_type = AARUREMOTE_DEVICE_TYPE_SCSI;
- free((void*)tmp_string);
+ free((void *)tmp_string);
}
}
else if(strncmp(tmp_string, "nvme", 4) == 0)
{
- free((void*)tmp_string);
+ free((void *)tmp_string);
device_type = AARUREMOTE_DEVICE_TYPE_NVME;
}
}
@@ -168,20 +168,20 @@ int32_t GetDeviceType(void* device_ctx)
return device_type;
#else
int32_t dev_type = AARUREMOTE_DEVICE_TYPE_UNKNOWN;
- const char* dev_name;
- const char* sysfs_path;
- char* dev_path;
- char* dev_path2;
- char* host_no;
- char* scsi_path;
- char* iscsi_path;
- char* spi_path;
- char* fc_path;
- char* sas_path;
+ const char *dev_name;
+ const char *sysfs_path;
+ char *dev_path;
+ char *dev_path2;
+ char *host_no;
+ char *scsi_path;
+ char *iscsi_path;
+ char *spi_path;
+ char *fc_path;
+ char *sas_path;
int ret;
- char* chrptr;
- char* sysfs_path_scr;
- FILE* file;
+ char *chrptr;
+ char *sysfs_path_scr;
+ FILE *file;
size_t len = 4096;
if(strlen(ctx->device_path) <= 5) return dev_type;
@@ -219,40 +219,40 @@ int32_t GetDeviceType(void* device_ctx)
if(!sysfs_path || !dev_path || !host_no || !scsi_path || !iscsi_path || !spi_path || !fc_path || !sas_path)
{
- free((void*)sysfs_path);
- free((void*)dev_path);
- free((void*)host_no);
- free((void*)iscsi_path);
- free((void*)scsi_path);
- free((void*)spi_path);
- free((void*)fc_path);
- free((void*)sas_path);
+ free((void *)sysfs_path);
+ free((void *)dev_path);
+ free((void *)host_no);
+ free((void *)iscsi_path);
+ free((void *)scsi_path);
+ free((void *)spi_path);
+ free((void *)fc_path);
+ free((void *)sas_path);
return dev_type;
}
- memset((void*)sysfs_path, 0, len);
- memset((void*)dev_path, 0, len);
- memset((void*)host_no, 0, len);
- memset((void*)iscsi_path, 0, len);
- memset((void*)scsi_path, 0, len);
- memset((void*)spi_path, 0, len);
- memset((void*)fc_path, 0, len);
- memset((void*)sas_path, 0, len);
+ memset((void *)sysfs_path, 0, len);
+ memset((void *)dev_path, 0, len);
+ memset((void *)host_no, 0, len);
+ memset((void *)iscsi_path, 0, len);
+ memset((void *)scsi_path, 0, len);
+ memset((void *)spi_path, 0, len);
+ memset((void *)fc_path, 0, len);
+ memset((void *)sas_path, 0, len);
- snprintf((char*)sysfs_path, len, "%s/%s/device", PATH_SYS_DEVBLOCK, dev_name);
+ snprintf((char *)sysfs_path, len, "%s/%s/device", PATH_SYS_DEVBLOCK, dev_name);
ret = readlink(sysfs_path, dev_path, len);
if(ret <= 0)
{
- free((void*)sysfs_path);
- free((void*)dev_path);
- free((void*)host_no);
- free((void*)iscsi_path);
- free((void*)scsi_path);
- free((void*)spi_path);
- free((void*)fc_path);
- free((void*)sas_path);
+ free((void *)sysfs_path);
+ free((void *)dev_path);
+ free((void *)host_no);
+ free((void *)iscsi_path);
+ free((void *)scsi_path);
+ free((void *)spi_path);
+ free((void *)fc_path);
+ free((void *)sas_path);
return dev_type;
}
@@ -275,14 +275,14 @@ int32_t GetDeviceType(void* device_ctx)
if(!chrptr)
{
- free((void*)sysfs_path);
- free((void*)dev_path);
- free((void*)host_no);
- free((void*)iscsi_path);
- free((void*)scsi_path);
- free((void*)spi_path);
- free((void*)fc_path);
- free((void*)sas_path);
+ free((void *)sysfs_path);
+ free((void *)dev_path);
+ free((void *)host_no);
+ free((void *)iscsi_path);
+ free((void *)scsi_path);
+ free((void *)spi_path);
+ free((void *)fc_path);
+ free((void *)sas_path);
return dev_type;
}
@@ -339,22 +339,22 @@ int32_t GetDeviceType(void* device_ctx)
}
}
- free((void*)sysfs_path);
- free((void*)dev_path);
- free((void*)host_no);
- free((void*)iscsi_path);
- free((void*)scsi_path);
- free((void*)spi_path);
- free((void*)fc_path);
- free((void*)sas_path);
+ free((void *)sysfs_path);
+ free((void *)dev_path);
+ free((void *)host_no);
+ free((void *)iscsi_path);
+ free((void *)scsi_path);
+ free((void *)spi_path);
+ free((void *)fc_path);
+ free((void *)sas_path);
return dev_type;
#endif
}
-int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
+int32_t ReOpen(void *device_ctx, uint32_t *closeFailed)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
int ret;
*closeFailed = 0;
@@ -375,9 +375,9 @@ int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
return ctx->fd <= 0 ? errno : 0;
}
-int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length, uint32_t* duration)
+int32_t OsRead(void *device_ctx, char *buffer, uint64_t offset, uint32_t length, uint32_t *duration)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
ssize_t ret;
*duration = 0;
off_t pos;
@@ -390,7 +390,7 @@ int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length,
if(pos < 0) return errno;
// TODO: Timing
- ret = read(ctx->fd, (void*)buffer, (size_t)length);
+ ret = read(ctx->fd, (void *)buffer, (size_t)length);
return ret < 0 ? errno : 0;
}
\ No newline at end of file
diff --git a/linux/ieee1394.c b/linux/ieee1394.c
index 38d7479..bb06b6f 100644
--- a/linux/ieee1394.c
+++ b/linux/ieee1394.c
@@ -24,22 +24,18 @@
#include "../aaruremote.h"
#include "linux.h"
-uint8_t GetFireWireData(void* device_ctx,
- uint32_t* id_model,
- uint32_t* id_vendor,
- uint64_t* guid,
- char* vendor,
- char* model)
+uint8_t GetFireWireData(void *device_ctx, uint32_t *id_model, uint32_t *id_vendor, uint64_t *guid, char *vendor,
+ char *model)
{
- DeviceContext* ctx = device_ctx;
- char* dev_path;
+ DeviceContext *ctx = device_ctx;
+ char *dev_path;
char tmp_path[4096];
char resolved_link[4096];
struct stat sb;
ssize_t len;
- char* rchr;
+ char *rchr;
int found;
- FILE* file;
+ FILE *file;
if(!ctx) return 0;
@@ -53,7 +49,7 @@ uint8_t GetFireWireData(void* device_ctx,
strncmp(ctx->device_path, "/dev/st", 7) != 0)
return 0;
- dev_path = (char*)ctx->device_path + 5;
+ dev_path = (char *)ctx->device_path + 5;
snprintf(tmp_path, 4096, "/sys/block/%s", dev_path);
diff --git a/linux/linux.h b/linux/linux.h
index 750a831..aa277c6 100644
--- a/linux/linux.h
+++ b/linux/linux.h
@@ -26,4 +26,4 @@ typedef struct
char device_path[4096];
} DeviceContext;
-#endif // AARUREMOTE_LINUX_LINUX_H_
+#endif // AARUREMOTE_LINUX_LINUX_H_
diff --git a/linux/list_devices.c b/linux/list_devices.c
index 7d77e3c..64ef280 100644
--- a/linux/list_devices.c
+++ b/linux/list_devices.c
@@ -31,21 +31,21 @@
#include "../aaruremote.h"
#include "linux.h"
-DeviceInfoList* ListDevices()
+DeviceInfoList *ListDevices()
{
- DIR* dir;
- struct dirent* dirent;
+ DIR *dir;
+ struct dirent *dirent;
int i;
DeviceInfoList *list_start = NULL, *list_current = NULL, *list_next = NULL;
- const char* tmp_string;
- FILE* file;
- char* line_str;
+ const char *tmp_string;
+ FILE *file;
+ char *line_str;
size_t n, ret;
- char* chrptr;
+ char *chrptr;
int has_udev = 0;
#ifdef HAS_UDEV
- struct udev* udev;
- struct udev_device* udev_device;
+ struct udev *udev;
+ struct udev_device *udev_device;
udev = udev_new();
has_udev = udev != 0;
@@ -95,14 +95,14 @@ DeviceInfoList* ListDevices()
if(tmp_string)
{
strncpy(list_next->this.vendor, tmp_string, 256);
- free((void*)tmp_string);
+ free((void *)tmp_string);
}
tmp_string = udev_device_get_property_value(udev_device, "ID_MODEL");
if(tmp_string)
{
strncpy(list_next->this.model, tmp_string, 256);
- free((void*)tmp_string);
+ free((void *)tmp_string);
for(i = 0; i < 256; i++)
{
@@ -116,7 +116,7 @@ DeviceInfoList* ListDevices()
if(tmp_string)
{
strncpy(list_next->this.serial, tmp_string, 256);
- free((void*)tmp_string);
+ free((void *)tmp_string);
}
else
{
@@ -124,7 +124,7 @@ DeviceInfoList* ListDevices()
if(tmp_string)
{
strncpy(list_next->this.serial, tmp_string, 256);
- free((void*)tmp_string);
+ free((void *)tmp_string);
}
}
@@ -132,11 +132,11 @@ DeviceInfoList* ListDevices()
if(tmp_string)
{
strncpy(list_next->this.bus, tmp_string, 256);
- free((void*)tmp_string);
+ free((void *)tmp_string);
}
}
}
-#else // Use sysfs
+#else // Use sysfs
if(!has_udev && !strstr(dirent->d_name, "loop"))
{
memset((void*)tmp_ctx.device_path, 0, 4096);
@@ -144,11 +144,19 @@ DeviceInfoList* ListDevices()
switch(GetDeviceType(&tmp_ctx))
{
- case AARUREMOTE_DEVICE_TYPE_ATA: strncpy(list_next->this.bus, "ATA", 256); break;
- case AARUREMOTE_DEVICE_TYPE_ATAPI: strncpy(list_next->this.bus, "ATAPI", 256); break;
+ case AARUREMOTE_DEVICE_TYPE_ATA:
+ strncpy(list_next->this.bus, "ATA", 256);
+ break;
+ case AARUREMOTE_DEVICE_TYPE_ATAPI:
+ strncpy(list_next->this.bus, "ATAPI", 256);
+ break;
case AARUREMOTE_DEVICE_TYPE_MMC:
- case AARUREMOTE_DEVICE_TYPE_SECURE_DIGITAL: strncpy(list_next->this.bus, "MMC/SD", 256); break;
- case AARUREMOTE_DEVICE_TYPE_NVME: strncpy(list_next->this.bus, "NVMe", 256); break;
+ case AARUREMOTE_DEVICE_TYPE_SECURE_DIGITAL:
+ strncpy(list_next->this.bus, "MMC/SD", 256);
+ break;
+ case AARUREMOTE_DEVICE_TYPE_NVME:
+ strncpy(list_next->this.bus, "NVMe", 256);
+ break;
case AARUREMOTE_DEVICE_TYPE_SCSI:
tmp_string = malloc(1024);
memset((void*)tmp_string, 0, 1024);
@@ -175,10 +183,10 @@ DeviceInfoList* ListDevices()
chrptr--;
}
- memset((void*)tmp_string, 0, 1024);
- memcpy((void*)tmp_string, chrptr, ret);
- snprintf((char*)line_str, 1024, "/sys/class/scsi_host/host%s/proc_name", tmp_string);
- memset((void*)tmp_string, 0, 1024);
+ memset((void *)tmp_string, 0, 1024);
+ memcpy((void *)tmp_string, chrptr, ret);
+ snprintf((char *)line_str, 1024, "/sys/class/scsi_host/host%s/proc_name", tmp_string);
+ memset((void *)tmp_string, 0, 1024);
file = fopen(line_str, "r");
if(file)
@@ -188,7 +196,8 @@ DeviceInfoList* ListDevices()
if(ret > 0)
{
- if(strncmp(line_str, "sbp2", 4) == 0) strncpy(list_next->this.bus, "FireWire", 256);
+ if(strncmp(line_str, "sbp2", 4) == 0)
+ strncpy(list_next->this.bus, "FireWire", 256);
else if(strncmp(line_str, "usb-storage", 11) == 0)
strncpy(list_next->this.bus, "USB", 256);
else
@@ -212,14 +221,16 @@ DeviceInfoList* ListDevices()
free((void*)tmp_string);
break;
- default: memset(&list_next->this.bus, 0, 256); break;
+ default:
+ memset(&list_next->this.bus, 0, 256);
+ break;
}
}
#endif
tmp_string = malloc(1024);
- memset((void*)tmp_string, 0, 1024);
- snprintf((char*)tmp_string, 1024, "%s/%s/device/vendor", PATH_SYS_DEVBLOCK, dirent->d_name);
+ memset((void *)tmp_string, 0, 1024);
+ snprintf((char *)tmp_string, 1024, "%s/%s/device/vendor", PATH_SYS_DEVBLOCK, dirent->d_name);
if(access(tmp_string, R_OK) == 0 && strlen(list_next->this.vendor) == 0)
{
@@ -237,7 +248,8 @@ DeviceInfoList* ListDevices()
strncpy(list_next->this.vendor, line_str, 256);
for(i = 255; i >= 0; i--)
{
- if(list_next->this.vendor[i] == 0) continue;
+ if(list_next->this.vendor[i] == 0)
+ continue;
else if(list_next->this.vendor[i] == 0x0A || list_next->this.vendor[i] == 0x0D ||
list_next->this.vendor[i] == ' ')
@@ -251,15 +263,12 @@ DeviceInfoList* ListDevices()
fclose(file);
}
}
- else if(strncmp(dirent->d_name, "loop", 4) == 0)
- {
- strncpy(list_next->this.vendor, "Linux", 256);
- }
- free((void*)tmp_string);
+ else if(strncmp(dirent->d_name, "loop", 4) == 0) { strncpy(list_next->this.vendor, "Linux", 256); }
+ free((void *)tmp_string);
tmp_string = malloc(1024);
- memset((void*)tmp_string, 0, 1024);
- snprintf((char*)tmp_string, 1024, "%s/%s/device/model", PATH_SYS_DEVBLOCK, dirent->d_name);
+ memset((void *)tmp_string, 0, 1024);
+ snprintf((char *)tmp_string, 1024, "%s/%s/device/model", PATH_SYS_DEVBLOCK, dirent->d_name);
if(access(tmp_string, R_OK) == 0 &&
(strlen(list_next->this.model) == 0 || strncmp(list_next->this.bus, "ata", 3) == 0))
@@ -278,7 +287,8 @@ DeviceInfoList* ListDevices()
strncpy(list_next->this.model, line_str, 256);
for(i = 255; i >= 0; i--)
{
- if(list_next->this.model[i] == 0) continue;
+ if(list_next->this.model[i] == 0)
+ continue;
else if(list_next->this.model[i] == 0x0A || list_next->this.model[i] == 0x0D ||
list_next->this.model[i] == ' ')
@@ -292,15 +302,12 @@ DeviceInfoList* ListDevices()
fclose(file);
}
}
- else if(strncmp(dirent->d_name, "loop", 4) == 0)
- {
- strncpy(list_next->this.model, "Linux", 256);
- }
- free((void*)tmp_string);
+ else if(strncmp(dirent->d_name, "loop", 4) == 0) { strncpy(list_next->this.model, "Linux", 256); }
+ free((void *)tmp_string);
tmp_string = malloc(1024);
- memset((void*)tmp_string, 0, 1024);
- snprintf((char*)tmp_string, 1024, "%s/%s/device/serial", PATH_SYS_DEVBLOCK, dirent->d_name);
+ memset((void *)tmp_string, 0, 1024);
+ snprintf((char *)tmp_string, 1024, "%s/%s/device/serial", PATH_SYS_DEVBLOCK, dirent->d_name);
if(access(tmp_string, R_OK) == 0 && (strlen(list_next->this.serial) == 0))
{
@@ -318,7 +325,8 @@ DeviceInfoList* ListDevices()
strncpy(list_next->this.serial, line_str, 256);
for(i = 255; i >= 0; i--)
{
- if(list_next->this.serial[i] == 0) continue;
+ if(list_next->this.serial[i] == 0)
+ continue;
else if(list_next->this.serial[i] == 0x0A || list_next->this.serial[i] == 0x0D ||
list_next->this.serial[i] == ' ')
@@ -332,14 +340,14 @@ DeviceInfoList* ListDevices()
fclose(file);
}
}
- free((void*)tmp_string);
+ free((void *)tmp_string);
if(strlen(list_next->this.vendor) == 0 || strncmp(list_next->this.vendor, "ATA", 3) == 0)
{
if(strlen(list_next->this.model) > 0)
{
tmp_string = malloc(256);
- strncpy((void*)tmp_string, list_next->this.model, 256);
+ strncpy((void *)tmp_string, list_next->this.model, 256);
chrptr = strchr(tmp_string, ' ');
@@ -351,14 +359,15 @@ DeviceInfoList* ListDevices()
strncpy(list_next->this.model, chrptr + 1, 256 - (chrptr - tmp_string) - 1);
}
- free((void*)tmp_string);
+ free((void *)tmp_string);
}
}
// TODO: Get better device type from sysfs paths
if(strlen(list_next->this.bus) == 0)
{
- if(strncmp(dirent->d_name, "loop", 4) == 0) strncpy(list_next->this.bus, "loop", 4);
+ if(strncmp(dirent->d_name, "loop", 4) == 0)
+ strncpy(list_next->this.bus, "loop", 4);
else if(strncmp(dirent->d_name, "nvme", 4) == 0)
strncpy(list_next->this.bus, "NVMe", 4);
else if(strncmp(dirent->d_name, "mmc", 3) == 0)
diff --git a/linux/mmc/ioctl.h b/linux/mmc/ioctl.h
index 5f44dab..90e3ca6 100644
--- a/linux/mmc/ioctl.h
+++ b/linux/mmc/ioctl.h
@@ -55,6 +55,7 @@ struct mmc_ioc_cmd
/* DAT buffer */
uint64_t data_ptr;
};
+
#define mmc_ioc_cmd_set_data(ic, ptr) ic.data_ptr = (__u64)(unsigned long)ptr
/**
@@ -69,7 +70,7 @@ struct mmc_ioc_multi_cmd
struct mmc_ioc_cmd cmds[0];
};
-#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
+#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
/*
* MMC_IOC_MULTI_CMD: Used to send an array of MMC commands described by
* the structure mmc_ioc_multi_cmd. The MMC driver will issue all
@@ -83,7 +84,7 @@ struct mmc_ioc_multi_cmd
* block device operations.
*/
#define MMC_IOC_MAX_BYTES (512L * 1024)
-#define MMC_IOC_MAX_CMDS 255
+#define MMC_IOC_MAX_CMDS 255
#endif
-#endif // AARUREMOTE_LINUX_MMC_IOCTL_H_
+#endif // AARUREMOTE_LINUX_MMC_IOCTL_H_
diff --git a/linux/pcmcia.c b/linux/pcmcia.c
index 9575951..db45757 100644
--- a/linux/pcmcia.c
+++ b/linux/pcmcia.c
@@ -25,18 +25,18 @@
#include "../aaruremote.h"
#include "linux.h"
-uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis)
+uint8_t GetPcmciaData(void *device_ctx, uint16_t *cis_len, char *cis)
{
- DeviceContext* ctx = device_ctx;
- char* dev_path;
+ DeviceContext *ctx = device_ctx;
+ char *dev_path;
char tmp_path[4096];
char resolved_link[4096];
struct stat sb;
ssize_t len;
- char* rchr;
- FILE* file;
- DIR* dir;
- struct dirent* dent;
+ char *rchr;
+ FILE *file;
+ DIR *dir;
+ struct dirent *dent;
*cis_len = 0;
if(!ctx) return 0;
@@ -48,7 +48,7 @@ uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis)
strncmp(ctx->device_path, "/dev/st", 7) != 0)
return 0;
- dev_path = (char*)ctx->device_path + 5;
+ dev_path = (char *)ctx->device_path + 5;
snprintf(tmp_path, 4096, "/sys/block/%s", dev_path);
diff --git a/linux/scsi.c b/linux/scsi.c
index 11b31d3..67e9411 100644
--- a/linux/scsi.c
+++ b/linux/scsi.c
@@ -24,19 +24,11 @@
#include "../aaruremote.h"
#include "linux.h"
-int32_t SendScsiCommand(void* device_ctx,
- char* cdb,
- char* buffer,
- char** sense_buffer,
- uint32_t timeout,
- int32_t direction,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t cdb_len,
- uint32_t* buf_len,
- uint32_t* sense_len)
+int32_t SendScsiCommand(void *device_ctx, char *cdb, char *buffer, char **sense_buffer, uint32_t timeout,
+ int32_t direction, uint32_t *duration, uint32_t *sense, uint32_t cdb_len, uint32_t *buf_len,
+ uint32_t *sense_len)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
sg_io_hdr_t hdr;
int dir, ret;
*sense_len = 32;
@@ -50,12 +42,20 @@ int32_t SendScsiCommand(void* device_ctx,
switch(direction)
{
- case AARUREMOTE_SCSI_DIRECTION_IN: dir = SG_DXFER_FROM_DEV; break;
- case AARUREMOTE_SCSI_DIRECTION_OUT: dir = SG_DXFER_TO_DEV; break;
+ case AARUREMOTE_SCSI_DIRECTION_IN:
+ dir = SG_DXFER_FROM_DEV;
+ break;
+ case AARUREMOTE_SCSI_DIRECTION_OUT:
+ dir = SG_DXFER_TO_DEV;
+ break;
case AARUREMOTE_SCSI_DIRECTION_INOUT:
- case AARUREMOTE_SCSI_DIRECTION_UNSPECIFIED: dir = SG_DXFER_TO_FROM_DEV; break;
+ case AARUREMOTE_SCSI_DIRECTION_UNSPECIFIED:
+ dir = SG_DXFER_TO_FROM_DEV;
+ break;
case AARUREMOTE_SCSI_DIRECTION_NONE:
- default: dir = SG_DXFER_NONE; break;
+ default:
+ dir = SG_DXFER_NONE;
+ break;
}
hdr.interface_id = 'S';
@@ -64,17 +64,17 @@ int32_t SendScsiCommand(void* device_ctx,
hdr.dxfer_direction = dir;
hdr.dxfer_len = *buf_len;
hdr.dxferp = buffer;
- hdr.cmdp = (unsigned char*)cdb;
- hdr.sbp = (unsigned char*)*sense_buffer;
+ hdr.cmdp = (unsigned char *)cdb;
+ hdr.sbp = (unsigned char *)*sense_buffer;
hdr.timeout = timeout;
hdr.flags = SG_FLAG_DIRECT_IO;
ret = ioctl(ctx->fd, SG_IO, &hdr);
- *sense = (hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK;
+ *sense = (hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK;
// TODO: Manual timing if duration is 0
*duration = hdr.duration;
*sense_len = hdr.sb_len_wr;
- return ret; // TODO: Implement
+ return ret; // TODO: Implement
}
\ No newline at end of file
diff --git a/linux/sdhci.c b/linux/sdhci.c
index 1dc1996..7e9ae7d 100644
--- a/linux/sdhci.c
+++ b/linux/sdhci.c
@@ -27,22 +27,11 @@
#include "linux.h"
#include "mmc/ioctl.h"
-int32_t SendSdhciCommand(void* device_ctx,
- uint8_t command,
- uint8_t write,
- uint8_t application,
- uint32_t flags,
- uint32_t argument,
- uint32_t block_size,
- uint32_t blocks,
- char* buffer,
- uint32_t buf_len,
- uint32_t timeout,
- uint32_t* response,
- uint32_t* duration,
- uint32_t* sense)
+int32_t SendSdhciCommand(void *device_ctx, uint8_t command, uint8_t write, uint8_t application, uint32_t flags,
+ uint32_t argument, uint32_t block_size, uint32_t blocks, char *buffer, uint32_t buf_len,
+ uint32_t timeout, uint32_t *response, uint32_t *duration, uint32_t *sense)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
struct mmc_ioc_cmd mmc_ioc_cmd;
int32_t error;
*duration = 0;
@@ -74,29 +63,22 @@ int32_t SendSdhciCommand(void* device_ctx,
*sense = error < 0;
- memcpy((char*)response, (char*)&mmc_ioc_cmd.response, sizeof(uint32_t) * 4);
+ memcpy((char *)response, (char *)&mmc_ioc_cmd.response, sizeof(uint32_t) * 4);
return error;
}
-int32_t GetSdhciRegisters(void* device_ctx,
- char** csd,
- char** cid,
- char** ocr,
- char** scr,
- uint32_t* csd_len,
- uint32_t* cid_len,
- uint32_t* ocr_len,
- uint32_t* scr_len)
+int32_t GetSdhciRegisters(void *device_ctx, char **csd, char **cid, char **ocr, char **scr, uint32_t *csd_len,
+ uint32_t *cid_len, uint32_t *ocr_len, uint32_t *scr_len)
{
- DeviceContext* ctx = device_ctx;
- char* tmp_string;
- char* sysfs_path_csd;
- char* sysfs_path_cid;
- char* sysfs_path_scr;
- char* sysfs_path_ocr;
+ DeviceContext *ctx = device_ctx;
+ char *tmp_string;
+ char *sysfs_path_csd;
+ char *sysfs_path_cid;
+ char *sysfs_path_scr;
+ char *sysfs_path_ocr;
size_t len;
- FILE* file;
+ FILE *file;
*csd = NULL;
*cid = NULL;
*ocr = NULL;
@@ -149,7 +131,7 @@ int32_t GetSdhciRegisters(void* device_ctx,
len = getline(&tmp_string, &n, file);
if(len > 0)
{
- *csd_len = Hexs2Bin(tmp_string, (unsigned char**)csd);
+ *csd_len = Hexs2Bin(tmp_string, (unsigned char **)csd);
if(*csd_len <= 0)
{
@@ -171,7 +153,7 @@ int32_t GetSdhciRegisters(void* device_ctx,
len = getline(&tmp_string, &n, file);
if(len > 0)
{
- *cid_len = Hexs2Bin(tmp_string, (unsigned char**)cid);
+ *cid_len = Hexs2Bin(tmp_string, (unsigned char **)cid);
if(*cid_len <= 0)
{
@@ -193,7 +175,7 @@ int32_t GetSdhciRegisters(void* device_ctx,
len = getline(&tmp_string, &n, file);
if(len > 0)
{
- *scr_len = Hexs2Bin(tmp_string, (unsigned char**)scr);
+ *scr_len = Hexs2Bin(tmp_string, (unsigned char **)scr);
if(*scr_len <= 0)
{
@@ -215,7 +197,7 @@ int32_t GetSdhciRegisters(void* device_ctx,
len = getline(&tmp_string, &n, file);
if(len > 0)
{
- *ocr_len = Hexs2Bin(tmp_string, (unsigned char**)ocr);
+ *ocr_len = Hexs2Bin(tmp_string, (unsigned char **)ocr);
if(*ocr_len <= 0)
{
@@ -237,16 +219,13 @@ int32_t GetSdhciRegisters(void* device_ctx,
return csd_len != 0 || cid_len != 0 || scr_len != 0 || ocr_len != 0;
}
-int32_t SendMultiSdhciCommand(void* device_ctx,
- uint64_t count,
- MmcSingleCommand commands[],
- uint32_t* duration,
- uint32_t* sense)
+int32_t SendMultiSdhciCommand(void *device_ctx, uint64_t count, MmcSingleCommand commands[], uint32_t *duration,
+ uint32_t *sense)
{
- DeviceContext* ctx = device_ctx;
+ DeviceContext *ctx = device_ctx;
*duration = 0;
*sense = 0;
- struct mmc_ioc_multi_cmd* mmc_ioc_multi_cmd;
+ struct mmc_ioc_multi_cmd *mmc_ioc_multi_cmd;
uint64_t i;
int32_t error;
if(!ctx) return -1;
@@ -279,7 +258,7 @@ int32_t SendMultiSdhciCommand(void* device_ctx,
mmc_ioc_multi_cmd->cmds[i].cmd_timeout_ms = commands[i].timeout * 1000;
}
*/
- mmc_ioc_multi_cmd->cmds[i].data_ptr = (uint64_t)commands[i].buffer;
+ mmc_ioc_multi_cmd->cmds[i].data_ptr = (uint64_t)commands[i].buffer;
}
error = ioctl(ctx->fd, MMC_IOC_MULTI_CMD, mmc_ioc_multi_cmd);
@@ -289,7 +268,7 @@ int32_t SendMultiSdhciCommand(void* device_ctx,
*sense = error < 0;
for(i = 0; i < count; i++)
- memcpy((char*)commands[i].response, (char*)mmc_ioc_multi_cmd->cmds[i].response, sizeof(uint32_t) * 4);
+ memcpy((char *)commands[i].response, (char *)mmc_ioc_multi_cmd->cmds[i].response, sizeof(uint32_t) * 4);
return error;
}
diff --git a/linux/usb.c b/linux/usb.c
index 87a779f..b5e5569 100644
--- a/linux/usb.c
+++ b/linux/usb.c
@@ -24,24 +24,18 @@
#include "../aaruremote.h"
#include "linux.h"
-uint8_t GetUsbData(void* device_ctx,
- uint16_t* desc_len,
- char* descriptors,
- uint16_t* id_vendor,
- uint16_t* id_product,
- char* manufacturer,
- char* product,
- char* serial)
+uint8_t GetUsbData(void *device_ctx, uint16_t *desc_len, char *descriptors, uint16_t *id_vendor, uint16_t *id_product,
+ char *manufacturer, char *product, char *serial)
{
- DeviceContext* ctx = device_ctx;
- char* dev_path;
+ DeviceContext *ctx = device_ctx;
+ char *dev_path;
char tmp_path[4096];
char resolved_link[4096];
struct stat sb;
ssize_t len;
- char* rchr;
+ char *rchr;
int found = 1;
- FILE* file;
+ FILE *file;
if(!ctx) return -1;
@@ -55,7 +49,7 @@ uint8_t GetUsbData(void* device_ctx,
strncmp(ctx->device_path, "/dev/st", 7) != 0)
return 0;
- dev_path = (char*)ctx->device_path + 5;
+ dev_path = (char *)ctx->device_path + 5;
snprintf(tmp_path, 4096, "/sys/block/%s", dev_path);
diff --git a/unix/hello.c b/unix/hello.c
index 6504286..b02c843 100644
--- a/unix/hello.c
+++ b/unix/hello.c
@@ -26,11 +26,11 @@
#include "../aaruremote.h"
#include "../endian.h"
-AaruPacketHello* GetHello()
+AaruPacketHello *GetHello()
{
struct utsname utsname;
int ret;
- AaruPacketHello* pkt_server_hello;
+ AaruPacketHello *pkt_server_hello;
ret = uname(&utsname);
diff --git a/unix/network.c b/unix/network.c
index bfe6bd1..368d753 100644
--- a/unix/network.c
+++ b/unix/network.c
@@ -28,8 +28,8 @@
int PrintNetworkAddresses()
{
int ret;
- struct ifaddrs* ifa;
- struct ifaddrs* ifa_start;
+ struct ifaddrs *ifa;
+ struct ifaddrs *ifa_start;
char ipv4_address[INET_ADDRSTRLEN];
ret = getifaddrs(&ifa);
@@ -43,7 +43,7 @@ int PrintNetworkAddresses()
{
if(ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET)
{
- inet_ntop(AF_INET, &((struct sockaddr_in*)ifa->ifa_addr)->sin_addr, ipv4_address, INET_ADDRSTRLEN);
+ inet_ntop(AF_INET, &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr, ipv4_address, INET_ADDRSTRLEN);
printf("%s port %d\n", ipv4_address, AARUREMOTE_PORT);
}
@@ -55,11 +55,11 @@ int PrintNetworkAddresses()
return 0;
}
-char* PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
+char *PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
-void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
+void *NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
{
- NetworkContext* ctx;
+ NetworkContext *ctx;
ctx = malloc(sizeof(NetworkContext));
@@ -76,28 +76,28 @@ void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
return ctx;
}
-int32_t NetBind(void* net_ctx, struct sockaddr* addr, socklen_t addrlen)
+int32_t NetBind(void *net_ctx, struct sockaddr *addr, socklen_t addrlen)
{
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
return bind(ctx->fd, addr, addrlen);
}
-int32_t NetListen(void* net_ctx, uint32_t backlog)
+int32_t NetListen(void *net_ctx, uint32_t backlog)
{
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
return listen(ctx->fd, backlog);
}
-void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
+void *NetAccept(void *net_ctx, struct sockaddr *addr, socklen_t *addrlen)
{
- NetworkContext* ctx = net_ctx;
- NetworkContext* cli_ctx;
+ NetworkContext *ctx = net_ctx;
+ NetworkContext *cli_ctx;
if(!ctx) return NULL;
@@ -116,9 +116,9 @@ void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
return cli_ctx;
}
-int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
+int32_t NetRecv(void *net_ctx, void *buf, int32_t len, uint32_t flags)
{
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
@@ -139,19 +139,19 @@ int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
return got_total;
}
-int32_t NetWrite(void* net_ctx, const void* buf, int32_t size)
+int32_t NetWrite(void *net_ctx, const void *buf, int32_t size)
{
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
return write(ctx->fd, buf, size);
}
-int32_t NetClose(void* net_ctx)
+int32_t NetClose(void *net_ctx)
{
int ret;
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
diff --git a/unix/unix.c b/unix/unix.c
index 6129366..d34cf23 100644
--- a/unix/unix.c
+++ b/unix/unix.c
@@ -24,6 +24,6 @@ void Initialize()
// Do nothing
}
-void PlatformLoop(AaruPacketHello* pkt_server_hello) { WorkingLoop(pkt_server_hello); }
+void PlatformLoop(AaruPacketHello *pkt_server_hello) { WorkingLoop(pkt_server_hello); }
uint8_t AmIRoot() { return geteuid() == 0; }
\ No newline at end of file
diff --git a/unix/unix.h b/unix/unix.h
index dbfd0c1..250068a 100644
--- a/unix/unix.h
+++ b/unix/unix.h
@@ -23,4 +23,4 @@ typedef struct
int fd;
} NetworkContext;
-#endif // AARUREMOTE_UNIX_UNIX_H_
+#endif // AARUREMOTE_UNIX_UNIX_H_
diff --git a/wii/hello.c b/wii/hello.c
index 1ba09b1..b4dcdb8 100644
--- a/wii/hello.c
+++ b/wii/hello.c
@@ -23,9 +23,9 @@
#include "../aaruremote.h"
#include "../endian.h"
-AaruPacketHello* GetHello()
+AaruPacketHello *GetHello()
{
- AaruPacketHello* pkt_server_hello;
+ AaruPacketHello *pkt_server_hello;
pkt_server_hello = malloc(sizeof(AaruPacketHello));
diff --git a/wii/list_devices.c b/wii/list_devices.c
index 681bd39..63e943e 100644
--- a/wii/list_devices.c
+++ b/wii/list_devices.c
@@ -25,7 +25,7 @@
#include "../aaruremote.h"
#include "wii.h"
-DeviceInfoList* ListDevices()
+DeviceInfoList *ListDevices()
{
DeviceInfoList *list_start = NULL, *list_current = NULL, *list_next = NULL;
u32 deviceId = 0;
@@ -39,7 +39,7 @@ DeviceInfoList* ListDevices()
strncpy(list_next->this.vendor, "Nintendo", 256);
strncpy(list_next->this.model, "Wii NAND", 256);
strncpy(list_next->this.bus, "NAND", 256);
- list_next->this.supported = false; // TODO: Implement NAND reading
+ list_next->this.supported = false; // TODO: Implement NAND reading
if(ES_GetDeviceID(&deviceId) < 0) snprintf(list_next->this.serial, 256, "%d", deviceId);
@@ -59,7 +59,7 @@ DeviceInfoList* ListDevices()
strncpy(list_next->this.vendor, "Nintendo", 256);
strncpy(list_next->this.model, "Wii SD", 256);
strncpy(list_next->this.bus, "MMC/SD", 256);
- list_next->this.supported = false; // TODO: Implement SD/MMC reading
+ list_next->this.supported = false; // TODO: Implement SD/MMC reading
list_current->next = list_next;
list_current = list_next;
}
diff --git a/wii/network.c b/wii/network.c
index 7f699f3..766842e 100644
--- a/wii/network.c
+++ b/wii/network.c
@@ -39,10 +39,11 @@ int PrintNetworkAddresses()
return 0;
}
-char* PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
-void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
+char *PrintIpv4Address(struct in_addr addr) { return inet_ntoa(addr); }
+
+void *NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
{
- NetworkContext* ctx;
+ NetworkContext *ctx;
ctx = malloc(sizeof(NetworkContext));
@@ -59,28 +60,28 @@ void* NetSocket(uint32_t domain, uint32_t type, uint32_t protocol)
return ctx;
}
-int32_t NetBind(void* net_ctx, struct sockaddr* addr, socklen_t addrlen)
+int32_t NetBind(void *net_ctx, struct sockaddr *addr, socklen_t addrlen)
{
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
return net_bind(ctx->fd, addr, addrlen);
}
-int32_t NetListen(void* net_ctx, uint32_t backlog)
+int32_t NetListen(void *net_ctx, uint32_t backlog)
{
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
return net_listen(ctx->fd, backlog);
}
-void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
+void *NetAccept(void *net_ctx, struct sockaddr *addr, socklen_t *addrlen)
{
- NetworkContext* ctx = net_ctx;
- NetworkContext* cli_ctx;
+ NetworkContext *ctx = net_ctx;
+ NetworkContext *cli_ctx;
if(!ctx) return NULL;
@@ -99,9 +100,9 @@ void* NetAccept(void* net_ctx, struct sockaddr* addr, socklen_t* addrlen)
return cli_ctx;
}
-int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
+int32_t NetRecv(void *net_ctx, void *buf, int32_t len, uint32_t flags)
{
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
@@ -122,19 +123,19 @@ int32_t NetRecv(void* net_ctx, void* buf, int32_t len, uint32_t flags)
return got_total;
}
-int32_t NetWrite(void* net_ctx, const void* buf, int32_t size)
+int32_t NetWrite(void *net_ctx, const void *buf, int32_t size)
{
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
return net_write(ctx->fd, buf, size);
}
-int32_t NetClose(void* net_ctx)
+int32_t NetClose(void *net_ctx)
{
int ret;
- NetworkContext* ctx = net_ctx;
+ NetworkContext *ctx = net_ctx;
if(!ctx) return -1;
diff --git a/wii/unimplemented.c b/wii/unimplemented.c
index 7454725..bd5da18 100644
--- a/wii/unimplemented.c
+++ b/wii/unimplemented.c
@@ -19,56 +19,36 @@
// TODO
-void* DeviceOpen(const char* device_path) { return NULL; }
+void *DeviceOpen(const char *device_path) { return NULL; }
-void DeviceClose(void* device_ctx) {}
+void DeviceClose(void *device_ctx) {}
-int32_t GetDeviceType(void* device_ctx) { return AARUREMOTE_DEVICE_TYPE_UNKNOWN; }
+int32_t GetDeviceType(void *device_ctx) { return AARUREMOTE_DEVICE_TYPE_UNKNOWN; }
-int32_t GetSdhciRegisters(void* device_ctx,
- char** csd,
- char** cid,
- char** ocr,
- char** scr,
- uint32_t* csd_len,
- uint32_t* cid_len,
- uint32_t* ocr_len,
- uint32_t* scr_len)
+int32_t GetSdhciRegisters(void *device_ctx, char **csd, char **cid, char **ocr, char **scr, uint32_t *csd_len,
+ uint32_t *cid_len, uint32_t *ocr_len, uint32_t *scr_len)
{
return 0;
}
-int32_t SendSdhciCommand(void* device_ctx,
- uint8_t command,
- uint8_t write,
- uint8_t application,
- uint32_t flags,
- uint32_t argument,
- uint32_t block_size,
- uint32_t blocks,
- char* buffer,
- uint32_t buf_len,
- uint32_t timeout,
- uint32_t* response,
- uint32_t* duration,
- uint32_t* sense)
+int32_t SendSdhciCommand(void *device_ctx, uint8_t command, uint8_t write, uint8_t application, uint32_t flags,
+ uint32_t argument, uint32_t block_size, uint32_t blocks, char *buffer, uint32_t buf_len,
+ uint32_t timeout, uint32_t *response, uint32_t *duration, uint32_t *sense)
{
return -1;
}
-int32_t SendMultiSdhciCommand(void* device_ctx,
- uint64_t count,
- MmcSingleCommand commands[],
- uint32_t* duration,
- uint32_t* sense)
+int32_t SendMultiSdhciCommand(void *device_ctx, uint64_t count, MmcSingleCommand commands[], uint32_t *duration,
+ uint32_t *sense)
{
return -1;
}
-int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
+
+int32_t ReOpen(void *device_ctx, uint32_t *closeFailed)
{
*closeFailed = 1;
return -1;
}
-int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length, uint32_t* duration) { return -1; }
\ No newline at end of file
+int32_t OsRead(void *device_ctx, char *buffer, uint64_t offset, uint32_t length, uint32_t *duration) { return -1; }
\ No newline at end of file
diff --git a/wii/unsupported.c b/wii/unsupported.c
index 5820df8..3a72c12 100644
--- a/wii/unsupported.c
+++ b/wii/unsupported.c
@@ -17,86 +17,44 @@
#include "../aaruremote.h"
-int32_t SendAtaChsCommand(void* device_ctx,
- AtaRegistersChs registers,
- AtaErrorRegistersChs* error_registers,
- uint8_t protocol,
- uint8_t transfer_register,
- char* buffer,
- uint32_t timeout,
- uint8_t transfer_blocks,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t* buf_len)
+int32_t SendAtaChsCommand(void *device_ctx, AtaRegistersChs registers, AtaErrorRegistersChs *error_registers,
+ uint8_t protocol, uint8_t transfer_register, char *buffer, uint32_t timeout,
+ uint8_t transfer_blocks, uint32_t *duration, uint32_t *sense, uint32_t *buf_len)
{
return -1;
}
-int32_t SendAtaLba28Command(void* device_ctx,
- AtaRegistersLba28 registers,
- AtaErrorRegistersLba28* error_registers,
- uint8_t protocol,
- uint8_t transfer_register,
- char* buffer,
- uint32_t timeout,
- uint8_t transfer_blocks,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t* buf_len)
+int32_t SendAtaLba28Command(void *device_ctx, AtaRegistersLba28 registers, AtaErrorRegistersLba28 *error_registers,
+ uint8_t protocol, uint8_t transfer_register, char *buffer, uint32_t timeout,
+ uint8_t transfer_blocks, uint32_t *duration, uint32_t *sense, uint32_t *buf_len)
{
return -1;
}
-int32_t SendAtaLba48Command(void* device_ctx,
- AtaRegistersLba48 registers,
- AtaErrorRegistersLba48* error_registers,
- uint8_t protocol,
- uint8_t transfer_register,
- char* buffer,
- uint32_t timeout,
- uint8_t transfer_blocks,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t* buf_len)
+int32_t SendAtaLba48Command(void *device_ctx, AtaRegistersLba48 registers, AtaErrorRegistersLba48 *error_registers,
+ uint8_t protocol, uint8_t transfer_register, char *buffer, uint32_t timeout,
+ uint8_t transfer_blocks, uint32_t *duration, uint32_t *sense, uint32_t *buf_len)
{
return -1;
}
-uint8_t GetFireWireData(void* device_ctx,
- uint32_t* id_model,
- uint32_t* id_vendor,
- uint64_t* guid,
- char* vendor,
- char* model)
+uint8_t GetFireWireData(void *device_ctx, uint32_t *id_model, uint32_t *id_vendor, uint64_t *guid, char *vendor,
+ char *model)
{
return 0;
}
-uint8_t GetPcmciaData(void* device_ctx, uint16_t* cis_len, char* cis) { return 0; }
+uint8_t GetPcmciaData(void *device_ctx, uint16_t *cis_len, char *cis) { return 0; }
-int32_t SendScsiCommand(void* device_ctx,
- char* cdb,
- char* buffer,
- char** sense_buffer,
- uint32_t timeout,
- int32_t direction,
- uint32_t* duration,
- uint32_t* sense,
- uint32_t cdb_len,
- uint32_t* buf_len,
- uint32_t* sense_len)
+int32_t SendScsiCommand(void *device_ctx, char *cdb, char *buffer, char **sense_buffer, uint32_t timeout,
+ int32_t direction, uint32_t *duration, uint32_t *sense, uint32_t cdb_len, uint32_t *buf_len,
+ uint32_t *sense_len)
{
return -1;
}
-uint8_t GetUsbData(void* device_ctx,
- uint16_t* desc_len,
- char* descriptors,
- uint16_t* id_vendor,
- uint16_t* id_product,
- char* manufacturer,
- char* product,
- char* serial)
+uint8_t GetUsbData(void *device_ctx, uint16_t *desc_len, char *descriptors, uint16_t *id_vendor, uint16_t *id_product,
+ char *manufacturer, char *product, char *serial)
{
return 0;
}
diff --git a/wii/wii.c b/wii/wii.c
index bc4d223..f156714 100644
--- a/wii/wii.c
+++ b/wii/wii.c
@@ -24,8 +24,8 @@
void Initialize()
{
- void* framebuffer;
- static GXRModeObj* rmode = NULL;
+ void *framebuffer;
+ static GXRModeObj *rmode = NULL;
VIDEO_Init();
WPAD_Init();
@@ -42,7 +42,7 @@ void Initialize()
if(rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
}
-void PlatformLoop(AaruPacketHello* pkt_server_hello)
+void PlatformLoop(AaruPacketHello *pkt_server_hello)
{
static lwp_t worker = (lwp_t)NULL;
int buttonsDown;
diff --git a/wii/wii.h b/wii/wii.h
index 610deb2..f9eff2a 100644
--- a/wii/wii.h
+++ b/wii/wii.h
@@ -18,18 +18,18 @@
#ifndef AARUREMOTE_WII_WII_H_
#define AARUREMOTE_WII_WII_H_
-#define AARUREMOTE_WII_DEVICE_FD_NAND 1
-#define AARUREMOTE_WII_DEVICE_FD_DVD 2
-#define AARUREMOTE_WII_DEVICE_FD_SD 3
+#define AARUREMOTE_WII_DEVICE_FD_NAND 1
+#define AARUREMOTE_WII_DEVICE_FD_DVD 2
+#define AARUREMOTE_WII_DEVICE_FD_SD 3
#define AARUREMOTE_WII_DEVICE_FD_GCMM_A 4
#define AARUREMOTE_WII_DEVICE_FD_GCMM_B 5
#define AARUREMOTE_WII_IOCTL_SD_GET_DEVICE_STATUS 0x0B
-#define AARUREMOTE_WII_SD_INSERTED 1
+#define AARUREMOTE_WII_SD_INSERTED 1
-#define AARUREMOTE_WII_DEVICE_PATH_NAND "/dev/flash"
-#define AARUREMOTE_WII_DEVICE_PATH_DVD "/dev/di"
-#define AARUREMOTE_WII_DEVICE_PATH_SD "/dev/sdio/slot0"
+#define AARUREMOTE_WII_DEVICE_PATH_NAND "/dev/flash"
+#define AARUREMOTE_WII_DEVICE_PATH_DVD "/dev/di"
+#define AARUREMOTE_WII_DEVICE_PATH_SD "/dev/sdio/slot0"
#define AARUREMOTE_WII_DEVICE_PATH_GCMM_A "/dev/gcmm/slota"
#define AARUREMOTE_WII_DEVICE_PATH_GCMM_B "/dev/gcmm/slotb"
@@ -44,4 +44,4 @@ typedef struct
s32 fd;
} NetworkContext;
-#endif // AARUREMOTE_WII_WII_H_
+#endif // AARUREMOTE_WII_WII_H_