forked from len0rd/rockbox
disk: Remember the partition number for each volume
Change-Id: Ied6b0a558eec57435f9299f3e3326714f5e3cdca
This commit is contained in:
parent
028f283ee5
commit
fee5013514
2 changed files with 23 additions and 3 deletions
|
@ -91,6 +91,7 @@ static bool is_free_volume(const struct volumeinfo *vi)
|
||||||
static void mark_free_volume(struct volumeinfo *vi)
|
static void mark_free_volume(struct volumeinfo *vi)
|
||||||
{
|
{
|
||||||
vi->drive = -1;
|
vi->drive = -1;
|
||||||
|
vi->partition = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_free_volume(void)
|
static int get_free_volume(void)
|
||||||
|
@ -102,6 +103,12 @@ static int get_free_volume(void)
|
||||||
return -1; /* none found */
|
return -1; /* none found */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void init_volume(struct volumeinfo *vi, int drive, int part)
|
||||||
|
{
|
||||||
|
vi->drive = drive;
|
||||||
|
vi->partition = part;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MAX_LOG_SECTOR_SIZE
|
#ifdef MAX_LOG_SECTOR_SIZE
|
||||||
static int disk_sector_multiplier[NUM_DRIVES] =
|
static int disk_sector_multiplier[NUM_DRIVES] =
|
||||||
{ [0 ... NUM_DRIVES-1] = 1 };
|
{ [0 ... NUM_DRIVES-1] = 1 };
|
||||||
|
@ -328,7 +335,7 @@ int disk_mount(int drive)
|
||||||
fat_get_bytes_per_sector(IF_MV(volume)) / SECTOR_SIZE;
|
fat_get_bytes_per_sector(IF_MV(volume)) / SECTOR_SIZE;
|
||||||
#endif
|
#endif
|
||||||
mounted = 1;
|
mounted = 1;
|
||||||
volumes[volume].drive = drive;
|
init_volume(&volumes[volume], drive, 0);
|
||||||
volume_onmount_internal(IF_MV(volume));
|
volume_onmount_internal(IF_MV(volume));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +358,7 @@ int disk_mount(int drive)
|
||||||
pinfo[i].start *= j;
|
pinfo[i].start *= j;
|
||||||
pinfo[i].size *= j;
|
pinfo[i].size *= j;
|
||||||
mounted++;
|
mounted++;
|
||||||
volumes[volume].drive = drive;
|
init_volume(&volumes[volume], drive, i);
|
||||||
disk_sector_multiplier[drive] = j;
|
disk_sector_multiplier[drive] = j;
|
||||||
volume_onmount_internal(IF_MV(volume));
|
volume_onmount_internal(IF_MV(volume));
|
||||||
volume = get_free_volume(); /* prepare next entry */
|
volume = get_free_volume(); /* prepare next entry */
|
||||||
|
@ -362,7 +369,7 @@ int disk_mount(int drive)
|
||||||
if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start))
|
if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start))
|
||||||
{
|
{
|
||||||
mounted++;
|
mounted++;
|
||||||
volumes[volume].drive = drive;
|
init_volume(&volumes[volume], drive, i);
|
||||||
volume_onmount_internal(IF_MV(volume));
|
volume_onmount_internal(IF_MV(volume));
|
||||||
volume = get_free_volume(); /* prepare next entry */
|
volume = get_free_volume(); /* prepare next entry */
|
||||||
}
|
}
|
||||||
|
@ -516,6 +523,7 @@ enum volume_info_type
|
||||||
#if defined (HAVE_MULTIDRIVE) || defined (HAVE_DIRCACHE)
|
#if defined (HAVE_MULTIDRIVE) || defined (HAVE_DIRCACHE)
|
||||||
VP_DRIVE,
|
VP_DRIVE,
|
||||||
#endif
|
#endif
|
||||||
|
VP_PARTITION,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int volume_properties(int volume, enum volume_info_type infotype)
|
static int volume_properties(int volume, enum volume_info_type infotype)
|
||||||
|
@ -542,6 +550,9 @@ static int volume_properties(int volume, enum volume_info_type infotype)
|
||||||
res = vi->drive;
|
res = vi->drive;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case VP_PARTITION:
|
||||||
|
res = vi->partition;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,6 +579,11 @@ int volume_drive(int volume)
|
||||||
}
|
}
|
||||||
#endif /* HAVE_MULTIDRIVE */
|
#endif /* HAVE_MULTIDRIVE */
|
||||||
|
|
||||||
|
int volume_partition(int volume)
|
||||||
|
{
|
||||||
|
return volume_properties(volume, VP_PARTITION);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DIRCACHE
|
#ifdef HAVE_DIRCACHE
|
||||||
bool volume_ismounted(IF_MV_NONVOID(int volume))
|
bool volume_ismounted(IF_MV_NONVOID(int volume))
|
||||||
{
|
{
|
||||||
|
@ -575,4 +591,5 @@ bool volume_ismounted(IF_MV_NONVOID(int volume))
|
||||||
}
|
}
|
||||||
#endif /* HAVE_DIRCACHE */
|
#endif /* HAVE_DIRCACHE */
|
||||||
|
|
||||||
|
|
||||||
#endif /* HAVE_HOTSWAP || HAVE_MULTIDRIVE || HAVE_DIRCACHE */
|
#endif /* HAVE_HOTSWAP || HAVE_MULTIDRIVE || HAVE_DIRCACHE */
|
||||||
|
|
|
@ -107,6 +107,7 @@
|
||||||
struct volumeinfo
|
struct volumeinfo
|
||||||
{
|
{
|
||||||
int drive; /* drive number */
|
int drive; /* drive number */
|
||||||
|
int partition; /* partition number (0 for superfloppy drives) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Volume-centric functions (in disk.c) */
|
/* Volume-centric functions (in disk.c) */
|
||||||
|
@ -131,4 +132,6 @@ static inline int volume_drive(int volume)
|
||||||
}
|
}
|
||||||
#endif /* HAVE_MULTIDRIVE */
|
#endif /* HAVE_MULTIDRIVE */
|
||||||
|
|
||||||
|
int volume_partition(int volume);
|
||||||
|
|
||||||
#endif /* __MV_H__ */
|
#endif /* __MV_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue