1*37fa5548Sgutteridge /* $NetBSD: ext.h,v 1.14 2023/09/24 20:41:52 gutteridge Exp $ */ 2a89a16b5Sws 36ae4c91aSws /* 4d445160eSws * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank 56ae4c91aSws * Copyright (c) 1995 Martin Husemann 66ae4c91aSws * 76ae4c91aSws * Redistribution and use in source and binary forms, with or without 86ae4c91aSws * modification, are permitted provided that the following conditions 96ae4c91aSws * are met: 106ae4c91aSws * 1. Redistributions of source code must retain the above copyright 116ae4c91aSws * notice, this list of conditions and the following disclaimer. 126ae4c91aSws * 2. Redistributions in binary form must reproduce the above copyright 136ae4c91aSws * notice, this list of conditions and the following disclaimer in the 146ae4c91aSws * documentation and/or other materials provided with the distribution. 156ae4c91aSws * 166ae4c91aSws * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 176ae4c91aSws * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 186ae4c91aSws * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 196ae4c91aSws * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 206ae4c91aSws * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 216ae4c91aSws * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 226ae4c91aSws * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 236ae4c91aSws * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 246ae4c91aSws * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 256ae4c91aSws * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 266ae4c91aSws */ 276ae4c91aSws 286ae4c91aSws #ifndef EXT_H 296ae4c91aSws #define EXT_H 306ae4c91aSws 316ae4c91aSws #include <sys/types.h> 326ae4c91aSws 336ae4c91aSws #include "dosfs.h" 346ae4c91aSws 356ae4c91aSws #define LOSTDIR "LOST.DIR" 366ae4c91aSws 376ae4c91aSws /* 386ae4c91aSws * Options: 396ae4c91aSws */ 406ae4c91aSws extern int alwaysno; /* assume "no" for all questions */ 416ae4c91aSws extern int alwaysyes; /* assume "yes" for all questions */ 426ae4c91aSws extern int preen; /* we are preening */ 436ae4c91aSws extern int rdonly; /* device is opened read only (supersedes above) */ 446ae4c91aSws 456ae4c91aSws extern char *fname; /* filesystem currently checked */ 466ae4c91aSws 4725e3d62eSws extern struct dosDirEntry *rootDir; 4825e3d62eSws 496ae4c91aSws /* 506ae4c91aSws * function declarations 516ae4c91aSws */ 5265e67723Sxtraeme int ask(int, const char *, ...) __attribute__((__format__(__printf__,2,3))); 536ae4c91aSws 546ae4c91aSws /* 556ae4c91aSws * Check filesystem given as arg 566ae4c91aSws */ 5765e67723Sxtraeme int checkfilesys(const char *); 586ae4c91aSws 596ae4c91aSws /* 606ae4c91aSws * Return values of various functions 616ae4c91aSws */ 626ae4c91aSws #define FSOK 0 /* Check was OK */ 63d445160eSws #define FSBOOTMOD 1 /* Boot block was modified */ 64d445160eSws #define FSDIRMOD 2 /* Some directory was modified */ 65d445160eSws #define FSFATMOD 4 /* The FAT was modified */ 66d445160eSws #define FSERROR 8 /* Some unrecovered error remains */ 67456dff6cSwiz #define FSFATAL 16 /* Some unrecoverable error occurred */ 684ab49897Sjdolecek #define FSDIRTY 32 /* File system is dirty */ 694ab49897Sjdolecek #define FSFIXFAT 64 /* Fix file system FAT */ 706ae4c91aSws 716ae4c91aSws /* 72*37fa5548Sgutteridge * Read a boot block in a machine independent fashion and translate 736ae4c91aSws * it into our struct bootblock. 746ae4c91aSws */ 7565e67723Sxtraeme int readboot(int, struct bootblock *); 766ae4c91aSws 77d445160eSws /* 78d445160eSws * Correct the FSInfo block. 79d445160eSws */ 8065e67723Sxtraeme int writefsinfo(int, struct bootblock *); 816ae4c91aSws 826ae4c91aSws /* 836ae4c91aSws * Read one of the FAT copies and return a pointer to the new 846ae4c91aSws * allocated array holding our description of it. 856ae4c91aSws */ 86a2b5923eSlukem int readfat(int, struct bootblock *, u_int, struct fatEntry **); 876ae4c91aSws 886ae4c91aSws /* 896ae4c91aSws * Check two FAT copies for consistency and merge changes into the 9030b2bf87Swiz * first if necessary. 916ae4c91aSws */ 92a2b5923eSlukem int comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, u_int); 936ae4c91aSws 946ae4c91aSws /* 956ae4c91aSws * Check a FAT 966ae4c91aSws */ 9765e67723Sxtraeme int checkfat(struct bootblock *, struct fatEntry *); 986ae4c91aSws 996ae4c91aSws /* 1006ae4c91aSws * Write back FAT entries 1016ae4c91aSws */ 10265e67723Sxtraeme int writefat(int, struct bootblock *, struct fatEntry *, int); 1036ae4c91aSws 1046ae4c91aSws /* 1056ae4c91aSws * Read a directory 1066ae4c91aSws */ 10765e67723Sxtraeme int resetDosDirSection(struct bootblock *, struct fatEntry *); 10865e67723Sxtraeme void finishDosDirSection(void); 10965e67723Sxtraeme int handleDirTree(int, struct bootblock *, struct fatEntry *); 1106ae4c91aSws 1116ae4c91aSws /* 1126ae4c91aSws * Cross-check routines run after everything is completely in memory 1136ae4c91aSws */ 1146ae4c91aSws /* 1156ae4c91aSws * Check for lost cluster chains 1166ae4c91aSws */ 11765e67723Sxtraeme int checklost(int, struct bootblock *, struct fatEntry *); 1186ae4c91aSws /* 1196ae4c91aSws * Try to reconnect a lost cluster chain 1206ae4c91aSws */ 12165e67723Sxtraeme int reconnect(int, struct bootblock *, struct fatEntry *, cl_t); 12265e67723Sxtraeme void finishlf(void); 1236ae4c91aSws 1246ae4c91aSws /* 1256ae4c91aSws * Small helper functions 1266ae4c91aSws */ 1276ae4c91aSws /* 1286ae4c91aSws * Return the type of a reserved cluster as text 1296ae4c91aSws */ 13065e67723Sxtraeme const char *rsrvdcltype(cl_t); 1316ae4c91aSws 1326ae4c91aSws /* 1336ae4c91aSws * Clear a cluster chain in a FAT 1346ae4c91aSws */ 13565e67723Sxtraeme void clearchain(struct bootblock *, struct fatEntry *, cl_t); 1366ae4c91aSws 1376ae4c91aSws #endif 138