From fee50135149fbec0e5973caaa528826c256c66ac Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Thu, 22 Dec 2022 17:47:32 +0000 Subject: disk: Remember the partition number for each volume Change-Id: Ied6b0a558eec57435f9299f3e3326714f5e3cdca --- firmware/common/disk.c | 23 ++++++++++++++++++++--- firmware/export/mv.h | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'firmware') diff --git a/firmware/common/disk.c b/firmware/common/disk.c index 267b9f1ebf..2fec38995a 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c @@ -91,6 +91,7 @@ static bool is_free_volume(const struct volumeinfo *vi) static void mark_free_volume(struct volumeinfo *vi) { vi->drive = -1; + vi->partition = -1; } static int get_free_volume(void) @@ -102,6 +103,12 @@ static int get_free_volume(void) 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 static int disk_sector_multiplier[NUM_DRIVES] = { [0 ... NUM_DRIVES-1] = 1 }; @@ -328,7 +335,7 @@ int disk_mount(int drive) fat_get_bytes_per_sector(IF_MV(volume)) / SECTOR_SIZE; #endif mounted = 1; - volumes[volume].drive = drive; + init_volume(&volumes[volume], drive, 0); volume_onmount_internal(IF_MV(volume)); } @@ -351,7 +358,7 @@ int disk_mount(int drive) pinfo[i].start *= j; pinfo[i].size *= j; mounted++; - volumes[volume].drive = drive; + init_volume(&volumes[volume], drive, i); disk_sector_multiplier[drive] = j; volume_onmount_internal(IF_MV(volume)); 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)) { mounted++; - volumes[volume].drive = drive; + init_volume(&volumes[volume], drive, i); volume_onmount_internal(IF_MV(volume)); volume = get_free_volume(); /* prepare next entry */ } @@ -516,6 +523,7 @@ enum volume_info_type #if defined (HAVE_MULTIDRIVE) || defined (HAVE_DIRCACHE) VP_DRIVE, #endif + VP_PARTITION, }; 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; break; #endif + case VP_PARTITION: + res = vi->partition; + break; } } @@ -568,6 +579,11 @@ int volume_drive(int volume) } #endif /* HAVE_MULTIDRIVE */ +int volume_partition(int volume) +{ + return volume_properties(volume, VP_PARTITION); +} + #ifdef HAVE_DIRCACHE 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_HOTSWAP || HAVE_MULTIDRIVE || HAVE_DIRCACHE */ diff --git a/firmware/export/mv.h b/firmware/export/mv.h index 55235d691a..966ff9a032 100644 --- a/firmware/export/mv.h +++ b/firmware/export/mv.h @@ -107,6 +107,7 @@ struct volumeinfo { int drive; /* drive number */ + int partition; /* partition number (0 for superfloppy drives) */ }; /* Volume-centric functions (in disk.c) */ @@ -131,4 +132,6 @@ static inline int volume_drive(int volume) } #endif /* HAVE_MULTIDRIVE */ +int volume_partition(int volume); + #endif /* __MV_H__ */ -- cgit v1.2.3