"Fossies" - the Fresh Open Source Software Archive
Member "dosfstools-4.2/src/fat.h" (31 Jan 2021, 3119 Bytes) of package /linux/misc/dosfstools-4.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard
) with prefixed line numbers and code folding
Alternatively you can here view
the uninterpreted source code file.
For more information about "fat.h" see the Fossies "Dox" file reference
documentation and the latest Fossies "Diffs"
side-by-side code changes report: 4.1_vs_4.2
1 /* fat.h - Read/write access to the FAT
3 Copyright (C) 1993 Werner Almesberger <email@example.com>
4 Copyright (C) 2008-2014 Daniel Baumann <firstname.lastname@example.org>
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.
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.
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/>.
19 THe complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
23 #ifndef _FAT_H
24 #define _FAT_H
26 void read_fat(DOS_FS * fs, int mode);
28 /* Loads the FAT of the filesystem described by FS. Initializes the FAT,
29 replaces broken FATs and rejects invalid cluster entries. */
31 void release_fat(DOS_FS * fs);
33 /* Release the FAT of the filesystem described by FS and free allocated memory.
34 Call it after finish work with FAT. */
36 void get_fat(FAT_ENTRY * entry, void *fat, uint32_t cluster, DOS_FS * fs);
38 /* Retrieve the FAT entry (next chained cluster) for CLUSTER. */
40 void set_fat(DOS_FS * fs, uint32_t cluster, int32_t new);
42 /* Changes the value of the CLUSTERth cluster of the FAT of FS to NEW. Special
43 values of NEW are -1 (EOF, 0xff8 or 0xfff8) and -2 (bad sector, 0xff7 or
44 0xfff7) */
46 int bad_cluster(DOS_FS * fs, uint32_t cluster);
48 /* Returns a non-zero integer if the CLUSTERth cluster is marked as bad or zero
49 otherwise. */
51 uint32_t next_cluster(DOS_FS * fs, uint32_t cluster);
53 /* Returns the number of the cluster following CLUSTER, or -1 if this is the
54 last cluster of the respective cluster chain. CLUSTER must not be a bad
55 cluster. */
57 off_t cluster_start(DOS_FS * fs, uint32_t cluster);
59 /* Returns the byte offset of CLUSTER, relative to the respective device. */
61 void set_owner(DOS_FS * fs, uint32_t cluster, DOS_FILE * owner);
63 /* Sets the owner pointer of the respective cluster to OWNER. If OWNER was NULL
64 before, it can be set to NULL or any non-NULL value. Otherwise, only NULL is
65 accepted as the new value. */
67 DOS_FILE *get_owner(DOS_FS * fs, uint32_t cluster);
69 /* Returns the owner of the repective cluster or NULL if the cluster has no
70 owner. */
72 void fix_bad(DOS_FS * fs);
74 /* Scans the disk for currently unused bad clusters and marks them as bad. */
76 void reclaim_free(DOS_FS * fs);
78 /* Marks all allocated, but unused clusters as free. */
80 void reclaim_file(DOS_FS * fs);
82 /* Scans the FAT for chains of allocated, but unused clusters and creates files
83 for them in the root directory. Also tries to fix all inconsistencies (e.g.
84 loops, shared clusters, etc.) in the process. */
86 uint32_t update_free(DOS_FS * fs);
88 /* Updates free cluster count in FSINFO sector. */