ext.h revision 92839
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 92839 2002-03-20 22:57:10Z imp $ 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) */ 5179455Sobrien 5279455Sobrienextern char *fname; /* filesystem currently checked */ 5379455Sobrien 5479455Sobrienextern struct dosDirEntry *rootDir; 5579455Sobrien 5679455Sobrien/* 5779455Sobrien * function declarations 5879455Sobrien */ 5992839Simpint ask(int, const char *, ...) __attribute__((__format__(__printf__,2,3))); 6079455Sobrien 6179455Sobrien/* 6279455Sobrien * Check filesystem given as arg 6379455Sobrien */ 6492839Simpint checkfilesys(const char *); 6579455Sobrien 6679455Sobrien/* 6779455Sobrien * Return values of various functions 6879455Sobrien */ 6979455Sobrien#define FSOK 0 /* Check was OK */ 7079455Sobrien#define FSBOOTMOD 1 /* Boot block was modified */ 7179455Sobrien#define FSDIRMOD 2 /* Some directory was modified */ 7279455Sobrien#define FSFATMOD 4 /* The FAT was modified */ 7379455Sobrien#define FSERROR 8 /* Some unrecovered error remains */ 7479455Sobrien#define FSFATAL 16 /* Some unrecoverable error occured */ 7579455Sobrien#define FSDIRTY 32 /* File system is dirty */ 7679455Sobrien#define FSFIXFAT 64 /* Fix file system FAT */ 7779455Sobrien 7879455Sobrien/* 7979455Sobrien * read a boot block in a machine independend fashion and translate 8079455Sobrien * it into our struct bootblock. 8179455Sobrien */ 8292839Simpint readboot(int, struct bootblock *); 8379455Sobrien 8479455Sobrien/* 8579455Sobrien * Correct the FSInfo block. 8679455Sobrien */ 8792839Simpint writefsinfo(int, struct bootblock *); 8879455Sobrien 8979455Sobrien/* 9079455Sobrien * Read one of the FAT copies and return a pointer to the new 9179455Sobrien * allocated array holding our description of it. 9279455Sobrien */ 9392839Simpint readfat(int, struct bootblock *, int, struct fatEntry **); 9479455Sobrien 9579455Sobrien/* 9679455Sobrien * Check two FAT copies for consistency and merge changes into the 9779455Sobrien * first if neccessary. 9879455Sobrien */ 9992839Simpint comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, int); 10079455Sobrien 10179455Sobrien/* 10279455Sobrien * Check a FAT 10379455Sobrien */ 10492839Simpint checkfat(struct bootblock *, struct fatEntry *); 10579455Sobrien 10679455Sobrien/* 10779455Sobrien * Write back FAT entries 10879455Sobrien */ 10992839Simpint writefat(int, struct bootblock *, struct fatEntry *, int); 11079455Sobrien 11179455Sobrien/* 11279455Sobrien * Read a directory 11379455Sobrien */ 11492839Simpint resetDosDirSection(struct bootblock *, struct fatEntry *); 11592839Simpvoid finishDosDirSection(void); 11692839Simpint handleDirTree(int, struct bootblock *, struct fatEntry *); 11779455Sobrien 11879455Sobrien/* 11979455Sobrien * Cross-check routines run after everything is completely in memory 12079455Sobrien */ 12179455Sobrien/* 12279455Sobrien * Check for lost cluster chains 12379455Sobrien */ 12492839Simpint checklost(int, struct bootblock *, struct fatEntry *); 12579455Sobrien/* 12679455Sobrien * Try to reconnect a lost cluster chain 12779455Sobrien */ 12892839Simpint reconnect(int, struct bootblock *, struct fatEntry *, cl_t); 12992839Simpvoid finishlf(void); 13079455Sobrien 13179455Sobrien/* 13279455Sobrien * Small helper functions 13379455Sobrien */ 13479455Sobrien/* 13579455Sobrien * Return the type of a reserved cluster as text 13679455Sobrien */ 13792839Simpchar *rsrvdcltype(cl_t); 13879455Sobrien 13979455Sobrien/* 14079455Sobrien * Clear a cluster chain in a FAT 14179455Sobrien */ 14292839Simpvoid clearchain(struct bootblock *, struct fatEntry *, cl_t); 14379455Sobrien 14479455Sobrien#endif 145