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