ext.h revision 1.2 1 /* $NetBSD: ext.h,v 1.2 1996/05/25 17:09:46 ws Exp $ */
2
3 /*
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank
5 * Copyright (c) 1995 Martin Husemann
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Martin Husemann
18 * and Wolfgang Solfrank.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef EXT_H
36 #define EXT_H
37
38 #include <sys/types.h>
39
40 #if sun
41 #define __P(a) a
42
43 typedef char int8_t;
44 typedef unsigned char u_int8_t;
45 typedef short int16_t;
46 typedef unsigned short u_int16_t;
47 typedef long int32_t;
48 typedef unsigned long u_int32_t;
49 #endif
50
51 #include "dosfs.h"
52
53 #define LOSTDIR "LOST.DIR"
54
55 /*
56 * Options:
57 */
58 extern int alwaysno; /* assume "no" for all questions */
59 extern int alwaysyes; /* assume "yes" for all questions */
60 extern int preen; /* we are preening */
61 extern int rdonly; /* device is opened read only (supersedes above) */
62
63 extern char *fname; /* filesystem currently checked */
64
65 /*
66 * function declarations
67 */
68 void errexit __P((const char *, ...));
69 void pfatal __P((const char *, ...));
70 void pwarn __P((const char *, ...));
71 int ask __P((int, const char *, ...));
72 void perror __P((const char *));
73
74 /*
75 * Check filesystem given as arg
76 */
77 int checkfilesys __P((const char *));
78
79 /*
80 * Return values of various functions
81 */
82 #define FSOK 0 /* Check was OK */
83 #define FSDIRMOD 1 /* Some directory was modified */
84 #define FSFATMOD 2 /* The FAT was modified */
85 #define FSERROR 4 /* Some unrecovered error remains */
86 #define FSFATAL 8 /* Some unrecoverable error occured */
87
88 /*
89 * read a boot block in a machine independend fashion and translate
90 * it into our struct bootblock.
91 */
92 int readboot __P((int, struct bootblock *));
93
94
95 /*
96 * Read one of the FAT copies and return a pointer to the new
97 * allocated array holding our description of it.
98 */
99 int readfat __P((int, struct bootblock *, int, struct fatEntry **));
100
101 /*
102 * Check two FAT copies for consistency and merge changes into the
103 * first if neccessary.
104 */
105 int comparefat __P((struct bootblock *, struct fatEntry *, struct fatEntry *, int));
106
107 /*
108 * Check a FAT
109 */
110 int checkfat __P((struct bootblock *, struct fatEntry *));
111
112 /*
113 * Write back FAT entries
114 */
115 int writefat __P((int, struct bootblock *, struct fatEntry *));
116
117 /*
118 * Read a directory
119 */
120 int resetDosDirSection __P((struct bootblock *));
121 void finishDosDirSection __P((void));
122 int readDosDirSection __P((int, struct bootblock *, struct fatEntry *, struct dosDirEntry *));
123
124 /*
125 * A stack of directories which should be examined later
126 */
127 extern struct dirTodoNode *pendingDirectories;
128
129 /*
130 * Cross-check routines run after everything is completely in memory
131 */
132 /*
133 * Check for lost cluster chains
134 */
135 int checklost __P((int, struct bootblock *, struct fatEntry *, struct dosDirEntry *));
136 /*
137 * Try to reconnect a lost cluster chain
138 */
139 int reconnect __P((int, struct bootblock *, struct fatEntry *, cl_t, struct dosDirEntry *));
140 void finishlf __P((void));
141
142 /*
143 * Small helper functions
144 */
145 /*
146 * Return the type of a reserved cluster as text
147 */
148 char *rsrvdcltype __P((cl_t));
149
150 /*
151 * Clear a cluster chain in a FAT
152 */
153 void clearchain __P((struct bootblock *, struct fatEntry *, cl_t));
154
155 #endif
156