ext.h revision 79455
1327Sjkh/*
2327Sjkh * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
3327Sjkh * Copyright (c) 1995 Martin Husemann
4327Sjkh *
5327Sjkh * Redistribution and use in source and binary forms, with or without
6327Sjkh * modification, are permitted provided that the following conditions
7327Sjkh * are met:
8327Sjkh * 1. Redistributions of source code must retain the above copyright
9327Sjkh *    notice, this list of conditions and the following disclaimer.
10327Sjkh * 2. Redistributions in binary form must reproduce the above copyright
11327Sjkh *    notice, this list of conditions and the following disclaimer in the
12327Sjkh *    documentation and/or other materials provided with the distribution.
13327Sjkh * 3. All advertising materials mentioning features or use of this software
14327Sjkh *    must display the following acknowledgement:
15327Sjkh *	This product includes software developed by Martin Husemann
16327Sjkh *	and Wolfgang Solfrank.
17327Sjkh * 4. Neither the name of the University nor the names of its contributors
1831997Shoek *    may be used to endorse or promote products derived from this software
19327Sjkh *    without specific prior written permission.
20327Sjkh *
21327Sjkh * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
2230221Scharnier * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23327Sjkh * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24327Sjkh * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25327Sjkh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2655567Sphantom * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2755567Sphantom * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2855567Sphantom * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2955567Sphantom * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30327Sjkh * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3162775Ssobomax *	$NetBSD: ext.h,v 1.6 2000/04/25 23:02:51 jdolecek Exp $
3255567Sphantom * $FreeBSD: head/sbin/fsck_msdosfs/ext.h 79455 2001-07-09 10:35:18Z obrien $
33327Sjkh */
34327Sjkh
35411Sjkh#ifndef EXT_H
36379Sjkh#define EXT_H
3711780Sjkh
38392Sjkh#include <sys/types.h>
39327Sjkh
4030221Scharnier#include "dosfs.h"
4130221Scharnier
42327Sjkh#define	LOSTDIR	"LOST.DIR"
43327Sjkh
44327Sjkh/*
45327Sjkh * Options:
46327Sjkh */
4756001Sdanextern int alwaysno;	/* assume "no" for all questions */
48327Sjkhextern int alwaysyes;	/* assume "yes" for all questions */
49327Sjkhextern int preen;	/* we are preening */
5046105Sjkhextern int rdonly;	/* device is opened read only (supersedes above) */
5146105Sjkh
5246105Sjkhextern char *fname;	/* filesystem currently checked */
5346105Sjkh
5446105Sjkhextern struct dosDirEntry *rootDir;
55327Sjkh
56327Sjkh/*
57327Sjkh * function declarations
58327Sjkh */
59327Sjkhint ask __P((int, const char *, ...)) __attribute__((__format__(__printf__,2,3)));
60327Sjkh
61327Sjkh/*
62327Sjkh * Check filesystem given as arg
63327Sjkh */
644996Sjkhint checkfilesys __P((const char *));
65327Sjkh
66327Sjkh/*
67327Sjkh * Return values of various functions
68327Sjkh */
69327Sjkh#define	FSOK		0		/* Check was OK */
70327Sjkh#define	FSBOOTMOD	1		/* Boot block was modified */
71327Sjkh#define	FSDIRMOD	2		/* Some directory was modified */
72327Sjkh#define	FSFATMOD	4		/* The FAT was modified */
73327Sjkh#define	FSERROR		8		/* Some unrecovered error remains */
74327Sjkh#define	FSFATAL		16		/* Some unrecoverable error occured */
75327Sjkh#define FSDIRTY		32		/* File system is dirty */
76327Sjkh#define FSFIXFAT	64		/* Fix file system FAT */
77327Sjkh
78327Sjkh/*
79327Sjkh * read a boot block in a machine independend fashion and translate
80327Sjkh * it into our struct bootblock.
81327Sjkh */
82327Sjkhint readboot __P((int, struct bootblock *));
834996Sjkh
844996Sjkh/*
854996Sjkh * Correct the FSInfo block.
864996Sjkh */
87327Sjkhint writefsinfo __P((int, struct bootblock *));
88327Sjkh
89327Sjkh/*
90327Sjkh * Read one of the FAT copies and return a pointer to the new
91327Sjkh * allocated array holding our description of it.
92327Sjkh */
93327Sjkhint readfat __P((int, struct bootblock *, int, struct fatEntry **));
94327Sjkh
95327Sjkh/*
96327Sjkh * Check two FAT copies for consistency and merge changes into the
97327Sjkh * first if neccessary.
98327Sjkh */
99327Sjkhint comparefat __P((struct bootblock *, struct fatEntry *, struct fatEntry *, int));
100327Sjkh
101327Sjkh/*
102327Sjkh * Check a FAT
1034996Sjkh */
1044996Sjkhint checkfat __P((struct bootblock *, struct fatEntry *));
1054996Sjkh
1064996Sjkh/*
107411Sjkh * Write back FAT entries
108411Sjkh */
109411Sjkhint writefat __P((int, struct bootblock *, struct fatEntry *, int));
110411Sjkh
1114996Sjkh/*
1124996Sjkh * Read a directory
1134996Sjkh */
1144996Sjkhint resetDosDirSection __P((struct bootblock *, struct fatEntry *));
11562775Ssobomaxvoid finishDosDirSection __P((void));
11662775Ssobomaxint handleDirTree __P((int, struct bootblock *, struct fatEntry *));
11762775Ssobomax
11862775Ssobomax/*
119379Sjkh * Cross-check routines run after everything is completely in memory
120379Sjkh */
121379Sjkh/*
122379Sjkh * Check for lost cluster chains
123411Sjkh */
124411Sjkhint checklost __P((int, struct bootblock *, struct fatEntry *));
125411Sjkh/*
126411Sjkh * Try to reconnect a lost cluster chain
127383Sjkh */
12811780Sjkhint reconnect __P((int, struct bootblock *, struct fatEntry *, cl_t));
129383Sjkhvoid finishlf __P((void));
130383Sjkh
131392Sjkh/*
132392Sjkh * Small helper functions
133392Sjkh */
134392Sjkh/*
135327Sjkh * Return the type of a reserved cluster as text
136327Sjkh */
137327Sjkhchar *rsrvdcltype __P((cl_t));
13830221Scharnier
139327Sjkh/*
140327Sjkh * Clear a cluster chain in a FAT
14146105Sjkh */
142327Sjkhvoid clearchain __P((struct bootblock *, struct fatEntry *, cl_t));
1438857Srgrimes
144327Sjkh#endif
145327Sjkh