1f9f848faSopenharmony_ci/*- 2f9f848faSopenharmony_ci * SPDX-License-Identifier: BSD-2-Clause 3f9f848faSopenharmony_ci * 4f9f848faSopenharmony_ci * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank 5f9f848faSopenharmony_ci * Copyright (c) 1995 Martin Husemann 6f9f848faSopenharmony_ci * Some structure declaration borrowed from Paul Popelka 7f9f848faSopenharmony_ci * (paulp@uts.amdahl.com), see /sys/msdosfs/ for reference. 8f9f848faSopenharmony_ci * 9f9f848faSopenharmony_ci * Redistribution and use in source and binary forms, with or without 10f9f848faSopenharmony_ci * modification, are permitted provided that the following conditions 11f9f848faSopenharmony_ci * are met: 12f9f848faSopenharmony_ci * 1. Redistributions of source code must retain the above copyright 13f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer. 14f9f848faSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 15f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer in the 16f9f848faSopenharmony_ci * documentation and/or other materials provided with the distribution. 17f9f848faSopenharmony_ci * 18f9f848faSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 19f9f848faSopenharmony_ci * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20f9f848faSopenharmony_ci * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21f9f848faSopenharmony_ci * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22f9f848faSopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23f9f848faSopenharmony_ci * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24f9f848faSopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25f9f848faSopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26f9f848faSopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27f9f848faSopenharmony_ci * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28f9f848faSopenharmony_ci * $NetBSD: dosfs.h,v 1.4 1997/01/03 14:32:48 ws Exp $ 29f9f848faSopenharmony_ci */ 30f9f848faSopenharmony_ci 31f9f848faSopenharmony_ci#ifndef DOSFS_H 32f9f848faSopenharmony_ci#define DOSFS_H 33f9f848faSopenharmony_ci 34f9f848faSopenharmony_ci/* support 4Kn disk reads */ 35f9f848faSopenharmony_ci#define DOSBOOTBLOCKSIZE_REAL 512 36f9f848faSopenharmony_ci#define DOSBOOTBLOCKSIZE 4096 37f9f848faSopenharmony_ci 38f9f848faSopenharmony_citypedef u_int32_t cl_t; /* type holding a cluster number */ 39f9f848faSopenharmony_ci 40f9f848faSopenharmony_ci/* 41f9f848faSopenharmony_ci * architecture independent description of all the info stored in a 42f9f848faSopenharmony_ci * FAT boot block. 43f9f848faSopenharmony_ci */ 44f9f848faSopenharmony_cistruct bootblock { 45f9f848faSopenharmony_ci u_int bpbBytesPerSec; /* bytes per sector */ 46f9f848faSopenharmony_ci u_int bpbSecPerClust; /* sectors per cluster */ 47f9f848faSopenharmony_ci u_int bpbResSectors; /* number of reserved sectors */ 48f9f848faSopenharmony_ci u_int bpbFATs; /* number of bpbFATs */ 49f9f848faSopenharmony_ci u_int bpbRootDirEnts; /* number of root directory entries */ 50f9f848faSopenharmony_ci u_int32_t bpbSectors; /* total number of sectors */ 51f9f848faSopenharmony_ci u_int bpbMedia; /* media descriptor */ 52f9f848faSopenharmony_ci u_int bpbFATsmall; /* number of sectors per FAT */ 53f9f848faSopenharmony_ci u_int SecPerTrack; /* sectors per track */ 54f9f848faSopenharmony_ci u_int bpbHeads; /* number of heads */ 55f9f848faSopenharmony_ci u_int32_t bpbHiddenSecs; /* # of hidden sectors */ 56f9f848faSopenharmony_ci u_int32_t bpbHugeSectors; /* # of sectors if bpbbpbSectors == 0 */ 57f9f848faSopenharmony_ci cl_t bpbRootClust; /* Start of Root Directory */ 58f9f848faSopenharmony_ci u_int bpbFSInfo; /* FSInfo sector */ 59f9f848faSopenharmony_ci u_int bpbBackup; /* Backup of Bootblocks */ 60f9f848faSopenharmony_ci cl_t FSFree; /* Number of free clusters acc. FSInfo */ 61f9f848faSopenharmony_ci cl_t FSNext; /* Next free cluster acc. FSInfo */ 62f9f848faSopenharmony_ci 63f9f848faSopenharmony_ci /* and some more calculated values */ 64f9f848faSopenharmony_ci u_int flags; /* some flags: */ 65f9f848faSopenharmony_ci#define FAT32 1 /* this is a FAT32 file system */ 66f9f848faSopenharmony_ci /* 67f9f848faSopenharmony_ci * Maybe, we should separate out 68f9f848faSopenharmony_ci * various parts of FAT32? XXX 69f9f848faSopenharmony_ci */ 70f9f848faSopenharmony_ci int ValidFat; /* valid fat if FAT32 non-mirrored */ 71f9f848faSopenharmony_ci cl_t ClustMask; /* mask for entries in FAT */ 72f9f848faSopenharmony_ci cl_t NumClusters; /* # of entries in a FAT */ 73f9f848faSopenharmony_ci u_int32_t NumSectors; /* how many sectors are there */ 74f9f848faSopenharmony_ci u_int32_t FATsecs; /* how many sectors are in FAT */ 75f9f848faSopenharmony_ci u_int32_t NumFatEntries; /* how many entries really are there */ 76f9f848faSopenharmony_ci u_int FirstCluster; /* at what sector is Cluster CLUST_FIRST */ 77f9f848faSopenharmony_ci u_int ClusterSize; /* Cluster size in bytes */ 78f9f848faSopenharmony_ci 79f9f848faSopenharmony_ci /* Now some statistics: */ 80f9f848faSopenharmony_ci u_int NumFiles; /* # of plain files */ 81f9f848faSopenharmony_ci u_int NumFree; /* # of free clusters */ 82f9f848faSopenharmony_ci u_int NumBad; /* # of bad clusters */ 83f9f848faSopenharmony_ci}; 84f9f848faSopenharmony_ci 85f9f848faSopenharmony_ci#define CLUST_FREE 0 /* 0 means cluster is free */ 86f9f848faSopenharmony_ci#define CLUST_FIRST 2 /* 2 is the minimum valid cluster number */ 87f9f848faSopenharmony_ci#define CLUST_RSRVD 0xfffffff6 /* start of reserved clusters */ 88f9f848faSopenharmony_ci#define CLUST_BAD 0xfffffff7 /* a cluster with a defect */ 89f9f848faSopenharmony_ci#define CLUST_EOFS 0xfffffff8 /* start of EOF indicators */ 90f9f848faSopenharmony_ci#define CLUST_EOF 0xffffffff /* standard value for last cluster */ 91f9f848faSopenharmony_ci#define CLUST_DEAD 0xfdeadc0d /* error encountered */ 92f9f848faSopenharmony_ci 93f9f848faSopenharmony_ci/* 94f9f848faSopenharmony_ci * Masks for cluster values 95f9f848faSopenharmony_ci */ 96f9f848faSopenharmony_ci#define CLUST12_MASK 0xfff 97f9f848faSopenharmony_ci#define CLUST16_MASK 0xffff 98f9f848faSopenharmony_ci#define CLUST32_MASK 0xfffffff 99f9f848faSopenharmony_ci 100f9f848faSopenharmony_ci#define DOSLONGNAMELEN 256 /* long name maximal length */ 101f9f848faSopenharmony_ci#define LRFIRST 0x40 /* first long name record */ 102f9f848faSopenharmony_ci#define LRNOMASK 0x1f /* mask to extract long record 103f9f848faSopenharmony_ci * sequence number */ 104f9f848faSopenharmony_ci 105f9f848faSopenharmony_ci/* 106f9f848faSopenharmony_ci * Architecture independent description of a directory entry 107f9f848faSopenharmony_ci */ 108f9f848faSopenharmony_cistruct dosDirEntry { 109f9f848faSopenharmony_ci struct dosDirEntry 110f9f848faSopenharmony_ci *parent, /* previous tree level */ 111f9f848faSopenharmony_ci *next, /* next brother */ 112f9f848faSopenharmony_ci *child; /* if this is a directory */ 113f9f848faSopenharmony_ci char name[8+1+3+1]; /* alias name first part */ 114f9f848faSopenharmony_ci char lname[DOSLONGNAMELEN]; /* real name */ 115f9f848faSopenharmony_ci uint flags; /* attributes */ 116f9f848faSopenharmony_ci cl_t head; /* cluster no */ 117f9f848faSopenharmony_ci u_int32_t size; /* filesize in bytes */ 118f9f848faSopenharmony_ci uint fsckflags; /* flags during fsck */ 119f9f848faSopenharmony_ci}; 120f9f848faSopenharmony_ci/* Flags in fsckflags: */ 121f9f848faSopenharmony_ci#define DIREMPTY 1 122f9f848faSopenharmony_ci#define DIREMPWARN 2 123f9f848faSopenharmony_ci 124f9f848faSopenharmony_ci/* 125f9f848faSopenharmony_ci * TODO-list of unread directories 126f9f848faSopenharmony_ci */ 127f9f848faSopenharmony_cistruct dirTodoNode { 128f9f848faSopenharmony_ci struct dosDirEntry *dir; 129f9f848faSopenharmony_ci struct dirTodoNode *next; 130f9f848faSopenharmony_ci}; 131f9f848faSopenharmony_ci 132f9f848faSopenharmony_ci#endif 133