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/* FIXME: YUCKY */
55#include "table.h"
56#include "bootsector.h"
57#include "context.h"
58#include "fatio.h"
59#include "traverse.h"
60#include "calc.h"
61#include "count.h"
62#include "clstdup.h"
63
64struct __attribute__ ((packed)) _FatDirEntry {
65 char name[8];
66 uint8_t extension[3];
67 uint8_t attributes;
68 uint8_t is_upper_case_name;
69 uint8_t creation_time_low; /* milliseconds */
70 uint16_t creation_time_high;
71 uint16_t creation_date;
72 uint16_t access_date;
73 uint16_t first_cluster_high; /* for FAT32 */
74 uint16_t time;
75 uint16_t date;
76 uint16_t first_cluster;
77 uint32_t length;
78};
79
80struct _FatSpecific {
81 FatBootSector *boot_sector; /* structure of boot sector */
82 FatInfoSector *info_sector; /* fat32-only information sector */
83
84 int logical_sector_size; /* illogical sector size :-) */
86
87 int sectors_per_track; /* BIOS CHS stuff (S) */
88 int heads; /* BIOS CHS stuff (H) */
89
90 int cluster_size;
94
98
99 uint32_t serial_number;
100
101 PedSector info_sector_offset; /* FAT32 only */
103 PedSector root_dir_offset; /* non-FAT32 */
106
107 FatCluster root_cluster; /* FAT32 only */
108 int root_dir_entry_count; /* non-FAT32 */
109 PedSector root_dir_sector_count; /* non-FAT32 */
111
112 FatTable* fat;
114
116 char* buffer;
117
118 int frag_size;
123};
124
125#define FAT_SPECIFIC(fs) ((FatSpecific*) fs->type_specific)
126
127#define FAT_ROOT 0
128
129#define DELETED_FLAG 0xe5
130
131#define READONLY_ATTR 0x01
132#define HIDDEN_ATTR 0x02
133#define SYSTEM_ATTR 0x04
134#define VOLUME_LABEL_ATTR 0x08
135#define VFAT_ATTR 0x0f
136#define DIRECTORY_ATTR 0x10
137#define ARCH_ATTR 0x20
138
139#define MAX_FAT12_CLUSTERS 4086
140#define MAX_FAT16_CLUSTERS 65526
141#define MAX_FAT32_CLUSTERS 2000000
142
143#define FAT_ROOT_DIR_ENTRY_COUNT 512
144
147
148extern void fat_print (const PedFileSystem* fs);
149
150extern PedFileSystem* fat_alloc (const PedGeometry* geom);
151extern void fat_free (PedFileSystem* fs);
152extern int fat_alloc_buffers (PedFileSystem* fs);
153extern void fat_free_buffers (PedFileSystem* fs);
154
155extern int fat_resize (PedFileSystem* fs, PedGeometry* geom, PedTimer* timer);
156
157extern int fat_set_frag_sectors (PedFileSystem* fs, PedSector frag_sectors);
158
159#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
void fat_free_buffers(PedFileSystem *fs)
Definition: fat.c:81
int fat_set_frag_sectors(PedFileSystem *fs, PedSector frag_sectors)
Definition: fat.c:100
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
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