libparted 3.6
Loading...
Searching...
No Matches
fat.h
Go to the documentation of this file.
1/*
2 libparted
3 Copyright (C) 1998-2001, 2007, 2009-2014, 2019-2023 Free Software
4 Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef FAT_H_INCLUDED
21#define FAT_H_INCLUDED
22
23#include <parted/parted.h>
24#include <parted/endian.h>
25#include <parted/debug.h>
26
27#if ENABLE_NLS
28# include <libintl.h>
29# define _(String) dgettext (PACKAGE, String)
30#else
31# define _(String) (String)
32#endif /* ENABLE_NLS */
33
34#include <stdlib.h>
35#include <sys/types.h>
36#include <sys/stat.h>
37#include <fcntl.h>
38
39#define BUFFER_SIZE 1024 /* buffer size in sectors (512 bytes) */
40
41typedef uint32_t FatCluster;
42typedef int32_t FatFragment;
43
48};
49typedef enum _FatType FatType;
50
52typedef struct _FatDirEntry FatDirEntry;
53
54#include "bootsector.h"
55#include "count.h"
56
57struct _FatTable {
58 void* table;
61
66
68};
69typedef struct _FatTable FatTable;
70
71struct __attribute__ ((packed)) _FatDirEntry {
72 char name[8];
73 uint8_t extension[3];
74 uint8_t attributes;
75 uint8_t is_upper_case_name;
76 uint8_t creation_time_low; /* milliseconds */
77 uint16_t creation_time_high;
78 uint16_t creation_date;
79 uint16_t access_date;
80 uint16_t first_cluster_high; /* for FAT32 */
81 uint16_t time;
82 uint16_t date;
83 uint16_t first_cluster;
84 uint32_t length;
85};
86
88 FatBootSector *boot_sector; /* structure of boot sector */
89 FatInfoSector *info_sector; /* fat32-only information sector */
90
91 int logical_sector_size; /* illogical sector size :-) */
93
94 int sectors_per_track; /* BIOS CHS stuff (S) */
95 int heads; /* BIOS CHS stuff (H) */
96
101
105
107
110 PedSector root_dir_offset; /* non-FAT32 */
113
114 FatCluster root_cluster; /* FAT32 only */
115 int root_dir_entry_count; /* non-FAT32 */
118
121
123 char* buffer;
124
130};
131
132#define FAT_SPECIFIC(fs) ((FatSpecific*) fs->type_specific)
133
134#define FAT_ROOT 0
135
136#define DELETED_FLAG 0xe5
137
138#define READONLY_ATTR 0x01
139#define HIDDEN_ATTR 0x02
140#define SYSTEM_ATTR 0x04
141#define VOLUME_LABEL_ATTR 0x08
142#define VFAT_ATTR 0x0f
143#define DIRECTORY_ATTR 0x10
144#define ARCH_ATTR 0x20
145
146#define MAX_FAT12_CLUSTERS 4086
147#define MAX_FAT16_CLUSTERS 65526
148#define MAX_FAT32_CLUSTERS 2000000
149
150#define FAT_ROOT_DIR_ENTRY_COUNT 512
151
154
155extern void fat_print (const PedFileSystem* fs);
156
157extern PedFileSystem* fat_alloc (const PedGeometry* geom);
158extern void fat_free (PedFileSystem* fs);
159extern int fat_alloc_buffers (PedFileSystem* fs);
160
161extern int fat_resize (PedFileSystem* fs, PedGeometry* geom, PedTimer* timer);
162
163#endif /* FAT_H_INCLUDED */
typedef __attribute__
Definition: vtoc.h:80
uint32_t length
Definition: dos.c:5
struct _FatInfoSector FatInfoSector
Definition: bootsector.h:24
struct _FatBootSector FatBootSector
Definition: bootsector.h:23
struct _FatClusterInfo FatClusterInfo
Definition: count.h:24
PedFileSystem * fat_alloc(const PedGeometry *geom)
Definition: fat.c:27
enum _FatType FatType
Definition: fat.h:49
int fat_alloc_buffers(PedFileSystem *fs)
Definition: fat.c:59
_FatType
Definition: fat.h:44
@ FAT_TYPE_FAT16
Definition: fat.h:46
@ FAT_TYPE_FAT32
Definition: fat.h:47
@ FAT_TYPE_FAT12
Definition: fat.h:45
void fat_free(PedFileSystem *fs)
Definition: fat.c:57
PedFileSystemType fat32_type
Definition: fat.c:138
int32_t FatFragment
Definition: fat.h:42
PedFileSystemType fat16_type
Definition: fat.c:132
int fat_resize(PedFileSystem *fs, PedGeometry *geom, PedTimer *timer)
Definition: resize.c:825
void fat_print(const PedFileSystem *fs)
uint32_t FatCluster
Definition: fat.h:41
struct _FatDirEntry FatDirEntry
Definition: fat.h:52
long long PedSector
We can address 2^63 sectors.
Definition: device.h:31
char name[16]
Definition: pc98.c:13
enum _FatType FatType
Definition: fat.h:49
int32_t FatFragment
Definition: fat.h:42
uint32_t FatCluster
Definition: fat.h:41
Definition: fat.h:87
PedSector root_dir_sector_count
Definition: fat.h:116
FatFragment cluster_frags
Definition: fat.h:129
FatFragment buffer_frags
Definition: fat.h:128
int fat_table_count
Definition: fat.h:103
uint32_t serial_number
Definition: fat.h:106
PedSector fat_sectors
Definition: fat.h:104
PedSector cluster_offset
Definition: fat.h:111
FatCluster cluster_count
Definition: fat.h:99
PedSector buffer_sectors
Definition: fat.h:122
int heads
Definition: fat.h:95
FatCluster total_dir_clusters
Definition: fat.h:117
PedSector fat_offset
Definition: fat.h:109
PedSector sector_count
Definition: fat.h:92
PedSector info_sector_offset
Definition: fat.h:108
int dir_entries_per_cluster
Definition: fat.h:100
FatBootSector * boot_sector
Definition: fat.h:88
FatInfoSector * info_sector
Definition: fat.h:89
PedSector boot_sector_backup_offset
Definition: fat.h:112
FatFragment frag_count
Definition: fat.h:127
int root_dir_entry_count
Definition: fat.h:115
int cluster_size
Definition: fat.h:97
char * buffer
Definition: fat.h:123
FatClusterInfo * cluster_info
Definition: fat.h:120
int logical_sector_size
Definition: fat.h:91
FatTable * fat
Definition: fat.h:119
FatType fat_type
Definition: fat.h:102
int frag_size
Definition: fat.h:125
PedSector root_dir_offset
Definition: fat.h:110
PedSector cluster_sectors
Definition: fat.h:98
FatCluster root_cluster
Definition: fat.h:114
PedSector frag_sectors
Definition: fat.h:126
int sectors_per_track
Definition: fat.h:94
Definition: fat.h:57
FatCluster bad_cluster_count
Definition: fat.h:65
FatCluster cluster_count
Definition: fat.h:63
void * table
Definition: fat.h:58
FatCluster size
Definition: fat.h:59
int raw_size
Definition: fat.h:60
FatCluster last_alloc
Definition: fat.h:67
FatCluster free_cluster_count
Definition: fat.h:64
FatType fat_type
Definition: fat.h:62
Structure describing type of file system.
Definition: filesys.h:46
Structure describing file system.
Definition: filesys.h:68
Geometry of the partition.
Definition: geom.h:35
Definition: timer.h:39