mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 19:24:37 +00:00
FreeBSD does not need the file descriptor for device.
This commit is contained in:
@@ -35,23 +35,12 @@ void* DeviceOpen(const char* device_path)
|
|||||||
|
|
||||||
memset(ctx, 0, sizeof(DeviceContext));
|
memset(ctx, 0, sizeof(DeviceContext));
|
||||||
|
|
||||||
ctx->fd = open(device_path, O_RDWR | O_NONBLOCK | O_CREAT);
|
|
||||||
|
|
||||||
if((ctx->fd < 0) && (errno == EACCES || errno == EROFS)) ctx->fd = open(device_path, O_RDONLY | O_NONBLOCK);
|
|
||||||
|
|
||||||
if(ctx->fd <= 0)
|
|
||||||
{
|
|
||||||
free(ctx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(ctx->device_path, device_path, 4096);
|
strncpy(ctx->device_path, device_path, 4096);
|
||||||
|
|
||||||
ctx->device = cam_open_device(ctx->device_path, O_RDWR);
|
ctx->device = cam_open_device(ctx->device_path, O_RDWR);
|
||||||
|
|
||||||
if(!ctx->device)
|
if(!ctx->device)
|
||||||
{
|
{
|
||||||
close(ctx->fd);
|
|
||||||
free(ctx);
|
free(ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -67,8 +56,6 @@ void DeviceClose(void* device_ctx)
|
|||||||
|
|
||||||
if(ctx->device) cam_close_device(ctx->device);
|
if(ctx->device) cam_close_device(ctx->device);
|
||||||
|
|
||||||
close(ctx->fd);
|
|
||||||
|
|
||||||
free(ctx);
|
free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <camlib.h>
|
#include <camlib.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
char device_path[4096];
|
char device_path[4096];
|
||||||
struct cam_device* device;
|
struct cam_device* device;
|
||||||
} DeviceContext;
|
} DeviceContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user