Frank Gevaerts | ad9db4d | 2008-11-01 16:25:04 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2008 by Frank Gevaerts |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #ifndef __MV_H__ |
| 23 | #define __MV_H__ |
| 24 | |
Thomas Martitz | f6c26d3 | 2014-02-07 18:30:50 +0100 | [diff] [blame] | 25 | #include <stdbool.h> |
Frank Gevaerts | ad9db4d | 2008-11-01 16:25:04 +0000 | [diff] [blame] | 26 | #include "config.h" |
| 27 | |
| 28 | /* FixMe: These macros are a bit nasty and perhaps misplaced here. |
| 29 | We'll get rid of them once decided on how to proceed with multivolume. */ |
Frank Gevaerts | c0a5a67 | 2009-07-17 22:28:49 +0000 | [diff] [blame] | 30 | |
Michael Sevakis | a56f1ca | 2013-08-17 12:18:22 -0400 | [diff] [blame] | 31 | /* Drives are things like a disk, a card, a flash chip. They can have volumes |
| 32 | on them */ |
Frank Gevaerts | c0a5a67 | 2009-07-17 22:28:49 +0000 | [diff] [blame] | 33 | #ifdef HAVE_MULTIDRIVE |
Michael Sevakis | a56f1ca | 2013-08-17 12:18:22 -0400 | [diff] [blame] | 34 | #define IF_MD(x...) x /* valist contents or empty */ |
| 35 | #define IF_MD_NONVOID(x...) x /* valist contents or 'void' */ |
| 36 | #define IF_MD_DRV(d) d /* drive argument or '0' */ |
Frank Gevaerts | c0a5a67 | 2009-07-17 22:28:49 +0000 | [diff] [blame] | 37 | #else /* empty definitions if no multi-drive */ |
Michael Sevakis | a56f1ca | 2013-08-17 12:18:22 -0400 | [diff] [blame] | 38 | #define IF_MD(x...) |
| 39 | #define IF_MD_NONVOID(x...) void |
| 40 | #define IF_MD_DRV(d) 0 |
Thomas Martitz | 706e6b7 | 2014-02-18 07:11:11 +0100 | [diff] [blame] | 41 | #endif /* HAVE_MULTIDRIVE */ |
Frank Gevaerts | c0a5a67 | 2009-07-17 22:28:49 +0000 | [diff] [blame] | 42 | |
| 43 | /* Volumes mean things that have filesystems on them, like partitions */ |
Frank Gevaerts | ad9db4d | 2008-11-01 16:25:04 +0000 | [diff] [blame] | 44 | #ifdef HAVE_MULTIVOLUME |
Michael Sevakis | a56f1ca | 2013-08-17 12:18:22 -0400 | [diff] [blame] | 45 | #define IF_MV(x...) x /* valist contents or empty */ |
| 46 | #define IF_MV_NONVOID(x...) x /* valist contents or 'void' */ |
| 47 | #define IF_MV_VOL(v) v /* volume argument or '0' */ |
Thomas Martitz | 46137eb | 2014-02-22 23:17:16 +0100 | [diff] [blame] | 48 | |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 49 | /* Format: "/<DEC###>/foo/bar" |
| 50 | * The "DEC" is pure decoration and treated as a comment. Only an unbroken |
| 51 | * trailing string of digits within the brackets is parsed as the volume |
| 52 | * number. |
| 53 | * |
| 54 | * IMPORTANT!: Adjust VOL_DEC_MAX_LEN if needed to the longest of these |
| 55 | */ |
| 56 | #define DEFAULT_VOL_DEC "Volume" |
| 57 | |
| 58 | #if (CONFIG_STORAGE & STORAGE_ATA) |
| 59 | #define ATA_VOL_DEC "HDD" |
Thomas Martitz | 46137eb | 2014-02-22 23:17:16 +0100 | [diff] [blame] | 60 | #endif |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 61 | #if (CONFIG_STORAGE & STORAGE_MMC) |
| 62 | #define MMC_VOL_DEC "MMC" |
| 63 | #endif |
| 64 | #if (CONFIG_STORAGE & STORAGE_SD) |
| 65 | #define SD_VOL_DEC "microSD" |
| 66 | #endif |
| 67 | #if (CONFIG_STORAGE & STORAGE_NAND) |
| 68 | #define NAND_VOL_DEC "NAND" |
| 69 | #endif |
| 70 | #if (CONFIG_STORAGE & STORAGE_RAMDISK) |
| 71 | #define RAMDISK_VOL_DEC "RAMDisk" |
| 72 | #endif |
| 73 | #if (CONFIG_STORAGE & STORAGE_HOSTFS) |
| 74 | #ifndef HOSTFS_VOL_DEC /* overridable */ |
| 75 | #define HOSTFS_VOL_DEC DEFAULT_VOL_DEC |
| 76 | #endif |
| 77 | #endif |
| 78 | |
| 79 | /* Characters that delimit a volume specifier at any root point in the path. |
| 80 | The tokens must be outside of legal filename characters */ |
| 81 | #define VOL_START_TOK '<' |
| 82 | #define VOL_END_TOK '>' |
| 83 | #define VOL_DEC_MAX_LEN 7 /* biggest of all xxx_VOL_DEC defines */ |
| 84 | #define VOL_MAX_LEN (1 + VOL_DEC_MAX_LEN + 2 + 1) |
| 85 | #define VOL_NUM_MAX 100 |
Thomas Martitz | 46137eb | 2014-02-22 23:17:16 +0100 | [diff] [blame] | 86 | |
Frank Gevaerts | ad9db4d | 2008-11-01 16:25:04 +0000 | [diff] [blame] | 87 | #else /* empty definitions if no multi-volume */ |
Michael Sevakis | a56f1ca | 2013-08-17 12:18:22 -0400 | [diff] [blame] | 88 | #define IF_MV(x...) |
| 89 | #define IF_MV_NONVOID(x...) void |
| 90 | #define IF_MV_VOL(v) 0 |
Thomas Martitz | 706e6b7 | 2014-02-18 07:11:11 +0100 | [diff] [blame] | 91 | #endif /* HAVE_MULTIVOLUME */ |
Frank Gevaerts | c0a5a67 | 2009-07-17 22:28:49 +0000 | [diff] [blame] | 92 | |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 93 | #define CHECK_VOL(volume) \ |
| 94 | ((unsigned int)IF_MV_VOL(volume) < NUM_VOLUMES) |
| 95 | |
| 96 | #define CHECK_DRV(drive) \ |
| 97 | ((unsigned int)IF_MD_DRV(drive) < NUM_DRIVES) |
| 98 | |
| 99 | /* Volume-centric functions (in disk.c) */ |
| 100 | void volume_recalc_free(IF_MV_NONVOID(int volume)); |
| 101 | unsigned int volume_get_cluster_size(IF_MV_NONVOID(int volume)); |
| 102 | void volume_size(IF_MV(int volume,) unsigned long *size, unsigned long *free); |
Solomon Peachy | 51fe1b6 | 2019-07-28 09:24:40 -0400 | [diff] [blame^] | 103 | #ifdef HAVE_DIRCACHE |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 104 | bool volume_ismounted(IF_MV_NONVOID(int volume)); |
Solomon Peachy | 51fe1b6 | 2019-07-28 09:24:40 -0400 | [diff] [blame^] | 105 | #endif |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 106 | #ifdef HAVE_HOTSWAP |
| 107 | bool volume_removable(int volume); |
| 108 | bool volume_present(int volume); |
| 109 | #endif /* HAVE_HOTSWAP */ |
| 110 | |
| 111 | #ifdef HAVE_MULTIDRIVE |
| 112 | int volume_drive(int volume); |
| 113 | #else /* !HAVE_MULTIDRIVE */ |
| 114 | static inline int volume_drive(int volume) |
| 115 | { |
| 116 | return 0; |
| 117 | (void)volume; |
| 118 | } |
| 119 | #endif /* HAVE_MULTIDRIVE */ |
| 120 | |
Michael Sevakis | a56f1ca | 2013-08-17 12:18:22 -0400 | [diff] [blame] | 121 | #endif /* __MV_H__ */ |