From f0b8ee117b33f9202a36647903a3753e7609ee8b Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sun, 8 Jan 2017 03:42:34 +0100 Subject: Makefile: Fix setting compiler --- src/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Makefile b/src/Makefile index be4ade6..0f05ed6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,9 +5,9 @@ INSTALL ?= install BUILD_DATE ?= $(shell LC_ALL=C date '+%b %e %Y') -CC = gcc -CROSS_CC = $(CROSS_COMPILE)$(CC) -HOST_CC = $(HOST_COMPILE)$(CC) +CC ?= cc +CROSS_CC ?= $(CROSS_COMPILE)$(CC) +HOST_CC ?= $(HOST_COMPILE)$(CC) CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBUILD_DATE="\"$(BUILD_DATE)\"" -D_POSIX_C_SOURCE=200809L -D_FILE_OFFSET_BITS=64 CFLAGS += -W -Wall -O2 -pedantic -std=c99 -- cgit v1.2.3 From 87867a590479c9cbd6dcff6d6ed40b6981102ee0 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sun, 8 Jan 2017 14:33:08 +0100 Subject: cal: Fix race condition between calling stat and opening file --- src/cal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cal.c b/src/cal.c index 4d07e5e..0688aa9 100644 --- a/src/cal.c +++ b/src/cal.c @@ -76,14 +76,14 @@ int cal_init_file(const char * file, struct cal ** cal_out) { off_t lsize = 0; #endif - if ( stat(file, &st) != 0 ) - return -1; - fd = open(file, O_RDONLY); if ( fd < 0 ) return -1; + if ( fstat(fd, &st) != 0 ) + goto err; + if ( S_ISREG(st.st_mode) ) size = st.st_size; else if ( S_ISBLK(st.st_mode) ) { -- cgit v1.2.3 From 66ecce9a3d11cb21b687fa9711cedc8a4fa58230 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Mon, 9 Jan 2017 22:56:33 +0100 Subject: disk: Remove check which is always false Type unsigned long long int according to C99 can store at least 2^64-1. --- src/disk.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index 6bdd974..0b6b494 100644 --- a/src/disk.c +++ b/src/disk.c @@ -207,11 +207,6 @@ int disk_dump_dev(int fd, const char * file) { #endif - if ( blksize > ULLONG_MAX ) { - ERROR("Block device is too big"); - return -1; - } - if ( blksize == 0 ) { ERROR("Block device has zero size"); return -1; -- cgit v1.2.3 From 897919a70fa030399e52792fa602e53590744e04 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sat, 17 Jun 2017 23:10:36 +0200 Subject: main: Fix race condition between calling stat and rename --- src/main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 40f367a..d503ab6 100644 --- a/src/main.c +++ b/src/main.c @@ -1319,14 +1319,12 @@ int main(int argc, char **argv) { for ( i = 0; i < IMAGE_COUNT; ++i ) { - struct stat st; + int rename_ret; + int rename_errno; if ( ! image_tmp_name(i) ) continue; - if ( stat(image_tmp_name(i), &st) != 0 ) - continue; - switch ( i ) { case IMAGE_2ND: case IMAGE_XLOADER: @@ -1357,10 +1355,18 @@ int main(int argc, char **argv) { buf[0] = 0; snprintf(buf, sizeof(buf), "%s-%s:%hd_%s", image_type_to_string(i), device_to_string(dev->detected_device), dev->detected_hwrev, ptr); + + rename_ret = rename(image_tmp_name(i), buf); + rename_errno = errno; + + if ( rename_ret < 0 && rename_errno == ENOENT ) + continue; + printf("Renaming %s image file to %s...\n", image_type_to_string(i), buf); - if ( rename(image_tmp_name(i), buf) < 0 ) { + if ( rename_ret < 0 ) { + errno = rename_errno; ERROR_INFO("Renaming failed"); buf[0] = 0; -- cgit v1.2.3 From 1ec3777cb89a2c19e45154ab84ea3a24f47c086d Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sat, 17 Jun 2017 23:46:50 +0200 Subject: image: Call image_free() when image_append() is failing --- src/image.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/image.c b/src/image.c index 9cb3e41..43478f6 100644 --- a/src/image.c +++ b/src/image.c @@ -162,8 +162,10 @@ static int image_append(struct image * image, const char * type, const char * de image->hash = image_hash_from_data(image); image->devices = calloc(1, sizeof(struct device_list)); - if ( ! image->devices ) - return -1; + if ( ! image->devices ) { + image_free(image); + ALLOC_ERROR_RETURN(-1); + } image->devices->device = DEVICE_ANY; -- cgit v1.2.3 From 5cbd5e92b878dfe1aa6c9623b21c38030c23b5ff Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sat, 17 Jun 2017 23:47:10 +0200 Subject: image: Add new function image_alloc_from_fd() --- src/image.c | 33 ++++++++++++++++++++++----------- src/image.h | 1 + 2 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/image.c b/src/image.c index 43478f6..b78633b 100644 --- a/src/image.c +++ b/src/image.c @@ -246,22 +246,33 @@ static struct image * image_alloc(void) { struct image * image_alloc_from_file(const char * file, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout) { + int fd; + + fd = open(file, O_RDONLY); + if ( fd < 0 ) { + ERROR_INFO("Cannot open image file %s", file); + return NULL; + } + + return image_alloc_from_fd(fd, file, type, device, hwrevs, version, layout); + +} + +struct image * image_alloc_from_fd(int fd, const char * orig_filename, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout) { + off_t offset; struct image * image = image_alloc(); - if ( ! image ) + if ( ! image ) { + close(fd); return NULL; + } image->is_shared_fd = 0; - image->fd = open(file, O_RDONLY); - if ( image->fd < 0 ) { - ERROR_INFO("Cannot open image file %s", file); - free(image); - return NULL; - } + image->fd = fd; offset = lseek(image->fd, 0, SEEK_END); if ( offset == (off_t)-1 ) { - ERROR_INFO("Cannot seek to end of file %s", file); + ERROR_INFO("Cannot seek to end of file %s", orig_filename); close(image->fd); free(image); return NULL; @@ -270,10 +281,10 @@ struct image * image_alloc_from_file(const char * file, const char * type, const image->size = offset; image->offset = 0; image->cur = 0; - image->orig_filename = strdup(file); + image->orig_filename = strdup(orig_filename); if ( lseek(image->fd, 0, SEEK_SET) == (off_t)-1 ) { - ERROR_INFO("Cannot seek to begin of file %s", file); + ERROR_INFO("Cannot seek to begin of file %s", orig_filename); close(image->fd); free(image->orig_filename); free(image); @@ -284,7 +295,7 @@ struct image * image_alloc_from_file(const char * file, const char * type, const return NULL; if ( ( ! type || ! type[0] ) && ( ! device || ! device[0] ) && ( ! hwrevs || ! hwrevs[0] ) && ( ! version || ! version[0] ) ) - image_missing_values_from_name(image, file); + image_missing_values_from_name(image, orig_filename); image_align(image); diff --git a/src/image.h b/src/image.h index 709fef7..42111bf 100644 --- a/src/image.h +++ b/src/image.h @@ -64,6 +64,7 @@ struct image_list { }; struct image * image_alloc_from_file(const char * file, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout); +struct image * image_alloc_from_fd(int fd, const char * orig_filename, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout); struct image * image_alloc_from_shared_fd(int fd, size_t size, size_t offset, uint16_t hash, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout); void image_free(struct image * image); void image_seek(struct image * image, size_t whence); -- cgit v1.2.3 From cda5dc6116d607cbe72cfe9d799fab890aba7119 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sat, 17 Jun 2017 23:48:01 +0200 Subject: main: Use image_alloc_from_fd() to fix race condition between calling stat and opening file --- src/main.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index d503ab6..070ccfc 100644 --- a/src/main.c +++ b/src/main.c @@ -155,16 +155,24 @@ static void parse_image_arg(char * arg, struct image_list ** image_first) { char * version; char * layout; char * layout_file; + int fd; /* First check if arg is file, then try to parse arg format */ - if ( stat(arg, &st) == 0 ) { - image = image_alloc_from_file(arg, NULL, NULL, NULL, NULL, NULL); - if ( ! image ) { - ERROR("Cannot load image file %s", arg); - exit(1); + fd = open(arg, O_RDONLY); + if ( fd >= 0 ) { + if ( fstat(fd, &st) == 0 && !S_ISDIR(st.st_mode) ) { + image = image_alloc_from_fd(fd, arg, NULL, NULL, NULL, NULL, NULL); + if ( ! image ) { + ERROR("Cannot load image file %s", arg); + exit(1); + } + image_list_add(image_first, image); + return; } - image_list_add(image_first, image); - return; + close(fd); + } else if ( errno != ENOENT ) { + ERROR("Cannot load image file %s", arg); + exit(1); } layout_file = strchr(arg, '%'); -- cgit v1.2.3 From 27a55c3367a3c66b075a2ef622f6aa1a3d19c24b Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Thu, 6 Jul 2017 20:55:41 +0200 Subject: disk: Choose correct partition in disk_open_dev() --- src/disk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index 0b6b494..6a75b35 100644 --- a/src/disk.c +++ b/src/disk.c @@ -127,9 +127,15 @@ int disk_open_dev(int maj, int min, int partition, int readonly) { return -1; } - memcpy(blkdev+len, "p1", 3); + if ( snprintf(blkdev+len, sizeof(blkdev)-len, "p%d", partition) >= (int)(sizeof(blkdev)-len) ) { + ERROR("Block device name is too long"); + return -1; + } if ( stat(blkdev, &st) != 0 || ! S_ISBLK(st.st_mode) ) { - memcpy(blkdev+len, "1", 2); + if ( snprintf(blkdev+len, sizeof(blkdev)-len, "%d", partition) >= (int)(sizeof(blkdev)-len) ) { + ERROR("Block device name is too long"); + return -1; + } if ( stat(blkdev, &st) != 0 || ! S_ISBLK(st.st_mode) ) { blkdev[len] = 0; fd = open(blkdev, O_RDONLY); -- cgit v1.2.3 From 31569c169a94640759a28acd420f27e0f39d9d3f Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sun, 9 Jul 2017 14:56:30 +0200 Subject: disk: Fix detection of correct device in disk_open_dev() --- src/disk.c | 58 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index 6a75b35..486f50d 100644 --- a/src/disk.c +++ b/src/disk.c @@ -51,6 +51,7 @@ int disk_open_dev(int maj, int min, int partition, int readonly) { DIR * dir; struct dirent * dirent; int found; + int old_errno; size_t len; char blkdev[1024]; @@ -117,6 +118,19 @@ int disk_open_dev(int maj, int min, int partition, int readonly) { blkdev[len] = 0; + fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL); + if ( fd < 0 ) { + if ( errno != ENOMEDIUM ) + ERROR_INFO("Cannot open block device %s", blkdev); + return -1; + } else { + if ( fstat(fd, &st) != 0 || ! S_ISBLK(st.st_mode) || makedev(maj, min) != st.st_rdev ) { + ERROR("Block device %s does not have id %d:%d\n", blkdev, maj, min); + close(fd); + return -1; + } + } + } else if ( partition > 0 ) { /* Select partition */ @@ -131,37 +145,41 @@ int disk_open_dev(int maj, int min, int partition, int readonly) { ERROR("Block device name is too long"); return -1; } - if ( stat(blkdev, &st) != 0 || ! S_ISBLK(st.st_mode) ) { + fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL); + if ( fd < 0 && errno == ENOENT ) { if ( snprintf(blkdev+len, sizeof(blkdev)-len, "%d", partition) >= (int)(sizeof(blkdev)-len) ) { ERROR("Block device name is too long"); return -1; } - if ( stat(blkdev, &st) != 0 || ! S_ISBLK(st.st_mode) ) { - blkdev[len] = 0; - fd = open(blkdev, O_RDONLY); - if ( fd < 0 ) { - if ( errno != ENOMEDIUM ) { - ERROR_INFO("Cannot open block device %s", blkdev); - return -1; - } - } else { - close(fd); - ERROR("Block device does not have partitions"); - return -1; - } + fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL); + } + if ( fd < 0 && errno == ENOENT ) { + blkdev[len] = 0; + fd = open(blkdev, O_RDONLY); + if ( fd < 0 ) { + if ( errno != ENOMEDIUM ) + ERROR_INFO("Cannot open block device %s", blkdev); + } else { + close(fd); + ERROR("Block device %s does not have partitions", blkdev); } + return -1; } + if ( fd < 0 ) + old_errno = errno; printf("Found block device %s for partition %d\n", blkdev, partition); - } + if ( fd < 0 ) { + errno = old_errno; + ERROR_INFO("Cannot open block device %s", blkdev); + } - fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL); + } else { + + ERROR("Invalid partition %d for block device %s", partition, blkdev); + fd = -1; - if ( fd < 0 ) { - if ( errno != ENOMEDIUM ) - ERROR_INFO("Cannot open block device %s", blkdev); - return -1; } return fd; -- cgit v1.2.3 From ccec7a182f1373fb15051a1c03d28e44c4188cce Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sun, 9 Jul 2017 14:57:41 +0200 Subject: disk: Close device file handle when freeing structures --- src/disk.c | 7 +++++++ src/disk.h | 1 + src/operations.c | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') 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); } -- cgit v1.2.3 From 559fe2a3bde61ccac3619fe2281dd6faaeeebd33 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sun, 9 Jul 2017 17:26:13 +0200 Subject: disk: After opening blkdev, check that it is really block device --- src/disk.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index b0d4499..c8d218c 100644 --- a/src/disk.c +++ b/src/disk.c @@ -173,6 +173,10 @@ int disk_open_dev(int maj, int min, int partition, int readonly) { if ( fd < 0 ) { errno = old_errno; ERROR_INFO("Cannot open block device %s", blkdev); + } else if ( fstat(fd, &st) != 0 || ! S_ISBLK(st.st_mode) ) { + ERROR("Block device %s is not block device\n", blkdev); + close(fd); + return -1; } } else { -- cgit v1.2.3 From e685787e67c431579f8e2cf717a19174f154fe6c Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Thu, 8 Feb 2018 19:24:11 +0100 Subject: disk: Ensure that maj1:min1 is first device and maj2:min2 is second device --- src/disk.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index c8d218c..bb8ae02 100644 --- a/src/disk.c +++ b/src/disk.c @@ -304,6 +304,7 @@ int disk_init(struct usb_device_info * dev) { int maj2; int min1; int min2; + int tmp; maj1 = -1; maj2 = -1; @@ -390,6 +391,16 @@ int disk_init(struct usb_device_info * dev) { return -1; } + /* Ensure that maj1:min1 is first device and maj2:min2 is second device */ + if ( min2 < min1 ) { + tmp = min1; + min1 = min2; + min2 = tmp; + tmp = maj1; + maj1 = maj2; + maj2 = tmp; + } + /* TODO: change 1 to 0 when disk_flash_dev will be implemented */ /* RX-51 and RM-680 export MyDocs in first usb device and just first partion, so host system see whole device without MBR table */ -- cgit v1.2.3 From a6c20b5ee46c39cf5c9e86bc6cd938ba56909dff Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Thu, 8 Feb 2018 19:48:34 +0100 Subject: disk: Open whole block device with O_NONBLOCK This would simplify handling of ENOMEDIUM error. --- src/disk.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index bb8ae02..2db197b 100644 --- a/src/disk.c +++ b/src/disk.c @@ -118,10 +118,9 @@ int disk_open_dev(int maj, int min, int partition, int readonly) { blkdev[len] = 0; - fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL); + fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL | O_NONBLOCK); if ( fd < 0 ) { - if ( errno != ENOMEDIUM ) - ERROR_INFO("Cannot open block device %s", blkdev); + ERROR_INFO("Cannot open block device %s", blkdev); return -1; } else { if ( fstat(fd, &st) != 0 || ! S_ISBLK(st.st_mode) || makedev(maj, min) != st.st_rdev ) { @@ -155,10 +154,9 @@ int disk_open_dev(int maj, int min, int partition, int readonly) { } if ( fd < 0 && errno == ENOENT ) { blkdev[len] = 0; - fd = open(blkdev, O_RDONLY); + fd = open(blkdev, O_RDONLY | O_NONBLOCK); if ( fd < 0 ) { - if ( errno != ENOMEDIUM ) - ERROR_INFO("Cannot open block device %s", blkdev); + ERROR_INFO("Cannot open block device %s", blkdev); } else { close(fd); ERROR("Block device %s does not have partitions", blkdev); -- cgit v1.2.3 From ca1db966904a17097f4ffa2a73bc6ca58b4dd145 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Thu, 8 Feb 2018 19:49:13 +0100 Subject: disk: Fix compile warning: comparison between signed and unsigned integer expressions --- src/disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index 2db197b..a608693 100644 --- a/src/disk.c +++ b/src/disk.c @@ -221,7 +221,7 @@ int disk_dump_dev(int fd, const char * file) { #else blksize = lseek(fd, 0, SEEK_END); - if ( blksize == (off_t)-1 ) { + if ( (off_t)blksize == (off_t)-1 ) { ERROR_INFO("Cannot get size of block device"); return -1; } -- cgit v1.2.3 From 808ce724eef5d8d1371522e7c02e612ee5fdc886 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Thu, 8 Feb 2018 19:49:54 +0100 Subject: main: Print message after dumping finish --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/main.c b/src/main.c index 070ccfc..a43512b 100644 --- a/src/main.c +++ b/src/main.c @@ -1247,6 +1247,8 @@ int main(int argc, char **argv) { if ( chdir(buf) < 0 ) ERROR_INFO("Cannot chdir back to %s", buf); + printf("Done\n"); + } /* dump fiasco */ -- cgit v1.2.3 From 2fd11378c8a350e124183dd833470c0a904375fd Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Thu, 8 Feb 2018 20:28:31 +0100 Subject: disk: Fix swapping maj1:min1 and maj2:min2 --- src/disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index a608693..87e2c39 100644 --- a/src/disk.c +++ b/src/disk.c @@ -390,7 +390,7 @@ int disk_init(struct usb_device_info * dev) { } /* Ensure that maj1:min1 is first device and maj2:min2 is second device */ - if ( min2 < min1 ) { + if ( min2 != -1 && min2 < min1 ) { tmp = min1; min1 = min2; min2 = tmp; -- cgit v1.2.3 From e987dcd94853d0355e36d44e766bfabba62c0df5 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Thu, 8 Feb 2018 20:35:12 +0100 Subject: disk: Remove remaining ENOMEDIUM --- src/disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index 87e2c39..c048a56 100644 --- a/src/disk.c +++ b/src/disk.c @@ -410,7 +410,7 @@ int disk_init(struct usb_device_info * dev) { else fd = disk_open_dev(maj1, min1, 1, 1); - if ( fd < 0 && errno != ENOMEDIUM ) + if ( fd < 0 ) return -1; dev->data = fd; -- cgit v1.2.3 From 33442482c65acf3805d24b76b3567ec97c2492ef Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Thu, 8 Feb 2018 23:20:14 +0100 Subject: disk: Fix detection of busnum Unpatched version of libusb on linux platform does not set location, but Debian's version of libusb has a patch which set it. For compatibility with other systems without unpatched libusb version, read busnum from dirname which seems to be always set. Fixes: https://github.com/pali/0xFFFF/issues/5 --- src/disk.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/disk.c b/src/disk.c index c048a56..f58b1dd 100644 --- a/src/disk.c +++ b/src/disk.c @@ -363,9 +363,17 @@ int disk_init(struct usb_device_info * dev) { fclose(f); - if ( devnum != device->devnum || device->bus->location != busnum ) + if ( device->devnum != devnum ) continue; + if ( device->bus->location ) { + if ( device->bus->location != busnum ) + continue; + } else if ( device->bus->dirname[0] ) { + if ( atoi(device->bus->dirname) != (int)busnum ) + continue; + } + if ( sscanf(dirent->d_name, "%d:%d", &maj2, &min2) != 2 ) { maj2 = -1; min2 = -1; -- cgit v1.2.3 From 7f38b4bd10f6bb7428460eb814a0be2ba5e5aa4a Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Thu, 19 Apr 2018 22:46:11 +0300 Subject: usb-device: restore N800 support N800 has stopped working at some point, not sure why: $ 0xFFFF -I [...] Waiting for USB device... Found USB device: SU-18/RX-44/RX-48/RX-51/RM-680 (0x421:0x105) in NOLO mode USB device product string: Nokia N800 (Update mode) USB device serial number string: (not detected) Detected USB device: RX-34 Error: Device mishmash Add the device to 0421:0105 list, and it works again: Waiting for USB device... Found USB device: SU-18/RX-34/RX-44/RX-48/RX-51/RM-680 (0x421:0x105) in NOLO mode USB device product string: Nokia N800 (Update mode) USB device serial number string: (not detected) Detected USB device: RX-34 Initializing NOLO... Device: RX-34 [...] --- src/usb-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/usb-device.c b/src/usb-device.c index 5379b82..f7c16bb 100644 --- a/src/usb-device.c +++ b/src/usb-device.c @@ -47,7 +47,7 @@ static struct usb_flash_device usb_devices[] = { { 0x0421, 0x0096, -1, -1, -1, FLASH_DISK, { DEVICE_RX_44, 0 } }, - { 0x0421, 0x0105, 2, 1, -1, FLASH_NOLO, { DEVICE_SU_18, DEVICE_RX_44, DEVICE_RX_48, DEVICE_RX_51, DEVICE_RM_680, DEVICE_RM_696, 0 } }, + { 0x0421, 0x0105, 2, 1, -1, FLASH_NOLO, { DEVICE_SU_18, DEVICE_RX_34, DEVICE_RX_44, DEVICE_RX_48, DEVICE_RX_51, DEVICE_RM_680, DEVICE_RM_696, 0 } }, { 0x0421, 0x0106, 0, -1, -1, FLASH_COLD, { DEVICE_RX_51, DEVICE_RM_680, DEVICE_RM_696, 0 } }, { 0x0421, 0x0189, -1, -1, -1, FLASH_DISK, { DEVICE_RX_48, 0 } }, { 0x0421, 0x01c7, -1, -1, -1, FLASH_DISK, { DEVICE_RX_51, 0 } }, -- cgit v1.2.3