another shot at fixing writes
[reactos.git] / rosapps / sysutils / dosfsck / fat.h
1 /* fat.h - Read/write access to the FAT */
2
3 /* Written 1993 by Werner Almesberger */
4
5
6 #ifndef _FAT_H
7 #define _FAT_H
8
9 void read_fat(DOS_FS *fs);
10
11 /* Loads the FAT of the file system described by FS. Initializes the FAT,
12 replaces broken FATs and rejects invalid cluster entries. */
13
14 void set_fat(DOS_FS *fs,unsigned long cluster,unsigned long new);
15
16 /* Changes the value of the CLUSTERth cluster of the FAT of FS to NEW. Special
17 values of NEW are -1 (EOF, 0xff8 or 0xfff8) and -2 (bad sector, 0xff7 or
18 0xfff7) */
19
20 int bad_cluster(DOS_FS *fs,unsigned long cluster);
21
22 /* Returns a non-zero integer if the CLUSTERth cluster is marked as bad or zero
23 otherwise. */
24
25 unsigned long next_cluster(DOS_FS *fs,unsigned long cluster);
26
27 /* Returns the number of the cluster following CLUSTER, or -1 if this is the
28 last cluster of the respective cluster chain. CLUSTER must not be a bad
29 cluster. */
30
31 loff_t cluster_start(DOS_FS *fs,unsigned long cluster);
32
33 /* Returns the byte offset of CLUSTER, relative to the respective device. */
34
35 void set_owner(DOS_FS *fs,unsigned long cluster,DOS_FILE *owner);
36
37 /* Sets the owner pointer of the respective cluster to OWNER. If OWNER was NULL
38 before, it can be set to NULL or any non-NULL value. Otherwise, only NULL is
39 accepted as the new value. */
40
41 DOS_FILE *get_owner(DOS_FS *fs,unsigned long cluster);
42
43 /* Returns the owner of the repective cluster or NULL if the cluster has no
44 owner. */
45
46 void fix_bad(DOS_FS *fs);
47
48 /* Scans the disk for currently unused bad clusters and marks them as bad. */
49
50 void reclaim_free(DOS_FS *fs);
51
52 /* Marks all allocated, but unused clusters as free. */
53
54 void reclaim_file(DOS_FS *fs);
55
56 /* Scans the FAT for chains of allocated, but unused clusters and creates files
57 for them in the root directory. Also tries to fix all inconsistencies (e.g.
58 loops, shared clusters, etc.) in the process. */
59
60 unsigned long update_free(DOS_FS *fs);
61
62 /* Updates free cluster count in FSINFO sector. */
63
64 #endif