1/* 2 * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank 3 * Copyright (c) 1995 Martin Husemann 4 * Some structure declaration borrowed from Paul Popelka 5 * (paulp@uts.amdahl.com), see /sys/msdosfs/ for reference. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 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. 15 * 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: dosfs.h,v 1.4 1997/01/03 14:32:48 ws Exp $
|
27 * $FreeBSD: head/sbin/fsck_msdosfs/dosfs.h 203871 2010-02-14 12:28:43Z kib $
|
27 * $FreeBSD: head/sbin/fsck_msdosfs/dosfs.h 203872 2010-02-14 12:30:30Z kib $ |
28 */ 29 30#ifndef DOSFS_H 31#define DOSFS_H 32 33#define DOSBOOTBLOCKSIZE 512 34 35typedef u_int32_t cl_t; /* type holding a cluster number */ 36 37/* 38 * architecture independent description of all the info stored in a 39 * FAT boot block. 40 */ 41struct bootblock { 42 u_int BytesPerSec; /* bytes per sector */ 43 u_int SecPerClust; /* sectors per cluster */ 44 u_int ResSectors; /* number of reserved sectors */ 45 u_int FATs; /* number of FATs */ 46 u_int RootDirEnts; /* number of root directory entries */ 47 u_int Media; /* media descriptor */ 48 u_int FATsmall; /* number of sectors per FAT */ 49 u_int SecPerTrack; /* sectors per track */ 50 u_int Heads; /* number of heads */
|
51 u_int32_t Sectors; /* total number of sectors */
|
51 u_int32_t HiddenSecs; /* # of hidden sectors */
|
52 u_int32_t Sectors; /* total number of sectors */ 53#define FAT32 1 /* this is a FAT32 file system */ 54 /* 55 * Maybe, we should separate out 56 * various parts of FAT32? XXX 57 */ |
58 u_int32_t HugeSectors; /* # of sectors if bpbSectors == 0 */ 59 u_int FSInfo; /* FSInfo sector */ 60 u_int Backup; /* Backup of Bootblocks */ 61 cl_t RootCl; /* Start of Root Directory */ 62 cl_t FSFree; /* Number of free clusters acc. FSInfo */ 63 cl_t FSNext; /* Next free cluster acc. FSInfo */ 64 65 /* and some more calculated values */ 66 u_int flags; /* some flags: */
|
62#define FAT32 1 /* this is a FAT32 file system */
63 /*
64 * Maybe, we should separate out
65 * various parts of FAT32? XXX
66 */
|
67 int ValidFat; /* valid fat if FAT32 non-mirrored */ 68 cl_t ClustMask; /* mask for entries in FAT */ 69 cl_t NumClusters; /* # of entries in a FAT */ 70 u_int32_t NumSectors; /* how many sectors are there */ 71 u_int32_t FATsecs; /* how many sectors are in FAT */ 72 u_int32_t NumFatEntries; /* how many entries really are there */ 73 u_int ClusterOffset; /* at what sector would sector 0 start */ 74 u_int ClusterSize; /* Cluster size in bytes */ 75 76 /* Now some statistics: */ 77 u_int NumFiles; /* # of plain files */ 78 u_int NumFree; /* # of free clusters */ 79 u_int NumBad; /* # of bad clusters */ 80}; 81 82struct fatEntry { 83 cl_t next; /* pointer to next cluster */ 84 cl_t head; /* pointer to start of chain */ 85 u_int32_t length; /* number of clusters on chain */ 86 int flags; /* see below */ 87}; 88 89#define CLUST_FREE 0 /* 0 means cluster is free */ 90#define CLUST_FIRST 2 /* 2 is the minimum valid cluster number */ 91#define CLUST_RSRVD 0xfffffff6 /* start of reserved clusters */ 92#define CLUST_BAD 0xfffffff7 /* a cluster with a defect */ 93#define CLUST_EOFS 0xfffffff8 /* start of EOF indicators */ 94#define CLUST_EOF 0xffffffff /* standard value for last cluster */ 95 96/* 97 * Masks for cluster values 98 */ 99#define CLUST12_MASK 0xfff 100#define CLUST16_MASK 0xffff 101#define CLUST32_MASK 0xfffffff 102 103#define FAT_USED 1 /* This fat chain is used in a file */ 104 105#define DOSLONGNAMELEN 256 /* long name maximal length */ 106#define LRFIRST 0x40 /* first long name record */ 107#define LRNOMASK 0x1f /* mask to extract long record 108 * sequence number */ 109 110/* 111 * Architecture independent description of a directory entry 112 */ 113struct dosDirEntry { 114 struct dosDirEntry 115 *parent, /* previous tree level */ 116 *next, /* next brother */ 117 *child; /* if this is a directory */ 118 char name[8+1+3+1]; /* alias name first part */ 119 char lname[DOSLONGNAMELEN]; /* real name */ 120 uint flags; /* attributes */ 121 cl_t head; /* cluster no */ 122 u_int32_t size; /* filesize in bytes */ 123 uint fsckflags; /* flags during fsck */ 124}; 125/* Flags in fsckflags: */ 126#define DIREMPTY 1 127#define DIREMPWARN 2 128 129/* 130 * TODO-list of unread directories 131 */ 132struct dirTodoNode { 133 struct dosDirEntry *dir; 134 struct dirTodoNode *next; 135}; 136 137#endif
|