1 /* $NetBSD: ext.h,v 1.5 1997/10/17 11:19:48 ws Exp $ */ 2 3 /* 4 * Copyright (C) 1995, 1996, 1997 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 #include "dosfs.h" 41 42 #define LOSTDIR "LOST.DIR" 43 44 /* 45 * Options: 46 */ 47 extern int alwaysno; /* assume "no" for all questions */ 48 extern int alwaysyes; /* assume "yes" for all questions */ 49 extern int preen; /* we are preening */ 50 extern int rdonly; /* device is opened read only (supersedes above) */ 51 52 extern char *fname; /* filesystem currently checked */ 53 54 extern struct dosDirEntry *rootDir; 55 56 /* 57 * function declarations 58 */ 59 int ask __P((int, const char *, ...)); 60 61 /* 62 * Check filesystem given as arg 63 */ 64 int checkfilesys __P((const char *)); 65 66 /* 67 * Return values of various functions 68 */ 69 #define FSOK 0 /* Check was OK */ 70 #define FSBOOTMOD 1 /* Boot block was modified */ 71 #define FSDIRMOD 2 /* Some directory was modified */ 72 #define FSFATMOD 4 /* The FAT was modified */ 73 #define FSERROR 8 /* Some unrecovered error remains */ 74 #define FSFATAL 16 /* Some unrecoverable error occured */ 75 76 /* 77 * read a boot block in a machine independend fashion and translate 78 * it into our struct bootblock. 79 */ 80 int readboot __P((int, struct bootblock *)); 81 82 /* 83 * Correct the FSInfo block. 84 */ 85 int writefsinfo __P((int, struct bootblock *)); 86 87 /* 88 * Read one of the FAT copies and return a pointer to the new 89 * allocated array holding our description of it. 90 */ 91 int readfat __P((int, struct bootblock *, int, struct fatEntry **)); 92 93 /* 94 * Check two FAT copies for consistency and merge changes into the 95 * first if neccessary. 96 */ 97 int comparefat __P((struct bootblock *, struct fatEntry *, struct fatEntry *, int)); 98 99 /* 100 * Check a FAT 101 */ 102 int checkfat __P((struct bootblock *, struct fatEntry *)); 103 104 /* 105 * Write back FAT entries 106 */ 107 int writefat __P((int, struct bootblock *, struct fatEntry *)); 108 109 /* 110 * Read a directory 111 */ 112 int resetDosDirSection __P((struct bootblock *, struct fatEntry *)); 113 void finishDosDirSection __P((void)); 114 int handleDirTree __P((int, struct bootblock *, struct fatEntry *)); 115 116 /* 117 * Cross-check routines run after everything is completely in memory 118 */ 119 /* 120 * Check for lost cluster chains 121 */ 122 int checklost __P((int, struct bootblock *, struct fatEntry *)); 123 /* 124 * Try to reconnect a lost cluster chain 125 */ 126 int reconnect __P((int, struct bootblock *, struct fatEntry *, cl_t)); 127 void finishlf __P((void)); 128 129 /* 130 * Small helper functions 131 */ 132 /* 133 * Return the type of a reserved cluster as text 134 */ 135 char *rsrvdcltype __P((cl_t)); 136 137 /* 138 * Clear a cluster chain in a FAT 139 */ 140 void clearchain __P((struct bootblock *, struct fatEntry *, cl_t)); 141 142 #endif 143