Home | History | Annotate | Line # | Download | only in fsck_msdos
ext.h revision 1.13
      1  1.13     lukem /*	$NetBSD: ext.h,v 1.13 2009/04/11 07:14:50 lukem Exp $	*/
      2   1.2        ws 
      3   1.1        ws /*
      4   1.5        ws  * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
      5   1.1        ws  * Copyright (c) 1995 Martin Husemann
      6   1.1        ws  *
      7   1.1        ws  * Redistribution and use in source and binary forms, with or without
      8   1.1        ws  * modification, are permitted provided that the following conditions
      9   1.1        ws  * are met:
     10   1.1        ws  * 1. Redistributions of source code must retain the above copyright
     11   1.1        ws  *    notice, this list of conditions and the following disclaimer.
     12   1.1        ws  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1        ws  *    notice, this list of conditions and the following disclaimer in the
     14   1.1        ws  *    documentation and/or other materials provided with the distribution.
     15   1.1        ws  *
     16   1.1        ws  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
     17   1.1        ws  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18   1.1        ws  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19   1.1        ws  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     20   1.1        ws  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21   1.1        ws  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22   1.1        ws  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23   1.1        ws  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24   1.1        ws  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25   1.1        ws  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26   1.1        ws  */
     27   1.1        ws 
     28   1.1        ws #ifndef EXT_H
     29   1.1        ws #define EXT_H
     30   1.1        ws 
     31   1.1        ws #include <sys/types.h>
     32   1.1        ws 
     33   1.1        ws #include "dosfs.h"
     34   1.1        ws 
     35   1.1        ws #define	LOSTDIR	"LOST.DIR"
     36   1.1        ws 
     37   1.1        ws /*
     38   1.1        ws  * Options:
     39   1.1        ws  */
     40   1.1        ws extern int alwaysno;	/* assume "no" for all questions */
     41   1.1        ws extern int alwaysyes;	/* assume "yes" for all questions */
     42   1.1        ws extern int preen;	/* we are preening */
     43   1.1        ws extern int rdonly;	/* device is opened read only (supersedes above) */
     44   1.1        ws 
     45   1.1        ws extern char *fname;	/* filesystem currently checked */
     46   1.1        ws 
     47   1.3        ws extern struct dosDirEntry *rootDir;
     48   1.3        ws 
     49   1.5        ws /*
     50   1.1        ws  * function declarations
     51   1.1        ws  */
     52  1.11   xtraeme int ask(int, const char *, ...) __attribute__((__format__(__printf__,2,3)));
     53   1.1        ws 
     54   1.1        ws /*
     55   1.1        ws  * Check filesystem given as arg
     56   1.1        ws  */
     57  1.11   xtraeme int checkfilesys(const char *);
     58   1.1        ws 
     59   1.1        ws /*
     60   1.1        ws  * Return values of various functions
     61   1.1        ws  */
     62   1.1        ws #define	FSOK		0		/* Check was OK */
     63   1.5        ws #define	FSBOOTMOD	1		/* Boot block was modified */
     64   1.5        ws #define	FSDIRMOD	2		/* Some directory was modified */
     65   1.5        ws #define	FSFATMOD	4		/* The FAT was modified */
     66   1.5        ws #define	FSERROR		8		/* Some unrecovered error remains */
     67  1.10       wiz #define	FSFATAL		16		/* Some unrecoverable error occurred */
     68   1.6  jdolecek #define FSDIRTY		32		/* File system is dirty */
     69   1.6  jdolecek #define FSFIXFAT	64		/* Fix file system FAT */
     70   1.1        ws 
     71   1.1        ws /*
     72   1.1        ws  * read a boot block in a machine independend fashion and translate
     73   1.1        ws  * it into our struct bootblock.
     74   1.1        ws  */
     75  1.11   xtraeme int readboot(int, struct bootblock *);
     76   1.1        ws 
     77   1.5        ws /*
     78   1.5        ws  * Correct the FSInfo block.
     79   1.5        ws  */
     80  1.11   xtraeme int writefsinfo(int, struct bootblock *);
     81   1.1        ws 
     82   1.1        ws /*
     83   1.1        ws  * Read one of the FAT copies and return a pointer to the new
     84   1.5        ws  * allocated array holding our description of it.
     85   1.1        ws  */
     86  1.13     lukem int readfat(int, struct bootblock *, u_int, struct fatEntry **);
     87   1.1        ws 
     88   1.1        ws /*
     89   1.1        ws  * Check two FAT copies for consistency and merge changes into the
     90   1.9       wiz  * first if necessary.
     91   1.1        ws  */
     92  1.13     lukem int comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, u_int);
     93   1.1        ws 
     94   1.1        ws /*
     95   1.1        ws  * Check a FAT
     96   1.1        ws  */
     97  1.11   xtraeme int checkfat(struct bootblock *, struct fatEntry *);
     98   1.1        ws 
     99   1.1        ws /*
    100   1.1        ws  * Write back FAT entries
    101   1.1        ws  */
    102  1.11   xtraeme int writefat(int, struct bootblock *, struct fatEntry *, int);
    103   1.1        ws 
    104   1.1        ws /*
    105   1.1        ws  * Read a directory
    106   1.1        ws  */
    107  1.11   xtraeme int resetDosDirSection(struct bootblock *, struct fatEntry *);
    108  1.11   xtraeme void finishDosDirSection(void);
    109  1.11   xtraeme int handleDirTree(int, struct bootblock *, struct fatEntry *);
    110   1.1        ws 
    111   1.1        ws /*
    112   1.1        ws  * Cross-check routines run after everything is completely in memory
    113   1.1        ws  */
    114   1.1        ws /*
    115   1.1        ws  * Check for lost cluster chains
    116   1.1        ws  */
    117  1.11   xtraeme int checklost(int, struct bootblock *, struct fatEntry *);
    118   1.1        ws /*
    119   1.1        ws  * Try to reconnect a lost cluster chain
    120   1.1        ws  */
    121  1.11   xtraeme int reconnect(int, struct bootblock *, struct fatEntry *, cl_t);
    122  1.11   xtraeme void finishlf(void);
    123   1.5        ws 
    124   1.1        ws /*
    125   1.1        ws  * Small helper functions
    126   1.1        ws  */
    127   1.1        ws /*
    128   1.1        ws  * Return the type of a reserved cluster as text
    129   1.1        ws  */
    130  1.11   xtraeme const char *rsrvdcltype(cl_t);
    131   1.1        ws 
    132   1.1        ws /*
    133   1.1        ws  * Clear a cluster chain in a FAT
    134   1.1        ws  */
    135  1.11   xtraeme void clearchain(struct bootblock *, struct fatEntry *, cl_t);
    136   1.1        ws 
    137   1.1        ws #endif
    138