2 * Copyright (c) 2011 Oleg Romanenko
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
33 #ifndef EXFAT_EXFAT_DENTRY_H_
34 #define EXFAT_EXFAT_DENTRY_H_
41 #define EXFAT_FILENAME_LEN 255
42 #define EXFAT_NAME_PART_LEN 15
43 #define EXFAT_VOLLABEL_LEN 11
45 #define EXFAT_TYPE_UNUSED 0x00
46 #define EXFAT_TYPE_USED 0x80
47 #define EXFAT_TYPE_VOLLABEL 0x83
48 #define EXFAT_TYPE_BITMAP 0x81
49 #define EXFAT_TYPE_UCTABLE 0x82
50 #define EXFAT_TYPE_GUID 0xA0
51 #define EXFAT_TYPE_FILE 0x85
52 #define EXFAT_TYPE_STREAM 0xC0
53 #define EXFAT_TYPE_NAME 0xC1
55 #define EXFAT_ATTR_RDONLY 0x01
56 #define EXFAT_ATTR_HIDDEN 0x02
57 #define EXFAT_ATTR_SYSTEM 0x04
58 #define EXFAT_ATTR_SUBDIR 0x10
59 #define EXFAT_ATTR_ARCHIVE 0x20
61 /* All dentry structs should have 31 byte size */
66 } __attribute__((packed
)) exfat_vollabel_dentry_t
;
70 uint8_t _reserved
[18];
73 } __attribute__((packed
)) exfat_bitmap_dentry_t
;
76 uint8_t _reserved1
[3];
78 uint8_t _reserved2
[12];
81 } __attribute__((packed
)) exfat_uctable_dentry_t
;
84 uint8_t count
; /* Always zero */
88 uint8_t _reserved
[10];
89 } __attribute__((packed
)) exfat_guid_dentry_t
;
95 uint8_t _reserved1
[2];
104 uint8_t _reserved2
[7];
105 } __attribute__((packed
)) exfat_file_dentry_t
;
109 uint8_t _reserved1
[1];
112 uint8_t _reserved2
[2];
113 uint64_t valid_data_size
;
114 uint8_t _reserved3
[4];
117 } __attribute__((packed
)) exfat_stream_dentry_t
;
121 uint16_t name
[EXFAT_NAME_PART_LEN
];
122 } __attribute__((packed
)) exfat_name_dentry_t
;
127 exfat_vollabel_dentry_t vollabel
;
128 exfat_bitmap_dentry_t bitmap
;
129 exfat_uctable_dentry_t uctable
;
130 exfat_guid_dentry_t guid
;
131 exfat_file_dentry_t file
;
132 exfat_stream_dentry_t stream
;
133 exfat_name_dentry_t name
;
135 } __attribute__((packed
)) exfat_dentry_t
;
141 EXFAT_DENTRY_VOLLABEL
,
143 EXFAT_DENTRY_UCTABLE
,
148 } exfat_dentry_clsf_t
;
150 extern exfat_dentry_clsf_t
exfat_classify_dentry(const exfat_dentry_t
*);
152 extern uint16_t exfat_name_hash(const uint16_t *, const uint16_t *, size_t);
154 extern void exfat_dentry_get_name(const exfat_name_dentry_t
*, size_t,
155 uint16_t *, size_t *);
156 extern void exfat_dentry_get_vollabel(const exfat_vollabel_dentry_t
*, size_t,
159 extern bool exfat_valid_char(char32_t
);
160 extern bool exfat_valid_name(const char *);
162 extern size_t exfat_utf16_length(const uint16_t *);