/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank4* Copyright (c) 1995 Martin Husemann5* Some structure declaration borrowed from Paul Popelka6* ([email protected]), see /sys/msdosfs/ for reference.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions and the following disclaimer.13* 2. Redistributions in binary form must reproduce the above copyright14* notice, this list of conditions and the following disclaimer in the15* documentation and/or other materials provided with the distribution.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR18* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES19* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.20* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,21* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT22* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF26* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27* $NetBSD: dosfs.h,v 1.4 1997/01/03 14:32:48 ws Exp $28*/2930#ifndef DOSFS_H31#define DOSFS_H3233/* support 4Kn disk reads */34#define DOSBOOTBLOCKSIZE_REAL 51235#define DOSBOOTBLOCKSIZE 40963637typedef u_int32_t cl_t; /* type holding a cluster number */3839/*40* architecture independent description of all the info stored in a41* FAT boot block.42*/43struct bootblock {44u_int bpbBytesPerSec; /* bytes per sector */45u_int bpbSecPerClust; /* sectors per cluster */46u_int bpbResSectors; /* number of reserved sectors */47u_int bpbFATs; /* number of bpbFATs */48u_int bpbRootDirEnts; /* number of root directory entries */49u_int32_t bpbSectors; /* total number of sectors */50u_int bpbMedia; /* media descriptor */51u_int bpbFATsmall; /* number of sectors per FAT */52u_int SecPerTrack; /* sectors per track */53u_int bpbHeads; /* number of heads */54u_int32_t bpbHiddenSecs; /* # of hidden sectors */55u_int32_t bpbHugeSectors; /* # of sectors if bpbbpbSectors == 0 */56cl_t bpbRootClust; /* Start of Root Directory */57u_int bpbFSInfo; /* FSInfo sector */58u_int bpbBackup; /* Backup of Bootblocks */59cl_t FSFree; /* Number of free clusters acc. FSInfo */60cl_t FSNext; /* Next free cluster acc. FSInfo */6162/* and some more calculated values */63u_int flags; /* some flags: */64#define FAT32 1 /* this is a FAT32 file system */65/*66* Maybe, we should separate out67* various parts of FAT32? XXX68*/69int ValidFat; /* valid fat if FAT32 non-mirrored */70cl_t ClustMask; /* mask for entries in FAT */71cl_t NumClusters; /* # of entries in a FAT */72u_int32_t NumSectors; /* how many sectors are there */73u_int32_t FATsecs; /* how many sectors are in FAT */74u_int32_t NumFatEntries; /* how many entries really are there */75u_int FirstCluster; /* at what sector is Cluster CLUST_FIRST */76u_int ClusterSize; /* Cluster size in bytes */7778/* Now some statistics: */79u_int NumFiles; /* # of plain files */80u_int NumFree; /* # of free clusters */81u_int NumBad; /* # of bad clusters */82};8384#define CLUST_FREE 0 /* 0 means cluster is free */85#define CLUST_FIRST 2 /* 2 is the minimum valid cluster number */86#define CLUST_RSRVD 0xfffffff6 /* start of reserved clusters */87#define CLUST_BAD 0xfffffff7 /* a cluster with a defect */88#define CLUST_EOFS 0xfffffff8 /* start of EOF indicators */89#define CLUST_EOF 0xffffffff /* standard value for last cluster */90#define CLUST_DEAD 0xfdeadc0d /* error encountered */9192/*93* Masks for cluster values94*/95#define CLUST12_MASK 0xfff96#define CLUST16_MASK 0xffff97#define CLUST32_MASK 0xfffffff9899#define DOSLONGNAMELEN 256 /* long name maximal length */100#define LRFIRST 0x40 /* first long name record */101#define LRNOMASK 0x1f /* mask to extract long record102* sequence number */103104/*105* Architecture independent description of a directory entry106*/107struct dosDirEntry {108struct dosDirEntry109*parent, /* previous tree level */110*next, /* next brother */111*child; /* if this is a directory */112char name[8+1+3+1]; /* alias name first part */113char lname[DOSLONGNAMELEN]; /* real name */114uint flags; /* attributes */115cl_t head; /* cluster no */116u_int32_t size; /* filesize in bytes */117uint fsckflags; /* flags during fsck */118};119/* Flags in fsckflags: */120#define DIREMPTY 1121#define DIREMPWARN 2122123/*124* TODO-list of unread directories125*/126struct dirTodoNode {127struct dosDirEntry *dir;128struct dirTodoNode *next;129};130131#endif132133134