From eda4a3d4e4ca1b587e628953eba6fdd9767a66d4 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Mon, 14 Dec 2020 14:06:57 +0000 Subject: [PATCH] Implement reopen command for FreeBSD. --- freebsd/device.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/freebsd/device.c b/freebsd/device.c index 749d219..f01375b 100644 --- a/freebsd/device.c +++ b/freebsd/device.c @@ -100,3 +100,18 @@ int32_t GetDeviceType(void* device_ctx) cam_freeccb(camccb); return device_type; } + +int32_t ReOpen(void* device_ctx, uint32_t* closeFailed) +{ + DeviceContext* ctx = device_ctx; + int ret; + *closeFailed = 0; + + if(!ctx) return -1; + + cam_close_device(ctx->device); + + ctx->device = cam_open_device(ctx->device_path, O_RDWR); + + return ctx->device == 0 ? errno : 0; +}