2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
5 * Copyright (c) 1995 Martin Husemann
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $NetBSD: ext.h,v 1.6 2000/04/25 23:02:51 jdolecek Exp $
33 #include <sys/types.h>
39 #define LOSTDIR "LOST.DIR"
44 extern int alwaysno
; /* assume "no" for all questions */
45 extern int alwaysyes
; /* assume "yes" for all questions */
46 extern int preen
; /* we are preening */
47 extern int rdonly
; /* device is opened read only (supersedes above) */
48 extern int allow_mmap
; /* allow the use of mmap() */
51 * function declarations
53 int ask(int, const char *, ...) __printflike(2, 3);
56 * Check file system given as arg
58 int checkfilesys(const char *);
61 * Return values of various functions
63 #define FSOK 0 /* Check was OK */
64 #define FSBOOTMOD 1 /* Boot block was modified */
65 #define FSDIRMOD 2 /* Some directory was modified */
66 #define FSFATMOD 4 /* The FAT was modified */
67 #define FSERROR 8 /* Some unrecovered error remains */
68 #define FSFATAL 16 /* Some unrecoverable error occurred */
69 #define FSDIRTY 32 /* File system is dirty */
72 * read a boot block in a machine independent fashion and translate
73 * it into our struct bootblock.
75 int readboot(int, struct bootblock
*);
78 * Correct the FSInfo block.
80 int writefsinfo(int, struct bootblock
*);
83 struct fat_descriptor
;
85 int cleardirty(struct fat_descriptor
*);
87 void fat_clear_cl_head(struct fat_descriptor
*, cl_t
);
88 bool fat_is_cl_head(struct fat_descriptor
*, cl_t
);
90 cl_t
fat_get_cl_next(struct fat_descriptor
*, cl_t
);
92 int fat_set_cl_next(struct fat_descriptor
*, cl_t
, cl_t
);
94 cl_t
fat_allocate_cluster(struct fat_descriptor
*fat
);
96 struct bootblock
* fat_get_boot(struct fat_descriptor
*);
97 int fat_get_fd(struct fat_descriptor
*);
98 bool fat_is_valid_cl(struct fat_descriptor
*, cl_t
);
101 * Read the FAT 0 and return a pointer to the newly allocated
104 int readfat(int, struct bootblock
*, struct fat_descriptor
**);
107 * Write back FAT entries
109 int writefat(struct fat_descriptor
*);
114 int resetDosDirSection(struct fat_descriptor
*);
115 void finishDosDirSection(void);
116 int handleDirTree(struct fat_descriptor
*);
119 * Cross-check routines run after everything is completely in memory
121 int checkchain(struct fat_descriptor
*, cl_t
, size_t *);
124 * Check for lost cluster chains
126 int checklost(struct fat_descriptor
*);
128 * Try to reconnect a lost cluster chain
130 int reconnect(struct fat_descriptor
*, cl_t
, size_t);
134 * Small helper functions
137 * Return the type of a reserved cluster as text
139 const char *rsrvdcltype(cl_t
);
142 * Clear a cluster chain in a FAT
144 void clearchain(struct fat_descriptor
*, cl_t
);