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