ext.h revision 125486
179455Sobrien/* 279455Sobrien * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank 379455Sobrien * Copyright (c) 1995 Martin Husemann 479455Sobrien * 579455Sobrien * Redistribution and use in source and binary forms, with or without 679455Sobrien * modification, are permitted provided that the following conditions 779455Sobrien * are met: 879455Sobrien * 1. Redistributions of source code must retain the above copyright 979455Sobrien * notice, this list of conditions and the following disclaimer. 1079455Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1179455Sobrien * notice, this list of conditions and the following disclaimer in the 1279455Sobrien * documentation and/or other materials provided with the distribution. 1379455Sobrien * 3. All advertising materials mentioning features or use of this software 1479455Sobrien * must display the following acknowledgement: 1579455Sobrien * This product includes software developed by Martin Husemann 1679455Sobrien * and Wolfgang Solfrank. 1779455Sobrien * 4. Neither the name of the University nor the names of its contributors 1879455Sobrien * may be used to endorse or promote products derived from this software 1979455Sobrien * without specific prior written permission. 2079455Sobrien * 2179455Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 2279455Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2379455Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2479455Sobrien * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 2579455Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2679455Sobrien * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2779455Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2879455Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2979455Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3079455Sobrien * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3179455Sobrien * $NetBSD: ext.h,v 1.6 2000/04/25 23:02:51 jdolecek Exp $ 3279455Sobrien * $FreeBSD: head/sbin/fsck_msdosfs/ext.h 125486 2004-02-05 15:47:46Z bde $ 3379455Sobrien */ 3479455Sobrien 3579455Sobrien#ifndef EXT_H 3679455Sobrien#define EXT_H 3779455Sobrien 3879455Sobrien#include <sys/types.h> 3979455Sobrien 4079455Sobrien#include "dosfs.h" 4179455Sobrien 4279455Sobrien#define LOSTDIR "LOST.DIR" 4379455Sobrien 4479455Sobrien/* 4579455Sobrien * Options: 4679455Sobrien */ 4779455Sobrienextern int alwaysno; /* assume "no" for all questions */ 4879455Sobrienextern int alwaysyes; /* assume "yes" for all questions */ 4979455Sobrienextern int preen; /* we are preening */ 5079455Sobrienextern int rdonly; /* device is opened read only (supersedes above) */ 51125486Sbdeextern int skipclean; /* skip clean file systems if preening */ 5279455Sobrien 5379455Sobrienextern struct dosDirEntry *rootDir; 5479455Sobrien 5579455Sobrien/* 5679455Sobrien * function declarations 5779455Sobrien */ 5892839Simpint ask(int, const char *, ...) __attribute__((__format__(__printf__,2,3))); 5979455Sobrien 6079455Sobrien/* 61123883Sbde * Check the dirty flag. If the file system is clean, then return 1. 62123883Sbde * Otherwise, return 0 (this includes the case of FAT12 file systems -- 63123883Sbde * they have no dirty flag, so they must be assumed to be unclean). 64123883Sbde */ 65123883Sbdeint checkdirty(int, struct bootblock *); 66123883Sbde 67123883Sbde/* 68102231Strhodes * Check file system given as arg 6979455Sobrien */ 7092839Simpint checkfilesys(const char *); 7179455Sobrien 7279455Sobrien/* 7379455Sobrien * Return values of various functions 7479455Sobrien */ 7579455Sobrien#define FSOK 0 /* Check was OK */ 7679455Sobrien#define FSBOOTMOD 1 /* Boot block was modified */ 7779455Sobrien#define FSDIRMOD 2 /* Some directory was modified */ 7879455Sobrien#define FSFATMOD 4 /* The FAT was modified */ 7979455Sobrien#define FSERROR 8 /* Some unrecovered error remains */ 8079455Sobrien#define FSFATAL 16 /* Some unrecoverable error occured */ 8179455Sobrien#define FSDIRTY 32 /* File system is dirty */ 82102231Strhodes#define FSFIXFAT 64 /* Fix file system FAT */ 8379455Sobrien 8479455Sobrien/* 8579455Sobrien * read a boot block in a machine independend fashion and translate 8679455Sobrien * it into our struct bootblock. 8779455Sobrien */ 8892839Simpint readboot(int, struct bootblock *); 8979455Sobrien 9079455Sobrien/* 9179455Sobrien * Correct the FSInfo block. 9279455Sobrien */ 9392839Simpint writefsinfo(int, struct bootblock *); 9479455Sobrien 9579455Sobrien/* 9679455Sobrien * Read one of the FAT copies and return a pointer to the new 9779455Sobrien * allocated array holding our description of it. 9879455Sobrien */ 9992839Simpint readfat(int, struct bootblock *, int, struct fatEntry **); 10079455Sobrien 10179455Sobrien/* 10279455Sobrien * Check two FAT copies for consistency and merge changes into the 10379455Sobrien * first if neccessary. 10479455Sobrien */ 10592839Simpint comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, int); 10679455Sobrien 10779455Sobrien/* 10879455Sobrien * Check a FAT 10979455Sobrien */ 11092839Simpint checkfat(struct bootblock *, struct fatEntry *); 11179455Sobrien 11279455Sobrien/* 11379455Sobrien * Write back FAT entries 11479455Sobrien */ 11592839Simpint writefat(int, struct bootblock *, struct fatEntry *, int); 11679455Sobrien 11779455Sobrien/* 11879455Sobrien * Read a directory 11979455Sobrien */ 12092839Simpint resetDosDirSection(struct bootblock *, struct fatEntry *); 12192839Simpvoid finishDosDirSection(void); 12292839Simpint handleDirTree(int, struct bootblock *, struct fatEntry *); 12379455Sobrien 12479455Sobrien/* 12579455Sobrien * Cross-check routines run after everything is completely in memory 12679455Sobrien */ 12779455Sobrien/* 12879455Sobrien * Check for lost cluster chains 12979455Sobrien */ 13092839Simpint checklost(int, struct bootblock *, struct fatEntry *); 13179455Sobrien/* 13279455Sobrien * Try to reconnect a lost cluster chain 13379455Sobrien */ 13492839Simpint reconnect(int, struct bootblock *, struct fatEntry *, cl_t); 13592839Simpvoid finishlf(void); 13679455Sobrien 13779455Sobrien/* 13879455Sobrien * Small helper functions 13979455Sobrien */ 14079455Sobrien/* 14179455Sobrien * Return the type of a reserved cluster as text 14279455Sobrien */ 14392839Simpchar *rsrvdcltype(cl_t); 14479455Sobrien 14579455Sobrien/* 14679455Sobrien * Clear a cluster chain in a FAT 14779455Sobrien */ 14892839Simpvoid clearchain(struct bootblock *, struct fatEntry *, cl_t); 14979455Sobrien 15079455Sobrien#endif 151