summaryrefslogtreecommitdiff
path: root/utils/rbutilqt/base/bootloaderinstallsansa.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2022-04-14 22:22:22 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2022-04-14 22:22:46 +0200
commit8a6ceff3762784d99f57e2f7f20149f97b6d82c7 (patch)
tree0ca938d476fc296aa90603570a70a6fb17dc524d /utils/rbutilqt/base/bootloaderinstallsansa.cpp
parentcc2f36492666be11da12890b35303a63e3aced87 (diff)
downloadrockbox-8a6ceff3762784d99f57e2f7f20149f97b6d82c7.tar.gz
rockbox-8a6ceff3762784d99f57e2f7f20149f97b6d82c7.zip
rbutil: Fix sansapatcher bootloader install on Windows.
During bootloader installation sansapatcher disk access is accidentially set up twice. This is not a problem except on Windows, which will abort with a "permission denied" error. This is basically the same problem as for ipodpatcher bootloader install. Change-Id: I03220e17d0e00a15fff23c02aba7da93d4781964
Diffstat (limited to 'utils/rbutilqt/base/bootloaderinstallsansa.cpp')
-rw-r--r--utils/rbutilqt/base/bootloaderinstallsansa.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/utils/rbutilqt/base/bootloaderinstallsansa.cpp b/utils/rbutilqt/base/bootloaderinstallsansa.cpp
index f6e345c7e2..b8e307cf2c 100644
--- a/utils/rbutilqt/base/bootloaderinstallsansa.cpp
+++ b/utils/rbutilqt/base/bootloaderinstallsansa.cpp
@@ -28,6 +28,11 @@ BootloaderInstallSansa::BootloaderInstallSansa(QObject *parent)
28 : BootloaderInstallBase(parent) 28 : BootloaderInstallBase(parent)
29{ 29{
30 sansa.sectorbuf = nullptr; 30 sansa.sectorbuf = nullptr;
31#if defined(Q_OS_WIN32)
32 sansa.dh = INVALID_HANDLE_VALUE;
33#else
34 sansa.dh = -1;
35#endif
31} 36}
32 37
33 38
@@ -51,21 +56,6 @@ bool BootloaderInstallSansa::install(void)
51 emit done(true); 56 emit done(true);
52 } 57 }
53 58
54 emit logItem(tr("Searching for Sansa"), LOGINFO);
55
56 int n = sansa_scan(&sansa);
57 if(n == -1) {
58 emit logItem(tr("Permission for disc access denied!\n"
59 "This is required to install the bootloader"),
60 LOGERROR);
61 emit done(true);
62 return false;
63 }
64 if(n == 0) {
65 emit logItem(tr("No Sansa detected!"), LOGERROR);
66 emit done(true);
67 return false;
68 }
69 if(sansa.hasoldbootloader) { 59 if(sansa.hasoldbootloader) {
70 emit logItem(tr("OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n" 60 emit logItem(tr("OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n"
71 "You must reinstall the original Sansa firmware before running\n" 61 "You must reinstall the original Sansa firmware before running\n"
@@ -92,10 +82,6 @@ void BootloaderInstallSansa::installStage2(void)
92 82
93 emit logItem(tr("Installing Rockbox bootloader"), LOGINFO); 83 emit logItem(tr("Installing Rockbox bootloader"), LOGINFO);
94 QCoreApplication::processEvents(); 84 QCoreApplication::processEvents();
95 if(!sansaInitialize(&sansa)) {
96 emit done(true);
97 return;
98 }
99 85
100 if(sansa_reopen_rw(&sansa) < 0) { 86 if(sansa_reopen_rw(&sansa) < 0) {
101 emit logItem(tr("Could not open Sansa in R/W mode"), LOGERROR); 87 emit logItem(tr("Could not open Sansa in R/W mode"), LOGERROR);
@@ -232,7 +218,21 @@ BootloaderInstallBase::BootloaderType BootloaderInstallSansa::installed(void)
232 218
233bool BootloaderInstallSansa::sansaInitialize(struct sansa_t *sansa) 219bool BootloaderInstallSansa::sansaInitialize(struct sansa_t *sansa)
234{ 220{
235 // initialize sector buffer. The sector buffer is part of the sansa_t 221 // if the ipod was already opened make sure to close it first.
222#if defined(Q_OS_WIN32)
223 if(sansa->dh != INVALID_HANDLE_VALUE)
224#else
225 if(sansa->dh >= 0)
226#endif
227 {
228 sansa_close(sansa);
229 }
230 // save buffer pointer before cleaning up ipod_t structure
231 unsigned char* sb = sansa->sectorbuf;
232 memset(sansa, 0, sizeof(struct sansa_t));
233 sansa->sectorbuf = sb;
234
235 // initialize sector buffer. The sector buffer is part of the ipod_t
236 // structure, so a second instance of this class will have its own buffer. 236 // structure, so a second instance of this class will have its own buffer.
237 if(sansa->sectorbuf == nullptr) { 237 if(sansa->sectorbuf == nullptr) {
238 sansa_alloc_buffer(sansa, BUFFER_SIZE); 238 sansa_alloc_buffer(sansa, BUFFER_SIZE);