1 | #ifndef MTOOLS_FSP_H
|
---|
2 | #define MTOOLS_FSP_H
|
---|
3 |
|
---|
4 | #include "stream.h"
|
---|
5 | #include "msdos.h"
|
---|
6 | #include "fs.h"
|
---|
7 |
|
---|
8 | typedef enum fatAccessMode_t {
|
---|
9 | FAT_ACCESS_READ,
|
---|
10 | FAT_ACCESS_WRITE
|
---|
11 | } fatAccessMode_t;
|
---|
12 |
|
---|
13 | typedef struct Fs_t {
|
---|
14 | Class_t *Class;
|
---|
15 | int refs;
|
---|
16 | Stream_t *Next;
|
---|
17 | Stream_t *Buffer;
|
---|
18 |
|
---|
19 | int serialized;
|
---|
20 | unsigned long serial_number;
|
---|
21 | int cluster_size;
|
---|
22 | unsigned int sector_size;
|
---|
23 | int fat_error;
|
---|
24 |
|
---|
25 | unsigned int (*fat_decode)(struct Fs_t *This, unsigned int num);
|
---|
26 | void (*fat_encode)(struct Fs_t *This, unsigned int num,
|
---|
27 | unsigned int code);
|
---|
28 |
|
---|
29 | Stream_t *Direct;
|
---|
30 | int fat_dirty;
|
---|
31 | unsigned int fat_start;
|
---|
32 | unsigned int fat_len;
|
---|
33 |
|
---|
34 | int num_fat;
|
---|
35 | unsigned int end_fat;
|
---|
36 | unsigned int last_fat;
|
---|
37 | int fat_bits;
|
---|
38 | struct FatMap_t *FatMap;
|
---|
39 |
|
---|
40 | int dir_start;
|
---|
41 | int dir_len;
|
---|
42 | int clus_start;
|
---|
43 |
|
---|
44 | int num_clus;
|
---|
45 | char *drive; /* for error messages */
|
---|
46 |
|
---|
47 | /* fat 32 */
|
---|
48 | unsigned int primaryFat;
|
---|
49 | unsigned int writeAllFats;
|
---|
50 | unsigned int rootCluster;
|
---|
51 | int infoSectorLoc;
|
---|
52 | unsigned int last; /* last sector allocated, or MAX32 if unknown */
|
---|
53 | unsigned int freeSpace; /* free space, or MAX32 if unknown */
|
---|
54 | int preallocatedClusters;
|
---|
55 |
|
---|
56 | int lastFatSectorNr;
|
---|
57 | unsigned char *lastFatSectorData;
|
---|
58 | fatAccessMode_t lastFatAccessMode;
|
---|
59 | int sectorMask;
|
---|
60 | int sectorShift;
|
---|
61 | } Fs_t;
|
---|
62 |
|
---|
63 | int fs_free(Stream_t *Stream);
|
---|
64 |
|
---|
65 | void set_fat12(Fs_t *Fs);
|
---|
66 | void set_fat16(Fs_t *Fs);
|
---|
67 | void set_fat32(Fs_t *Fs);
|
---|
68 | unsigned int get_next_free_cluster(Fs_t *Fs, unsigned int last);
|
---|
69 | unsigned int fatDecode(Fs_t *This, unsigned int pos);
|
---|
70 | void fatAppend(Fs_t *This, unsigned int pos, unsigned int newpos);
|
---|
71 | void fatDeallocate(Fs_t *This, unsigned int pos);
|
---|
72 | void fatAllocate(Fs_t *This, unsigned int pos, unsigned int value);
|
---|
73 | void fatEncode(Fs_t *This, unsigned int pos, unsigned int value);
|
---|
74 |
|
---|
75 | int fat_read(Fs_t *This, struct bootsector *boot, int fat_bits,
|
---|
76 | size_t tot_sectors, int nodups);
|
---|
77 | void fat_write(Fs_t *This);
|
---|
78 | int zero_fat(Fs_t *Fs, int media_descriptor);
|
---|
79 | extern Class_t FsClass;
|
---|
80 | int fsPreallocateClusters(Fs_t *Fs, long);
|
---|
81 | Fs_t *getFs(Stream_t *Stream);
|
---|
82 |
|
---|
83 |
|
---|
84 | #endif
|
---|