blob: 9d202a8087d598ac4b1d14785dedcdd557082984 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 by Frank Gevaerts
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef __MV_H__
#define __MV_H__
#include <stdbool.h>
#include <stdint.h>
#include "config.h"
/* FixMe: These macros are a bit nasty and perhaps misplaced here.
We'll get rid of them once decided on how to proceed with multivolume. */
/* Drives are things like a disk, a card, a flash chip. They can have volumes
on them */
#ifdef HAVE_MULTIDRIVE
#define IF_MD(x...) x /* valist contents or empty */
#define IF_MD_NONVOID(x...) x /* valist contents or 'void' */
#define IF_MD_DRV(d) d /* drive argument or '0' */
#else /* empty definitions if no multi-drive */
#define IF_MD(x...)
#define IF_MD_NONVOID(x...) void
#define IF_MD_DRV(d) 0
#endif /* HAVE_MULTIDRIVE */
/* Storage size */
#if (CONFIG_STORAGE & STORAGE_ATA) && defined(HAVE_LBA48)
typedef uint64_t sector_t;
#define STORAGE_64BIT_SECTOR
#elif (CONFIG_STORAGE & STORAGE_SD) && defined(HAVE_SDUC)
typedef uint64_t sector_t;
#define STORAGE_64BIT_SECTOR
#else
typedef unsigned long sector_t;
#undef STORAGE_64BIT_SECTOR
#endif
/* Volumes mean things that have filesystems on them, like partitions */
#ifdef HAVE_MULTIVOLUME
#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' */
/* 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_USB)
#define USB_VOL_DEC "USB"
#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
#ifndef ROOT_VOLUME
#define ROOT_VOLUME INT_MAX
#endif
#else /* empty definitions if no multi-volume */
#define IF_MV(x...)
#define IF_MV_NONVOID(x...) void
#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)
/* contains info about a volume */
struct volumeinfo
{
int drive; /* drive number */
int partition; /* partition number (0 for superfloppy 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,) sector_t *size, sector_t *free);
#ifdef HAVE_DIRCACHE
bool volume_ismounted(IF_MV_NONVOID(int volume));
#endif
#ifdef HAVE_HOTSWAP
bool volume_removable(int volume);
bool volume_present(int volume);
#else
#define volume_present(x) 1
#define volueme_removeable(x) 0
#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 */
int volume_partition(int volume);
#endif /* __MV_H__ */
|