dosfs.h revision 1.3
1/* $OpenBSD: dosfs.h,v 1.3 1996/06/23 14:30:42 deraadt Exp $ */ 2/* $NetBSD: dosfs.h,v 1.1.4.1 1996/05/31 18:41:42 jtc Exp $ */ 3 4/* 5 * Copyright (C) 1995, 1996 Wolfgang Solfrank 6 * Copyright (c) 1995 Martin Husemann 7 * Some structure declaration borrowed from Paul Popelka 8 * (paulp@uts.amdahl.com), see /sys/msdosfs/ for reference. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by Martin Husemann 21 * and Wolfgang Solfrank. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 29 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38#ifndef DOSFS_H 39#define DOSFS_H 40 41#define DOSBOOTBLOCKSIZE 512 42 43#define MAX12BITCLUSTERS 4078 44 45typedef u_int16_t cl_t; /* type holding a cluster number */ 46 47/* 48 * architecture independent description of all the info stored in a 49 * FAT boot block. 50 */ 51struct bootblock { 52 u_int BytesPerSec; /* bytes per sector */ 53 u_int SecPerClust; /* sectors per cluster */ 54 u_int ResSectors; /* number of reserved sectors */ 55 u_int FATs; /* number of FATs */ 56 u_int RootDirEnts; /* number of root directory entries */ 57 u_int32_t Sectors; /* total number of sectors */ 58 u_int Media; /* media descriptor */ 59 u_int FATsecs; /* number of sectors per FAT */ 60 u_int SecPerTrack; /* sectors per track */ 61 u_int Heads; /* number of heads */ 62 u_int32_t HiddenSecs; /* # of hidden sectors */ 63 u_int32_t HugeSectors; /* # of sectors if bpbSectors == 0 */ 64 65 /* and some more calculated values */ 66 int Is16BitFat; /* 0 for 12 bit, 1 for 16 bit */ 67 cl_t NumClusters; /* # of entries in a FAT */ 68 u_int32_t NumSectors; /* how many sectors are there */ 69 u_int32_t NumFatEntries; /* how many entries really are there */ 70 u_int ClusterOffset; /* at what sector would sector 0 start */ 71 u_int ClusterSize; /* Cluster size in bytes */ 72 73 /* Now some statistics: */ 74 u_int NumFiles; /* # of plain files */ 75 u_int NumFree; /* # of free clusters */ 76}; 77 78struct fatEntry { 79 cl_t next; /* pointer to next cluster */ 80 cl_t head; /* pointer to start of chain */ 81 u_int32_t length; /* number of clusters on chain */ 82 int flags; /* see below */ 83}; 84 85#define CLUST_FREE 0 /* 0 means cluster is free */ 86#define CLUST_FIRST 2 /* 2 is the minimum valid cluster number */ 87#define CLUST_RSRVD 0xfff0 /* start of reserved clusters */ 88#define CLUST_BAD 0xfff7 /* a cluster with a defect */ 89#define CLUST_EOFS 0xfff8 /* start of EOF indicators */ 90#define CLUST_EOF 0xffff /* standard value for last cluster */ 91 92#define FAT_USED 1 /* This fat chain is used in a file */ 93 94#define DOSLONGNAMELEN 256 /* long name maximal length */ 95#define LRFIRST 0x40 /* first long name record */ 96#define LRNOMASK 0x1f /* mask to extract long record 97 * sequence number */ 98 99/* 100 * Architecture independent description of a directory entry 101 */ 102struct dosDirEntry { 103 struct dosDirEntry 104 *parent, /* previous tree level */ 105 *next, /* next brother */ 106 *child; /* if this is a directory */ 107 char name[8+1+3+1]; /* alias name first part */ 108 char lname[DOSLONGNAMELEN]; /* real name */ 109 uint flags; /* attributes */ 110 cl_t head; /* cluster no */ 111 u_int32_t size; /* filesize in bytes */ 112 uint fsckflags; /* flags during fsck */ 113}; 114/* Flags in fsckflags: */ 115#define DIREMPTY 1 116#define DIREMPWARN 2 117 118/* 119 * TODO-list of unread directories 120 */ 121struct dirTodoNode { 122 struct dosDirEntry *dir; 123 struct dirTodoNode *next; 124}; 125 126#endif 127