Add macro make_build in spec file
[platform/upstream/dosfstools.git] / src / 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 #include <stdint.h>
24
25 #define SECTOR_SIZE 512         /* sector size (bytes) */
26 #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
27 #define MSDOS_DPS_BITS 4        /* log2(MSDOS_DPS) */
28 #define MSDOS_DIR_BITS 5        /* log2(sizeof(struct msdos_dir_entry)) */
29
30 #define ATTR_NONE 0     /* no attribute bits */
31 #define ATTR_RO 1       /* read-only */
32 #define ATTR_HIDDEN 2   /* hidden */
33 #define ATTR_SYS 4      /* system */
34 #define ATTR_VOLUME 8   /* volume label */
35 #define ATTR_DIR 16     /* directory */
36 #define ATTR_ARCH 32    /* archived */
37
38 /* attribute bits that are copied "as is" */
39 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
40
41 #define DELETED_FLAG 0xe5       /* marks file as deleted when in name[0] */
42 #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
43
44 #define MSDOS_NAME 11                   /* maximum name length */
45 #define MSDOS_DOT ".          "         /* ".", padded to MSDOS_NAME chars */
46 #define MSDOS_DOTDOT "..         "      /* "..", padded to MSDOS_NAME chars */
47
48 struct msdos_dir_entry {
49     uint8_t name[MSDOS_NAME];   /* name including extension */
50     uint8_t attr;               /* attribute bits */
51     uint8_t lcase;              /* Case for base and extension */
52     uint8_t ctime_cs;           /* Creation time, centiseconds (0-199) */
53     uint16_t ctime;             /* Creation time */
54     uint16_t cdate;             /* Creation date */
55     uint16_t adate;             /* Last access date */
56     uint16_t starthi;           /* High 16 bits of cluster in FAT32 */
57     uint16_t time, date, start; /* time, date and first cluster */
58     uint32_t size;              /* file size (in bytes) */
59 } __attribute__ ((packed));
60
61 #endif /* _MSDOS_FS_H */