/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank4* Copyright (c) 1995 Martin Husemann5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR16* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES17* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.18* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,19* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT20* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,21* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY22* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF24* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.25* $NetBSD: ext.h,v 1.6 2000/04/25 23:02:51 jdolecek Exp $26*/2728#ifndef EXT_H29#define EXT_H3031#include <sys/types.h>3233#include <stdbool.h>3435#include "dosfs.h"3637#define LOSTDIR "LOST.DIR"3839/*40* Options:41*/42extern int alwaysno; /* assume "no" for all questions */43extern int alwaysyes; /* assume "yes" for all questions */44extern int preen; /* we are preening */45extern int rdonly; /* device is opened read only (supersedes above) */46extern int skipclean; /* skip clean file systems if preening */47extern int allow_mmap; /* allow the use of mmap() */4849/*50* function declarations51*/52int ask(int, const char *, ...) __printflike(2, 3);5354/*55* Check the dirty flag. If the file system is clean, then return 1.56* Otherwise, return 0 (this includes the case of FAT12 file systems --57* they have no dirty flag, so they must be assumed to be unclean).58*/59int checkdirty(int, struct bootblock *);6061/*62* Check file system given as arg63*/64int checkfilesys(const char *);6566/*67* Return values of various functions68*/69#define FSOK 0 /* Check was OK */70#define FSBOOTMOD 1 /* Boot block was modified */71#define FSDIRMOD 2 /* Some directory was modified */72#define FSFATMOD 4 /* The FAT was modified */73#define FSERROR 8 /* Some unrecovered error remains */74#define FSFATAL 16 /* Some unrecoverable error occurred */75#define FSDIRTY 32 /* File system is dirty */7677/*78* read a boot block in a machine independent fashion and translate79* it into our struct bootblock.80*/81int readboot(int, struct bootblock *);8283/*84* Correct the FSInfo block.85*/86int writefsinfo(int, struct bootblock *);8788/* Opaque type */89struct fat_descriptor;9091int cleardirty(struct fat_descriptor *);9293void fat_clear_cl_head(struct fat_descriptor *, cl_t);94bool fat_is_cl_head(struct fat_descriptor *, cl_t);9596cl_t fat_get_cl_next(struct fat_descriptor *, cl_t);9798int fat_set_cl_next(struct fat_descriptor *, cl_t, cl_t);99100cl_t fat_allocate_cluster(struct fat_descriptor *fat);101102struct bootblock* fat_get_boot(struct fat_descriptor *);103int fat_get_fd(struct fat_descriptor *);104bool fat_is_valid_cl(struct fat_descriptor *, cl_t);105106/*107* Read the FAT 0 and return a pointer to the newly allocated108* descriptor of it.109*/110int readfat(int, struct bootblock *, struct fat_descriptor **);111112/*113* Write back FAT entries114*/115int writefat(struct fat_descriptor *);116117/*118* Read a directory119*/120int resetDosDirSection(struct fat_descriptor *);121void finishDosDirSection(void);122int handleDirTree(struct fat_descriptor *);123124/*125* Cross-check routines run after everything is completely in memory126*/127int checkchain(struct fat_descriptor *, cl_t, size_t *);128129/*130* Check for lost cluster chains131*/132int checklost(struct fat_descriptor *);133/*134* Try to reconnect a lost cluster chain135*/136int reconnect(struct fat_descriptor *, cl_t, size_t);137void finishlf(void);138139/*140* Small helper functions141*/142/*143* Return the type of a reserved cluster as text144*/145const char *rsrvdcltype(cl_t);146147/*148* Clear a cluster chain in a FAT149*/150void clearchain(struct fat_descriptor *, cl_t);151152#endif153154155