3
Copyright (C) 1998-2001, 2007, 2009-2012 Free Software Foundation, Inc.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 3 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#ifndef FAT_H_INCLUDED
20
#define FAT_H_INCLUDED
22
#include <parted/parted.h>
23
#include <parted/endian.h>
24
#include <parted/debug.h>
28
# define _(String) dgettext (PACKAGE, String)
30
# define _(String) (String)
31
#endif /* ENABLE_NLS */
34
#include <sys/types.h>
38
#define BUFFER_SIZE 1024 /* buffer size in sectors (512 bytes) */
40
typedef uint32_t FatCluster;
41
typedef int32_t FatFragment;
48
typedef enum _FatType FatType;
50
typedef struct _FatSpecific FatSpecific;
51
typedef struct _FatDirEntry FatDirEntry;
55
#include "bootsector.h"
63
struct __attribute__ ((packed)) _FatDirEntry {
67
uint8_t is_upper_case_name;
68
uint8_t creation_time_low; /* milliseconds */
69
uint16_t creation_time_high;
70
uint16_t creation_date;
72
uint16_t first_cluster_high; /* for FAT32 */
75
uint16_t first_cluster;
80
FatBootSector boot_sector; /* structure of boot sector */
81
FatInfoSector info_sector; /* fat32-only information sector */
83
int logical_sector_size; /* illogical sector size :-) */
84
PedSector sector_count;
86
int sectors_per_track; /* BIOS CHS stuff (S) */
87
int heads; /* BIOS CHS stuff (H) */
90
PedSector cluster_sectors;
91
FatCluster cluster_count;
92
int dir_entries_per_cluster;
96
PedSector fat_sectors;
98
uint32_t serial_number;
100
PedSector info_sector_offset; /* FAT32 only */
101
PedSector fat_offset;
102
PedSector root_dir_offset; /* non-FAT32 */
103
PedSector cluster_offset;
104
PedSector boot_sector_backup_offset;
106
FatCluster root_cluster; /* FAT32 only */
107
int root_dir_entry_count; /* non-FAT32 */
108
PedSector root_dir_sector_count; /* non-FAT32 */
109
FatCluster total_dir_clusters;
112
FatClusterInfo* cluster_info;
114
PedSector buffer_sectors;
118
PedSector frag_sectors;
119
FatFragment frag_count;
120
FatFragment buffer_frags;
121
FatFragment cluster_frags;
124
#define FAT_SPECIFIC(fs) ((FatSpecific*) fs->type_specific)
128
#define DELETED_FLAG 0xe5
130
#define READONLY_ATTR 0x01
131
#define HIDDEN_ATTR 0x02
132
#define SYSTEM_ATTR 0x04
133
#define VOLUME_LABEL_ATTR 0x08
134
#define VFAT_ATTR 0x0f
135
#define DIRECTORY_ATTR 0x10
136
#define ARCH_ATTR 0x20
138
#define MAX_FAT12_CLUSTERS 4086
139
#define MAX_FAT16_CLUSTERS 65526
140
#define MAX_FAT32_CLUSTERS 2000000
142
#define FAT_ROOT_DIR_ENTRY_COUNT 512
144
extern PedFileSystemType fat16_type;
145
extern PedFileSystemType fat32_type;
147
extern void fat_print (const PedFileSystem* fs);
149
extern PedFileSystem* fat_alloc (const PedGeometry* geom);
150
extern void fat_free (PedFileSystem* fs);
151
extern int fat_alloc_buffers (PedFileSystem* fs);
152
extern void fat_free_buffers (PedFileSystem* fs);
154
extern int fat_resize (PedFileSystem* fs, PedGeometry* geom, PedTimer* timer);
156
extern int fat_set_frag_sectors (PedFileSystem* fs, PedSector frag_sectors);
158
#endif /* FAT_H_INCLUDED */