summaryrefslogtreecommitdiffstats
path: root/firmware/export/mv.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/mv.h')
-rw-r--r--firmware/export/mv.h77
1 files changed, 62 insertions, 15 deletions
diff --git a/firmware/export/mv.h b/firmware/export/mv.h
index 1d0a536663..620d77d30d 100644
--- a/firmware/export/mv.h
+++ b/firmware/export/mv.h
@@ -45,23 +45,44 @@
#define IF_MV(x...) x /* valist contents or empty */
#define IF_MV_NONVOID(x...) x /* valist contents or 'void' */
#define IF_MV_VOL(v) v /* volume argument or '0' */
-/* how to name volumes, first char must be outside of legal file names,
- a number gets appended to enumerate, if applicable */
-#if (CONFIG_STORAGE & STORAGE_MMC)
-#define VOL_NAMES "<MMC%d>"
-#define VOL_ENUM_POS 4 /* position of %d, to avoid runtime calculation */
-#elif (CONFIG_STORAGE & STORAGE_SD)
-#define VOL_NAMES "<microSD%d>"
-#define VOL_ENUM_POS 8 /* position of %d, to avoid runtime calculation */
-#else
-#define VOL_NAMES "<HD%d>"
-#define VOL_ENUM_POS 3
-#endif /* CONFIG_STORAGE */
-#ifdef HAVE_HOTSWAP
-bool volume_removable(int volume);
-bool volume_present(int volume);
+/* Format: "/<DEC###>/foo/bar"
+ * The "DEC" is pure decoration and treated as a comment. Only an unbroken
+ * trailing string of digits within the brackets is parsed as the volume
+ * number.
+ *
+ * IMPORTANT!: Adjust VOL_DEC_MAX_LEN if needed to the longest of these
+ */
+#define DEFAULT_VOL_DEC "Volume"
+
+#if (CONFIG_STORAGE & STORAGE_ATA)
+#define ATA_VOL_DEC "HDD"
+#endif
+#if (CONFIG_STORAGE & STORAGE_MMC)
+#define MMC_VOL_DEC "MMC"
+#endif
+#if (CONFIG_STORAGE & STORAGE_SD)
+#define SD_VOL_DEC "microSD"
+#endif
+#if (CONFIG_STORAGE & STORAGE_NAND)
+#define NAND_VOL_DEC "NAND"
+#endif
+#if (CONFIG_STORAGE & STORAGE_RAMDISK)
+#define RAMDISK_VOL_DEC "RAMDisk"
+#endif
+#if (CONFIG_STORAGE & STORAGE_HOSTFS)
+#ifndef HOSTFS_VOL_DEC /* overridable */
+#define HOSTFS_VOL_DEC DEFAULT_VOL_DEC
#endif
+#endif
+
+/* Characters that delimit a volume specifier at any root point in the path.
+ The tokens must be outside of legal filename characters */
+#define VOL_START_TOK '<'
+#define VOL_END_TOK '>'
+#define VOL_DEC_MAX_LEN 7 /* biggest of all xxx_VOL_DEC defines */
+#define VOL_MAX_LEN (1 + VOL_DEC_MAX_LEN + 2 + 1)
+#define VOL_NUM_MAX 100
#else /* empty definitions if no multi-volume */
#define IF_MV(x...)
@@ -69,4 +90,30 @@ bool volume_present(int volume);
#define IF_MV_VOL(v) 0
#endif /* HAVE_MULTIVOLUME */
+#define CHECK_VOL(volume) \
+ ((unsigned int)IF_MV_VOL(volume) < NUM_VOLUMES)
+
+#define CHECK_DRV(drive) \
+ ((unsigned int)IF_MD_DRV(drive) < NUM_DRIVES)
+
+/* Volume-centric functions (in disk.c) */
+void volume_recalc_free(IF_MV_NONVOID(int volume));
+unsigned int volume_get_cluster_size(IF_MV_NONVOID(int volume));
+void volume_size(IF_MV(int volume,) unsigned long *size, unsigned long *free);
+bool volume_ismounted(IF_MV_NONVOID(int volume));
+#ifdef HAVE_HOTSWAP
+bool volume_removable(int volume);
+bool volume_present(int volume);
+#endif /* HAVE_HOTSWAP */
+
+#ifdef HAVE_MULTIDRIVE
+int volume_drive(int volume);
+#else /* !HAVE_MULTIDRIVE */
+static inline int volume_drive(int volume)
+{
+ return 0;
+ (void)volume;
+}
+#endif /* HAVE_MULTIDRIVE */
+
#endif /* __MV_H__ */