3 Functions for mounting and dismounting partitions
4 on various block devices.
6 Copyright (c) 2006 Michael "Chishm" Chisholm
8 Redistribution and use in source and binary forms, with or without modification,
9 are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 3. The name of the author may not be used to endorse or promote products derived
17 from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
22 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 extern const char* DEVICE_NAME
;
41 typedef enum {FS_UNKNOWN
, FS_FAT12
, FS_FAT16
, FS_FAT32
} FS_TYPE
;
45 uint32_t sectorsPerFat
;
51 const DISC_INTERFACE
* disc
;
53 // Info about the partition
57 uint32_t rootDirCluster
;
58 uint32_t numberOfSectors
;
60 uint32_t bytesPerSector
;
61 uint32_t sectorsPerCluster
;
62 uint32_t bytesPerCluster
;
64 // Values that may change after construction
65 uint32_t cwdCluster
; // Current working directory cluster
67 struct _FILE_STRUCT
* firstOpenFile
; // The start of a linked list of files
68 mutex_t lock
; // A lock for partition operations
69 bool readOnly
; // If this is set, then do not try writing to the disc
73 Mount the supplied device and return a pointer to the struct necessary to use it
75 PARTITION
* _FAT_partition_constructor (const DISC_INTERFACE
* disc
, uint32_t cacheSize
, sec_t startSector
);
78 Dismount the device and free all structures used.
79 Will also attempt to synchronise all open files to disc.
81 void _FAT_partition_destructor (PARTITION
* partition
);
84 Return the partition specified in a path, as taken from the devoptab.
86 PARTITION
* _FAT_partition_getPartitionFromPath (const char* path
);
88 #endif // _PARTITION_H