ReactOS 0.4.16-dev-197-g92996da
fat.h
Go to the documentation of this file.
1/* fat.h - Read/write access to the FAT
2
3 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
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 THe complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21*/
22
23#ifndef _FAT_H
24#define _FAT_H
25
26void read_fat(DOS_FS * fs);
27
28/* Loads the FAT of the filesystem described by FS. Initializes the FAT,
29 replaces broken FATs and rejects invalid cluster entries. */
30
31void get_fat(FAT_ENTRY * entry, void *fat, uint32_t cluster, DOS_FS * fs);
32
33/* Retrieve the FAT entry (next chained cluster) for CLUSTER. */
34
35void set_fat(DOS_FS * fs, uint32_t cluster, int32_t new);
36
37/* Changes the value of the CLUSTERth cluster of the FAT of FS to NEW. Special
38 values of NEW are -1 (EOF, 0xff8 or 0xfff8) and -2 (bad sector, 0xff7 or
39 0xfff7) */
40
41int bad_cluster(DOS_FS * fs, uint32_t cluster);
42
43/* Returns a non-zero integer if the CLUSTERth cluster is marked as bad or zero
44 otherwise. */
45
47
48/* Returns the number of the cluster following CLUSTER, or -1 if this is the
49 last cluster of the respective cluster chain. CLUSTER must not be a bad
50 cluster. */
51
53
54/* Returns the byte offset of CLUSTER, relative to the respective device. */
55
56void set_owner(DOS_FS * fs, uint32_t cluster, DOS_FILE * owner);
57
58/* Sets the owner pointer of the respective cluster to OWNER. If OWNER was NULL
59 before, it can be set to NULL or any non-NULL value. Otherwise, only NULL is
60 accepted as the new value. */
61
63
64/* Returns the owner of the repective cluster or NULL if the cluster has no
65 owner. */
66
67void fix_bad(DOS_FS * fs);
68
69/* Scans the disk for currently unused bad clusters and marks them as bad. */
70
71void reclaim_free(DOS_FS * fs);
72
73/* Marks all allocated, but unused clusters as free. */
74
75void reclaim_file(DOS_FS * fs);
76
77/* Scans the FAT for chains of allocated, but unused clusters and creates files
78 for them in the root directory. Also tries to fix all inconsistencies (e.g.
79 loops, shared clusters, etc.) in the process. */
80
82
83/* Updates free cluster count in FSINFO sector. */
84
85#endif
INT32 int32_t
Definition: types.h:71
UINT32 uint32_t
Definition: types.h:75
__kernel_off_t off_t
Definition: linux.h:201
uint32_t entry
Definition: isohybrid.c:63
static unsigned char * fat
Definition: mkdosfs.c:542
void fix_bad(DOS_FS *fs)
Definition: fat.c:322
void reclaim_free(DOS_FS *fs)
Definition: fat.c:340
uint32_t next_cluster(DOS_FS *fs, uint32_t cluster)
Definition: fat.c:276
void set_owner(DOS_FS *fs, uint32_t cluster, DOS_FILE *owner)
Definition: fat.c:303
DOS_FILE * get_owner(DOS_FS *fs, uint32_t cluster)
Definition: fat.c:314
int bad_cluster(DOS_FS *fs, uint32_t cluster)
Definition: fat.c:258
uint32_t update_free(DOS_FS *fs)
Definition: fat.c:531
void read_fat(DOS_FS *fs)
Definition: fat.c:81
off_t cluster_start(DOS_FS *fs, uint32_t cluster)
Definition: fat.c:289
void get_fat(FAT_ENTRY *entry, void *fat, uint32_t cluster, DOS_FS *fs)
Definition: fat.c:41
void set_fat(DOS_FS *fs, uint32_t cluster, int32_t new)
Definition: fat.c:189
void reclaim_file(DOS_FS *fs)
Definition: fat.c:426
Definition: fsck.fat.h:192
Definition: ffs.h:70