[VFATLIB] Upgrade fsck.fat to 4.1
[reactos.git] / sdk / lib / fslib / vfatlib / check / msdos_fs.h
1 /* msdos_fs.h - MS-DOS filesystem constants/structures
2
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 The complete text of the GNU General Public License
17 can be found in /usr/share/common-licenses/GPL-3 file.
18 */
19
20 #ifndef _MSDOS_FS_H
21 #define _MSDOS_FS_H
22
23 #ifndef __REACTOS__
24 #include <stdint.h>
25 #endif
26
27 #define SECTOR_SIZE 512 /* sector size (bytes) */
28 #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
29 #define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */
30 #define MSDOS_DIR_BITS 5 /* log2(sizeof(struct msdos_dir_entry)) */
31
32 #define ATTR_NONE 0 /* no attribute bits */
33 #define ATTR_RO 1 /* read-only */
34 #define ATTR_HIDDEN 2 /* hidden */
35 #define ATTR_SYS 4 /* system */
36 #define ATTR_VOLUME 8 /* volume label */
37 #define ATTR_DIR 16 /* directory */
38 #define ATTR_ARCH 32 /* archived */
39
40 /* attribute bits that are copied "as is" */
41 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
42
43 #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
44 #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
45
46 #define MSDOS_NAME 11 /* maximum name length */
47 #define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */
48 #define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */
49
50 #ifdef __REACTOS__
51 #include <pshpack1.h>
52 #endif
53
54 struct msdos_dir_entry {
55 uint8_t name[MSDOS_NAME]; /* name including extension */
56 uint8_t attr; /* attribute bits */
57 uint8_t lcase; /* Case for base and extension */
58 uint8_t ctime_cs; /* Creation time, centiseconds (0-199) */
59 uint16_t ctime; /* Creation time */
60 uint16_t cdate; /* Creation date */
61 uint16_t adate; /* Last access date */
62 uint16_t starthi; /* High 16 bits of cluster in FAT32 */
63 uint16_t time, date, start; /* time, date and first cluster */
64 uint32_t size; /* file size (in bytes) */
65 } __attribute__ ((packed));
66
67 #ifdef __REACTOS__
68 #include <poppack.h>
69 #endif
70
71 #endif /* _MSDOS_FS_H */