source: mainline/uspace/srv/fs/exfat/exfat_dentry.h@ 18902ca6

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 18902ca6 was f3504c1, checked in by Jiri Svoboda <jiri@…>, 8 years ago

ExFAT volume label support.

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * Copyright (c) 2011 Oleg Romanenko
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
29/** @addtogroup fs
30 * @{
31 */
32
33#ifndef EXFAT_EXFAT_DENTRY_H_
34#define EXFAT_EXFAT_DENTRY_H_
35
36#include <stddef.h>
37#include <stdint.h>
38#include <stdbool.h>
39
40#define EXFAT_FILENAME_LEN 255
41#define EXFAT_NAME_PART_LEN 15
42#define EXFAT_VOLLABEL_LEN 11
43
44#define EXFAT_TYPE_UNUSED 0x00
45#define EXFAT_TYPE_USED 0x80
46#define EXFAT_TYPE_VOLLABEL 0x83
47#define EXFAT_TYPE_BITMAP 0x81
48#define EXFAT_TYPE_UCTABLE 0x82
49#define EXFAT_TYPE_GUID 0xA0
50#define EXFAT_TYPE_FILE 0x85
51#define EXFAT_TYPE_STREAM 0xC0
52#define EXFAT_TYPE_NAME 0xC1
53
54#define EXFAT_ATTR_RDONLY 0x01
55#define EXFAT_ATTR_HIDDEN 0x02
56#define EXFAT_ATTR_SYSTEM 0x04
57#define EXFAT_ATTR_SUBDIR 0x10
58#define EXFAT_ATTR_ARCHIVE 0x20
59
60
61/* All dentry structs should have 31 byte size */
62typedef struct {
63 uint8_t size;
64 uint16_t label[11];
65 uint8_t _reserved[8];
66} __attribute__ ((packed)) exfat_vollabel_dentry_t;
67
68typedef struct {
69 uint8_t flags;
70 uint8_t _reserved[18];
71 uint32_t firstc;
72 uint64_t size;
73} __attribute__ ((packed)) exfat_bitmap_dentry_t;
74
75typedef struct {
76 uint8_t _reserved1[3];
77 uint32_t checksum;
78 uint8_t _reserved2[12];
79 uint32_t firstc;
80 uint64_t size;
81} __attribute__ ((packed)) exfat_uctable_dentry_t;
82
83typedef struct {
84 uint8_t count; /* Always zero */
85 uint16_t checksum;
86 uint16_t flags;
87 uint8_t guid[16];
88 uint8_t _reserved[10];
89} __attribute__ ((packed)) exfat_guid_dentry_t;
90
91typedef struct {
92 uint8_t count;
93 uint16_t checksum;
94 uint16_t attr;
95 uint8_t _reserved1[2];
96 uint32_t ctime;
97 uint32_t mtime;
98 uint32_t atime;
99 uint8_t ctime_fine;
100 uint8_t mtime_fine;
101 uint8_t ctime_tz;
102 uint8_t mtime_tz;
103 uint8_t atime_tz;
104 uint8_t _reserved2[7];
105} __attribute__ ((packed)) exfat_file_dentry_t;
106
107typedef struct {
108 uint8_t flags;
109 uint8_t _reserved1[1];
110 uint8_t name_size;
111 uint16_t hash;
112 uint8_t _reserved2[2];
113 uint64_t valid_data_size;
114 uint8_t _reserved3[4];
115 uint32_t firstc;
116 uint64_t data_size;
117} __attribute__ ((packed)) exfat_stream_dentry_t;
118
119typedef struct {
120 uint8_t flags;
121 uint16_t name[EXFAT_NAME_PART_LEN];
122} __attribute__ ((packed)) exfat_name_dentry_t;
123
124
125typedef struct {
126 uint8_t type;
127 union {
128 exfat_vollabel_dentry_t vollabel;
129 exfat_bitmap_dentry_t bitmap;
130 exfat_uctable_dentry_t uctable;
131 exfat_guid_dentry_t guid;
132 exfat_file_dentry_t file;
133 exfat_stream_dentry_t stream;
134 exfat_name_dentry_t name;
135 };
136} __attribute__ ((packed)) exfat_dentry_t;
137
138
139typedef enum {
140 EXFAT_DENTRY_SKIP,
141 EXFAT_DENTRY_LAST,
142 EXFAT_DENTRY_FREE,
143 EXFAT_DENTRY_VOLLABEL,
144 EXFAT_DENTRY_BITMAP,
145 EXFAT_DENTRY_UCTABLE,
146 EXFAT_DENTRY_GUID,
147 EXFAT_DENTRY_FILE,
148 EXFAT_DENTRY_STREAM,
149 EXFAT_DENTRY_NAME
150} exfat_dentry_clsf_t;
151
152
153extern exfat_dentry_clsf_t exfat_classify_dentry(const exfat_dentry_t *);
154
155extern uint16_t exfat_name_hash(const uint16_t *, const uint16_t *, size_t);
156
157extern void exfat_dentry_get_name(const exfat_name_dentry_t *, size_t,
158 uint16_t *, size_t *);
159extern void exfat_dentry_get_vollabel(const exfat_vollabel_dentry_t *, size_t,
160 uint16_t *);
161
162extern bool exfat_valid_char(wchar_t);
163extern bool exfat_valid_name(const char *);
164
165extern size_t exfat_utf16_length(const uint16_t *);
166
167
168#endif
169
170/**
171 * @}
172 */
Note: See TracBrowser for help on using the repository browser.