mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
rbutil: Fix ipodpatcher bootloader install on Windows.
During bootloader installation ipodpatcher disk access is accidentially set up twice. This is not a problem except on Windows, which will abort with a "permission denied" error. Change-Id: I9a835ef0d49f24df741b7b2909c4bd87cb1c8341
This commit is contained in:
parent
b9ab75732a
commit
cc2f364926
3 changed files with 17 additions and 13 deletions
|
@ -355,6 +355,7 @@ int ipod_reopen_rw(struct ipod_t* ipod)
|
|||
int ipod_close(struct ipod_t* ipod)
|
||||
{
|
||||
close(ipod->dh);
|
||||
ipod->dh = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,6 +155,7 @@ int ipod_close(struct ipod_t* ipod)
|
|||
{
|
||||
unlock_volume(ipod->dh);
|
||||
CloseHandle(ipod->dh);
|
||||
ipod->dh = INVALID_HANDLE_VALUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,19 +42,6 @@ BootloaderInstallIpod::~BootloaderInstallIpod()
|
|||
|
||||
bool BootloaderInstallIpod::install(void)
|
||||
{
|
||||
ipodInitialize(&ipod);
|
||||
|
||||
if(ipod.sectorbuf == nullptr) {
|
||||
emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR);
|
||||
emit done(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// save buffer pointer before cleaning up ipod_t structure
|
||||
unsigned char* sb = ipod.sectorbuf;
|
||||
memset(&ipod, 0, sizeof(struct ipod_t));
|
||||
ipod.sectorbuf = sb;
|
||||
|
||||
if(!ipodInitialize(&ipod)) {
|
||||
emit done(true);
|
||||
return false;
|
||||
|
@ -223,6 +210,21 @@ BootloaderInstallBase::Capabilities BootloaderInstallIpod::capabilities(void)
|
|||
*/
|
||||
bool BootloaderInstallIpod::ipodInitialize(struct ipod_t *ipod)
|
||||
{
|
||||
// if the ipod was already opened make sure to close it first.
|
||||
#if defined(Q_OS_WIN32)
|
||||
if(ipod->dh != INVALID_HANDLE_VALUE)
|
||||
#else
|
||||
if(ipod->dh >= 0)
|
||||
#endif
|
||||
{
|
||||
ipod_close(ipod);
|
||||
}
|
||||
|
||||
// save buffer pointer before cleaning up ipod_t structure
|
||||
unsigned char* sb = ipod->sectorbuf;
|
||||
memset(ipod, 0, sizeof(struct ipod_t));
|
||||
ipod->sectorbuf = sb;
|
||||
|
||||
// initialize sector buffer. The sector buffer is part of the ipod_t
|
||||
// structure, so a second instance of this class will have its own buffer.
|
||||
if(ipod->sectorbuf == nullptr) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue