summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/disk.c7
-rw-r--r--src/disk.h1
-rw-r--r--src/operations.c5
3 files changed, 12 insertions, 1 deletions
diff --git a/src/disk.c b/src/disk.c
index 486f50d..b0d4499 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -413,6 +413,13 @@ int disk_init(struct usb_device_info * dev) {
}
+void disk_exit(struct usb_device_info * dev) {
+
+ if ( dev->data >= 0 )
+ close(dev->data);
+
+}
+
enum device disk_get_device(struct usb_device_info * dev) {
return dev->device;
diff --git a/src/disk.h b/src/disk.h
index d5f367d..15eb127 100644
--- a/src/disk.h
+++ b/src/disk.h
@@ -24,6 +24,7 @@
#include "usb-device.h"
int disk_init(struct usb_device_info * dev);
+void disk_exit(struct usb_device_info * dev);
enum device disk_get_device(struct usb_device_info * dev);
diff --git a/src/operations.c b/src/operations.c
index cd7ef44..b3be2c7 100644
--- a/src/operations.c
+++ b/src/operations.c
@@ -91,8 +91,11 @@ clean:
void dev_free(struct device_info * dev) {
- if ( dev->usb )
+ if ( dev->usb ) {
+ if ( dev->usb->flash_device->protocol == FLASH_DISK )
+ disk_exit(dev->usb);
usb_close_device(dev->usb);
+ }
free(dev);
}