summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/disk.c23
-rw-r--r--firmware/export/mv.h3
2 files changed, 23 insertions, 3 deletions
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)
91static void mark_free_volume(struct volumeinfo *vi) 91static void mark_free_volume(struct volumeinfo *vi)
92{ 92{
93 vi->drive = -1; 93 vi->drive = -1;
94 vi->partition = -1;
94} 95}
95 96
96static int get_free_volume(void) 97static int get_free_volume(void)
@@ -102,6 +103,12 @@ static int get_free_volume(void)
102 return -1; /* none found */ 103 return -1; /* none found */
103} 104}
104 105
106static void init_volume(struct volumeinfo *vi, int drive, int part)
107{
108 vi->drive = drive;
109 vi->partition = part;
110}
111
105#ifdef MAX_LOG_SECTOR_SIZE 112#ifdef MAX_LOG_SECTOR_SIZE
106static int disk_sector_multiplier[NUM_DRIVES] = 113static int disk_sector_multiplier[NUM_DRIVES] =
107 { [0 ... NUM_DRIVES-1] = 1 }; 114 { [0 ... NUM_DRIVES-1] = 1 };
@@ -328,7 +335,7 @@ int disk_mount(int drive)
328 fat_get_bytes_per_sector(IF_MV(volume)) / SECTOR_SIZE; 335 fat_get_bytes_per_sector(IF_MV(volume)) / SECTOR_SIZE;
329 #endif 336 #endif
330 mounted = 1; 337 mounted = 1;
331 volumes[volume].drive = drive; 338 init_volume(&volumes[volume], drive, 0);
332 volume_onmount_internal(IF_MV(volume)); 339 volume_onmount_internal(IF_MV(volume));
333 } 340 }
334 341
@@ -351,7 +358,7 @@ int disk_mount(int drive)
351 pinfo[i].start *= j; 358 pinfo[i].start *= j;
352 pinfo[i].size *= j; 359 pinfo[i].size *= j;
353 mounted++; 360 mounted++;
354 volumes[volume].drive = drive; 361 init_volume(&volumes[volume], drive, i);
355 disk_sector_multiplier[drive] = j; 362 disk_sector_multiplier[drive] = j;
356 volume_onmount_internal(IF_MV(volume)); 363 volume_onmount_internal(IF_MV(volume));
357 volume = get_free_volume(); /* prepare next entry */ 364 volume = get_free_volume(); /* prepare next entry */
@@ -362,7 +369,7 @@ int disk_mount(int drive)
362 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start)) 369 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start))
363 { 370 {
364 mounted++; 371 mounted++;
365 volumes[volume].drive = drive; 372 init_volume(&volumes[volume], drive, i);
366 volume_onmount_internal(IF_MV(volume)); 373 volume_onmount_internal(IF_MV(volume));
367 volume = get_free_volume(); /* prepare next entry */ 374 volume = get_free_volume(); /* prepare next entry */
368 } 375 }
@@ -516,6 +523,7 @@ enum volume_info_type
516#if defined (HAVE_MULTIDRIVE) || defined (HAVE_DIRCACHE) 523#if defined (HAVE_MULTIDRIVE) || defined (HAVE_DIRCACHE)
517 VP_DRIVE, 524 VP_DRIVE,
518#endif 525#endif
526 VP_PARTITION,
519}; 527};
520 528
521static int volume_properties(int volume, enum volume_info_type infotype) 529static 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)
542 res = vi->drive; 550 res = vi->drive;
543 break; 551 break;
544 #endif 552 #endif
553 case VP_PARTITION:
554 res = vi->partition;
555 break;
545 } 556 }
546 } 557 }
547 558
@@ -568,6 +579,11 @@ int volume_drive(int volume)
568} 579}
569#endif /* HAVE_MULTIDRIVE */ 580#endif /* HAVE_MULTIDRIVE */
570 581
582int volume_partition(int volume)
583{
584 return volume_properties(volume, VP_PARTITION);
585}
586
571#ifdef HAVE_DIRCACHE 587#ifdef HAVE_DIRCACHE
572bool volume_ismounted(IF_MV_NONVOID(int volume)) 588bool volume_ismounted(IF_MV_NONVOID(int volume))
573{ 589{
@@ -575,4 +591,5 @@ bool volume_ismounted(IF_MV_NONVOID(int volume))
575} 591}
576#endif /* HAVE_DIRCACHE */ 592#endif /* HAVE_DIRCACHE */
577 593
594
578#endif /* HAVE_HOTSWAP || HAVE_MULTIDRIVE || HAVE_DIRCACHE */ 595#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 @@
107struct volumeinfo 107struct volumeinfo
108{ 108{
109 int drive; /* drive number */ 109 int drive; /* drive number */
110 int partition; /* partition number (0 for superfloppy drives) */
110}; 111};
111 112
112/* Volume-centric functions (in disk.c) */ 113/* Volume-centric functions (in disk.c) */
@@ -131,4 +132,6 @@ static inline int volume_drive(int volume)
131} 132}
132#endif /* HAVE_MULTIDRIVE */ 133#endif /* HAVE_MULTIDRIVE */
133 134
135int volume_partition(int volume);
136
134#endif /* __MV_H__ */ 137#endif /* __MV_H__ */