RetroArch
partition.h
Go to the documentation of this file.
1 /*
2  partition.h
3  Functions for mounting and dismounting partitions
4  on various block devices.
5 
6  Copyright (c) 2006 Michael "Chishm" Chisholm
7 
8  Redistribution and use in source and binary forms, with or without modification,
9  are permitted provided that the following conditions are met:
10 
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.
18 
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.
28 */
29 
30 #ifndef _PARTITION_H
31 #define _PARTITION_H
32 
33 #include "common.h"
34 #include "cache.h"
35 #include "lock.h"
36 
37 #define MIN_SECTOR_SIZE 512
38 #define MAX_SECTOR_SIZE 4096
39 
40 /* Filesystem type */
42 
43 typedef struct {
50 } FAT;
51 
52 typedef struct {
55  /* Info about the partition */
67  /* Values that may change after construction */
68  uint32_t cwdCluster; /* Current working directory cluster */
70  struct _FILE_STRUCT* firstOpenFile; /* The start of a linked list of files */
71  mutex_t lock; /* A lock for partition operations */
72  bool readOnly; /* If this is set, then do not try writing to the disc */
73  char label[12]; /* Volume label */
74 } PARTITION;
75 
76 /*
77 Mount the supplied device and return a pointer to the struct necessary to use it
78 */
79 PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cacheSize, uint32_t SectorsPerPage, sec_t startSector);
80 
81 /*
82 Dismount the device and free all structures used.
83 Will also attempt to synchronise all open files to disc.
84 */
86 
87 /*
88 Return the partition specified in a path, as taken from the devoptab.
89 */
91 
92 /*
93 Create the fs info sector.
94 */
96 
97 /*
98 Read the fs info sector data.
99 */
101 
102 /*
103 Write the fs info sector data.
104 */
106 
107 #endif /* _PARTITION_H */
Definition: fatfile.h:52
uint32_t sectorsPerFat
Definition: partition.h:45
uint32_t bytesPerCluster
Definition: partition.h:64
uint64_t totalSize
Definition: partition.h:57
int mutex_t
typedef for the mutex handle
Definition: lock.c:6
uint32_t rootDirCluster
Definition: partition.h:59
Definition: partition.h:41
void _FAT_partition_readFSinfo(PARTITION *partition)
Definition: partition.c:394
const DISC_INTERFACE * disc
Definition: partition.h:53
uint32_t lastCluster
Definition: partition.h:46
GLsizei const GLchar ** path
Definition: glext.h:7901
int openFileCount
Definition: partition.h:69
GLuint GLsizei const GLchar * label
Definition: glext.h:8583
uint32_t numberLastAllocCluster
Definition: partition.h:49
uint32_t numberOfSectors
Definition: partition.h:60
uint32_t numberFreeCluster
Definition: partition.h:48
PARTITION * _FAT_partition_getPartitionFromPath(const char *path)
Definition: partition.c:353
FAT fat
Definition: partition.h:66
uint32_t firstFree
Definition: partition.h:47
uint32_t cwdCluster
Definition: partition.h:68
void _FAT_partition_writeFSinfo(PARTITION *partition)
Definition: partition.c:425
static IdxT partition(lua_State *L, IdxT lo, IdxT up)
Definition: ltablib.c:310
uint32_t sec_t
Definition: iosuhax_disc_interface.h:40
struct _FILE_STRUCT * firstOpenFile
Definition: partition.h:70
FS_TYPE filesysType
Definition: partition.h:56
Definition: partition.h:41
Definition: partition.h:52
void _FAT_partition_createFSinfo(PARTITION *partition)
Definition: partition.c:363
uint32_t sectorsPerCluster
Definition: partition.h:63
FS_TYPE
Definition: partition.h:41
PARTITION * _FAT_partition_constructor(const DISC_INTERFACE *disc, uint32_t cacheSize, uint32_t SectorsPerPage, sec_t startSector)
Definition: partition.c:311
CACHE * cache
Definition: partition.h:54
Definition: cache.h:50
Definition: partition.h:41
Definition: iosuhax_disc_interface.h:52
sec_t dataStart
Definition: partition.h:61
mutex_t lock
Definition: partition.h:71
Definition: partition.h:41
sec_t rootDirStart
Definition: partition.h:58
sec_t fatStart
Definition: partition.h:44
Definition: partition.h:43
bool readOnly
Definition: partition.h:72
unsigned __int64 uint64_t
Definition: stdint.h:136
unsigned int uint32_t
Definition: stdint.h:126
void _FAT_partition_destructor(PARTITION *partition)
Definition: partition.c:325
uint32_t bytesPerSector
Definition: partition.h:62
uint32_t fsInfoSector
Definition: partition.h:65