source: mainline/uspace/lib/label/include/std/fat.h

Last change on this file was c8ea6eca, checked in by Jakub Jermar <jakub@…>, 7 years ago

Improve doxygen documentation

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[9e7615d]1/*
2 * Copyright (c) 2008 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - 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.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
[c8ea6eca]29/** @addtogroup liblabel
[9e7615d]30 * @{
31 */
32
33#ifndef FAT_FAT_H_
34#define FAT_FAT_H_
35
36#include <stdint.h>
37
38#define BS_BLOCK 0
39#define BS_SIZE 512
40#define DIRENT_SIZE 32
41
42#define FAT12_CLST_MAX 4085
43#define FAT16_CLST_MAX 65525
44
45#define FATAUTO 0
46#define FAT12 12
47#define FAT16 16
48#define FAT32 32
49
50#define FAT_CLUSTER_DOUBLE_SIZE(a) ((a) / 4)
51
52typedef struct fat_bs {
[904b1bc]53 /** Jump instruction */
54 uint8_t ji[3];
[9e7615d]55 uint8_t oem_name[8];
[904b1bc]56
[9e7615d]57 /* BIOS Parameter Block */
[904b1bc]58
59 /** Bytes per sector */
60 uint16_t bps;
61 /** Sectors per cluster */
62 uint8_t spc;
63 /** Reserved sector count */
64 uint16_t rscnt;
65 /** Number of FATs */
66 uint8_t fatcnt;
67 /** Maximum number of root directory entries */
68 uint16_t root_ent_max;
69 /** Total sectors. 16-bit version */
70 uint16_t totsec16;
71 /** Media descriptor */
72 uint8_t mdesc;
73 /** Sectors per FAT12/FAT16 */
74 uint16_t sec_per_fat;
75 /** Sectors per track */
76 uint16_t sec_per_track;
77 /** Number of heads */
78 uint16_t headcnt;
79 /** Hidden sectors */
80 uint32_t hidden_sec;
81 /** Total sectors. 32-bit version */
82 uint32_t totsec32;
[9e7615d]83
84 union {
85 struct {
86 /* FAT12/FAT16 only: Extended BIOS Parameter Block */
87 /** Physical drive number. */
88 uint8_t pdn;
89 uint8_t reserved;
90 /** Extended boot signature. */
91 uint8_t ebs;
92 /** Serial number. */
93 uint32_t id;
94 /** Volume label. */
95 uint8_t label[11];
96 /** FAT type. */
97 uint8_t type[8];
98 /** Boot code. */
99 uint8_t boot_code[448];
100 /** Boot sector signature. */
101 uint16_t signature;
[1433ecda]102 } __attribute__((packed));
[9e7615d]103 struct {
104 /* FAT32 only */
105 /** Sectors per FAT. */
106 uint32_t sectors_per_fat;
107 /** FAT flags. */
108 uint16_t flags;
109 /** Version. */
110 uint16_t version;
111 /** Cluster number of root directory. */
112 uint32_t root_cluster;
113 /** Sector number of file system information sector. */
114 uint16_t fsinfo_sec;
115 /** Sector number of boot sector copy. */
116 uint16_t bscopy_sec;
117 uint8_t reserved1[12];
118 /** Physical drive number. */
119 uint8_t pdn;
120 uint8_t reserved2;
121 /** Extended boot signature. */
122 uint8_t ebs;
123 /** Serial number. */
124 uint32_t id;
125 /** Volume label. */
126 uint8_t label[11];
127 /** FAT type. */
128 uint8_t type[8];
129 /** Boot code. */
130 uint8_t boot_code[420];
131 /** Signature. */
132 uint16_t signature;
[1433ecda]133 } __attribute__((packed)) fat32;
[9e7615d]134 };
[1433ecda]135} __attribute__((packed)) fat_bs_t;
[9e7615d]136
137#endif
138
139/**
140 * @}
141 */
Note: See TracBrowser for help on using the repository browser.