ext.h revision 96707
1193326Sed/* 2193326Sed * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank 3193326Sed * Copyright (c) 1995 Martin Husemann 4193326Sed * 5193326Sed * Redistribution and use in source and binary forms, with or without 6193326Sed * modification, are permitted provided that the following conditions 7193326Sed * are met: 8193326Sed * 1. Redistributions of source code must retain the above copyright 9193326Sed * notice, this list of conditions and the following disclaimer. 10193326Sed * 2. Redistributions in binary form must reproduce the above copyright 11193326Sed * notice, this list of conditions and the following disclaimer in the 12198893Srdivacky * documentation and/or other materials provided with the distribution. 13193326Sed * 3. All advertising materials mentioning features or use of this software 14193326Sed * must display the following acknowledgement: 15198092Srdivacky * This product includes software developed by Martin Husemann 16234353Sdim * and Wolfgang Solfrank. 17208600Srdivacky * 4. Neither the name of the University nor the names of its contributors 18208600Srdivacky * may be used to endorse or promote products derived from this software 19218893Sdim * without specific prior written permission. 20234353Sdim * 21234353Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 22210299Sed * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23210299Sed * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24210299Sed * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25200583Srdivacky * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26200583Srdivacky * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27199990Srdivacky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28199990Srdivacky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29198893Srdivacky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30206084Srdivacky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31199482Srdivacky * $NetBSD: ext.h,v 1.6 2000/04/25 23:02:51 jdolecek Exp $ 32199482Srdivacky * $FreeBSD: head/sbin/fsck_msdosfs/ext.h 96707 2002-05-16 04:10:46Z trhodes $ 33200583Srdivacky */ 34200583Srdivacky 35200583Srdivacky#ifndef EXT_H 36200583Srdivacky#define EXT_H 37200583Srdivacky 38200583Srdivacky#include <sys/types.h> 39200583Srdivacky 40200583Srdivacky#include "dosfs.h" 41200583Srdivacky 42200583Srdivacky#define LOSTDIR "LOST.DIR" 43200583Srdivacky 44200583Srdivacky/* 45200583Srdivacky * Options: 46200583Srdivacky */ 47200583Srdivackyextern int alwaysno; /* assume "no" for all questions */ 48200583Srdivackyextern int alwaysyes; /* assume "yes" for all questions */ 49200583Srdivackyextern int preen; /* we are preening */ 50200583Srdivackyextern int rdonly; /* device is opened read only (supersedes above) */ 51205408Srdivacky 52205408Srdivackyextern char *fname; /* filesystem currently checked */ 53200583Srdivacky 54200583Srdivackyextern struct dosDirEntry *rootDir; 55200583Srdivacky 56239462Sdim/* 57218893Sdim * function declarations 58218893Sdim */ 59221345Sdimint ask(int, const char *, ...) __attribute__((__format__(__printf__,2,3))); 60221345Sdim 61243830Sdim/* 62243830Sdim * Check filesystem given as arg 63193326Sed */ 64234353Sdimint checkfilesys(const char *); 65234353Sdim 66234353Sdim/* 67234353Sdim * Return values of various functions 68239462Sdim */ 69239462Sdim#define FSOK 0 /* Check was OK */ 70239462Sdim#define FSBOOTMOD 1 /* Boot block was modified */ 71239462Sdim#define FSDIRMOD 2 /* Some directory was modified */ 72199482Srdivacky#define FSFATMOD 4 /* The FAT was modified */ 73207619Srdivacky#define FSERROR 8 /* Some unrecovered error remains */ 74199482Srdivacky#define FSFATAL 16 /* Some unrecoverable error occured */ 75207619Srdivacky#define FSDIRTY 32 /* File system is dirty */ 76207619Srdivacky#define FSFIXFAT 64 /* Fix filesystem FAT */ 77207619Srdivacky 78199482Srdivacky/* 79218893Sdim * read a boot block in a machine independend fashion and translate 80218893Sdim * it into our struct bootblock. 81243830Sdim */ 82243830Sdimint readboot(int, struct bootblock *); 83243830Sdim 84243830Sdim/* 85243830Sdim * Correct the FSInfo block. 86199482Srdivacky */ 87193326Sedint writefsinfo(int, struct bootblock *); 88193326Sed 89193326Sed/* 90193326Sed * Read one of the FAT copies and return a pointer to the new 91193326Sed * allocated array holding our description of it. 92193326Sed */ 93193326Sedint readfat(int, struct bootblock *, int, struct fatEntry **); 94193326Sed 95193326Sed/* 96193326Sed * Check two FAT copies for consistency and merge changes into the 97212904Sdim * first if neccessary. 98198092Srdivacky */ 99198092Srdivackyint comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, int); 100193326Sed 101194711Sed/* 102194711Sed * Check a FAT 103194711Sed */ 104223017Sdimint checkfat(struct bootblock *, struct fatEntry *); 105239462Sdim 106239462Sdim/* 107234353Sdim * Write back FAT entries 108234353Sdim */ 109234353Sdimint writefat(int, struct bootblock *, struct fatEntry *, int); 110234353Sdim 111234353Sdim/* 112239462Sdim * Read a directory 113201361Srdivacky */ 114201361Srdivackyint resetDosDirSection(struct bootblock *, struct fatEntry *); 115201361Srdivackyvoid finishDosDirSection(void); 116218893Sdimint handleDirTree(int, struct bootblock *, struct fatEntry *); 117239462Sdim 118218893Sdim/* 119226633Sdim * Cross-check routines run after everything is completely in memory 120226633Sdim */ 121226633Sdim/* 122226633Sdim * Check for lost cluster chains 123226633Sdim */ 124234353Sdimint checklost(int, struct bootblock *, struct fatEntry *); 125234353Sdim/* 126234353Sdim * Try to reconnect a lost cluster chain 127234353Sdim */ 128234353Sdimint reconnect(int, struct bootblock *, struct fatEntry *, cl_t); 129234353Sdimvoid finishlf(void); 130234353Sdim 131234353Sdim/* 132234353Sdim * Small helper functions 133234353Sdim */ 134234353Sdim/* 135234353Sdim * Return the type of a reserved cluster as text 136234353Sdim */ 137234353Sdimchar *rsrvdcltype(cl_t); 138234353Sdim 139234353Sdim/* 140234353Sdim * Clear a cluster chain in a FAT 141234353Sdim */ 142234353Sdimvoid clearchain(struct bootblock *, struct fatEntry *, cl_t); 143193326Sed 144#endif 145