forked from len0rd/rockbox
Introduce volume_{present,removable} and fix invalid calls in apps/
The code was trying to probe for volume presence by calling drive layer with volume index. It is a miracle it get unnoticed so far. Introduce proper volume probing using the vol->drive map in the disk layer. Change-Id: I463a5bcc8170f007cad049536094207d2ba3c6fc Reviewed-on: http://gerrit.rockbox.org/669 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
This commit is contained in:
parent
c71e0567d6
commit
193753aa1f
3 changed files with 24 additions and 2 deletions
|
@ -71,6 +71,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
#include "disk.h"
|
||||||
|
|
||||||
struct root_items {
|
struct root_items {
|
||||||
int (*function)(void* param);
|
int (*function)(void* param);
|
||||||
|
@ -131,12 +132,12 @@ static int browser(void* param)
|
||||||
for (i = 0; i < NUM_VOLUMES; i++)
|
for (i = 0; i < NUM_VOLUMES; i++)
|
||||||
{
|
{
|
||||||
char vol_string[VOL_ENUM_POS + 8];
|
char vol_string[VOL_ENUM_POS + 8];
|
||||||
if (!storage_removable(i))
|
if (!volume_removable(i))
|
||||||
continue;
|
continue;
|
||||||
/* VOL_NAMES contains a %d */
|
/* VOL_NAMES contains a %d */
|
||||||
snprintf(vol_string, sizeof(vol_string), "/"VOL_NAMES, i);
|
snprintf(vol_string, sizeof(vol_string), "/"VOL_NAMES, i);
|
||||||
/* test whether we would browse the external card */
|
/* test whether we would browse the external card */
|
||||||
if (!storage_present(i) &&
|
if (!volume_present(i) &&
|
||||||
(strstr(last_folder, vol_string)
|
(strstr(last_folder, vol_string)
|
||||||
#ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
|
#ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
|
||||||
|| (i == 0)
|
|| (i == 0)
|
||||||
|
|
|
@ -292,3 +292,19 @@ int disk_unmount_all(void)
|
||||||
return unmounted;
|
return unmounted;
|
||||||
#endif /* HAVE_MULTIDRIVE */
|
#endif /* HAVE_MULTIDRIVE */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_HOTSWAP
|
||||||
|
bool volume_removable(int volume)
|
||||||
|
{
|
||||||
|
if(vol_drive[volume] == -1)
|
||||||
|
return false;
|
||||||
|
return storage_removable(vol_drive[volume]);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool volume_present(int volume)
|
||||||
|
{
|
||||||
|
if(vol_drive[volume] == -1)
|
||||||
|
return false;
|
||||||
|
return storage_present(vol_drive[volume]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -50,4 +50,9 @@ int disk_unmount(int drive);
|
||||||
int disk_get_sector_multiplier(IF_MD_NONVOID(int drive));
|
int disk_get_sector_multiplier(IF_MD_NONVOID(int drive));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_HOTSWAP
|
||||||
|
bool volume_removable(int volume);
|
||||||
|
bool volume_present(int volume);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue