kernel - Order ipfw3 module before other ipfw3_* modules
[dragonfly.git] / usr.sbin / fstyp / msdosfs.h
blobbd0abcef600c6233b25231d2de7855cdb9d16a30
1 /*-
2 * Copyright (c) 2016 The DragonFly Project
3 * Copyright (c) 2006 Tobias Reifenberger
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
27 * $FreeBSD$
30 #include <sys/types.h>
33 * Conversion macros for little endian encoded unsigned integers
34 * in byte streams to the local unsigned integer format.
36 #define UINT16BYTES(p) ((uint32_t)((p)[0] + (256*(p)[1])))
37 #define UINT32BYTES(p) ((uint32_t)((p)[0] + (256*(p)[1]) + \
38 (65536*(p)[2]) + (16777216*(p)[3])))
41 * All following structures are according to:
43 * Microsoft Extensible Firmware Initiative FAT32 File System Specification
44 * FAT: General Overview of On-Disk Format
45 * Version 1.03, December 6, 2000
46 * Microsoft Corporation
50 * FAT boot sector and boot parameter block for
51 * FAT12 and FAT16 volumes
53 typedef struct fat_bsbpb {
54 /* common fields */
55 uint8_t BS_jmpBoot[3];
56 uint8_t BS_OEMName[8];
57 uint8_t BPB_BytsPerSec[2];
58 uint8_t BPB_SecPerClus;
59 uint8_t BPB_RsvdSecCnt[2];
60 uint8_t BPB_NumFATs;
61 uint8_t BPB_RootEntCnt[2];
62 uint8_t BPB_TotSec16[2];
63 uint8_t BPB_Media;
64 uint8_t BPB_FATSz16[2];
65 uint8_t BPB_SecPerTrack[2];
66 uint8_t BPB_NumHeads[2];
67 uint8_t BPB_HiddSec[4];
68 uint8_t BPB_TotSec32[4];
69 /* FAT12/FAT16 only fields */
70 uint8_t BS_DrvNum;
71 uint8_t BS_Reserved1;
72 uint8_t BS_BootSig;
73 uint8_t BS_VolID[4];
74 uint8_t BS_VolLab[11];
75 uint8_t BS_FilSysType[8];
76 } FAT_BSBPB; /* 62 bytes */
79 * FAT boot sector and boot parameter block for
80 * FAT32 volumes
82 typedef struct fat32_bsbpb {
83 /* common fields */
84 uint8_t BS_jmpBoot[3];
85 uint8_t BS_OEMName[8];
86 uint8_t BPB_BytsPerSec[2];
87 uint8_t BPB_SecPerClus;
88 uint8_t BPB_RsvdSecCnt[2];
89 uint8_t BPB_NumFATs;
90 uint8_t BPB_RootEntCnt[2];
91 uint8_t BPB_TotSec16[2];
92 uint8_t BPB_Media;
93 uint8_t BPB_FATSz16[2];
94 uint8_t BPB_SecPerTrack[2];
95 uint8_t BPB_NumHeads[2];
96 uint8_t BPB_HiddSec[4];
97 uint8_t BPB_TotSec32[4];
98 /* FAT32 only fields */
99 uint8_t BPB_FATSz32[4];
100 uint8_t BPB_ExtFlags[2];
101 uint8_t BPB_FSVer[2];
102 uint8_t BPB_RootClus[4];
103 uint8_t BPB_FSInfo[2];
104 uint8_t BPB_BkBootSec[2];
105 uint8_t BPB_Reserved[12];
106 uint8_t BS_DrvNum;
107 uint8_t BS_Reserved1;
108 uint8_t BS_BootSig;
109 uint8_t BS_VolID[4];
110 uint8_t BS_VolLab[11];
111 uint8_t BS_FilSysType[8];
112 } FAT32_BSBPB; /* 90 bytes */
115 * FAT directory entry structure
117 #define FAT_DES_ATTR_READ_ONLY 0x01
118 #define FAT_DES_ATTR_HIDDEN 0x02
119 #define FAT_DES_ATTR_SYSTEM 0x04
120 #define FAT_DES_ATTR_VOLUME_ID 0x08
121 #define FAT_DES_ATTR_DIRECTORY 0x10
122 #define FAT_DES_ATTR_ARCHIVE 0x20
123 #define FAT_DES_ATTR_LONG_NAME (FAT_DES_ATTR_READ_ONLY | \
124 FAT_DES_ATTR_HIDDEN | \
125 FAT_DES_ATTR_SYSTEM | \
126 FAT_DES_ATTR_VOLUME_ID)
128 typedef struct fat_des {
129 uint8_t DIR_Name[11];
130 uint8_t DIR_Attr;
131 uint8_t DIR_NTRes;
132 uint8_t DIR_CrtTimeTenth;
133 uint8_t DIR_CrtTime[2];
134 uint8_t DIR_CrtDate[2];
135 uint8_t DIR_LstAccDate[2];
136 uint8_t DIR_FstClusHI[2];
137 uint8_t DIR_WrtTime[2];
138 uint8_t DIR_WrtDate[2];
139 uint8_t DIR_FstClusLO[2];
140 uint8_t DIR_FileSize[4];
141 } FAT_DES;