Home | History | Annotate | Download | only in fsck_msdos
      1 /*
      2  * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
      3  * Copyright (c) 1995 Martin Husemann
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  * 3. All advertising materials mentioning features or use of this software
     14  *    must display the following acknowledgement:
     15  *	This product includes software developed by Martin Husemann
     16  *	and Wolfgang Solfrank.
     17  * 4. Neither the name of the University nor the names of its contributors
     18  *    may be used to endorse or promote products derived from this software
     19  *    without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  *	$NetBSD: ext.h,v 1.6 2000/04/25 23:02:51 jdolecek Exp $
     32  * $FreeBSD: src/sbin/fsck_msdosfs/ext.h,v 1.10.20.1 2009/04/15 03:14:26 kensmith Exp $
     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 extern int skipclean;	/* skip clean file systems if preening */
     52 
     53 extern struct dosDirEntry *rootDir;
     54 
     55 /*
     56  * function declarations
     57  */
     58 int ask(int, const char *, ...);
     59 
     60 /*
     61  * Check the dirty flag.  If the file system is clean, then return 1.
     62  * Otherwise, return 0 (this includes the case of FAT12 file systems --
     63  * they have no dirty flag, so they must be assumed to be unclean).
     64  */
     65 int checkdirty(int, struct bootblock *);
     66 
     67 /*
     68  * Check file system given as arg
     69  */
     70 int checkfilesys(const char *);
     71 
     72 /*
     73  * Return values of various functions
     74  */
     75 #define	FSOK		0		/* Check was OK */
     76 #define	FSBOOTMOD	1		/* Boot block was modified */
     77 #define	FSDIRMOD	2		/* Some directory was modified */
     78 #define	FSFATMOD	4		/* The FAT was modified */
     79 #define	FSERROR		8		/* Some unrecovered error remains */
     80 #define	FSFATAL		16		/* Some unrecoverable error occured */
     81 #define FSDIRTY		32		/* File system is dirty */
     82 #define FSFIXFAT	64		/* Fix file system FAT */
     83 
     84 /*
     85  * read a boot block in a machine independend fashion and translate
     86  * it into our struct bootblock.
     87  */
     88 int readboot(int, struct bootblock *);
     89 
     90 /*
     91  * Correct the FSInfo block.
     92  */
     93 int writefsinfo(int, struct bootblock *);
     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(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(struct bootblock *, struct fatEntry *, struct fatEntry *, int);
    106 
    107 /*
    108  * Check a FAT
    109  */
    110 int checkfat(struct bootblock *, struct fatEntry *);
    111 
    112 /*
    113  * Write back FAT entries
    114  */
    115 int writefat(int, struct bootblock *, struct fatEntry *, int);
    116 
    117 /*
    118  * Read a directory
    119  */
    120 int resetDosDirSection(struct bootblock *, struct fatEntry *);
    121 void finishDosDirSection(void);
    122 int handleDirTree(int, struct bootblock *, struct fatEntry *);
    123 
    124 /*
    125  * Cross-check routines run after everything is completely in memory
    126  */
    127 /*
    128  * Check for lost cluster chains
    129  */
    130 int checklost(int, struct bootblock *, struct fatEntry *);
    131 /*
    132  * Try to reconnect a lost cluster chain
    133  */
    134 int reconnect(int, struct bootblock *, struct fatEntry *, cl_t);
    135 void finishlf(void);
    136 
    137 /*
    138  * Small helper functions
    139  */
    140 /*
    141  * Return the type of a reserved cluster as text
    142  */
    143 char *rsrvdcltype(cl_t);
    144 
    145 /*
    146  * Clear a cluster chain in a FAT
    147  */
    148 void clearchain(struct bootblock *, struct fatEntry *, cl_t);
    149 
    150 #endif
    151