source: mainline/uspace/srv/fs/exfat/exfat_dentry.h@ 7b882c1f

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

Fix vertical spacing with new Ccheck revision.

  • 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 exfat
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/* All dentry structs should have 31 byte size */
61typedef struct {
62 uint8_t size;
63 uint16_t label[11];
64 uint8_t _reserved[8];
65} __attribute__((packed)) exfat_vollabel_dentry_t;
66
67typedef struct {
68 uint8_t flags;
69 uint8_t _reserved[18];
70 uint32_t firstc;
71 uint64_t size;
72} __attribute__((packed)) exfat_bitmap_dentry_t;
73
74typedef struct {
75 uint8_t _reserved1[3];
76 uint32_t checksum;
77 uint8_t _reserved2[12];
78 uint32_t firstc;
79 uint64_t size;
80} __attribute__((packed)) exfat_uctable_dentry_t;
81
82typedef struct {
83 uint8_t count; /* Always zero */
84 uint16_t checksum;
85 uint16_t flags;
86 uint8_t guid[16];
87 uint8_t _reserved[10];
88} __attribute__((packed)) exfat_guid_dentry_t;
89
90typedef struct {
91 uint8_t count;
92 uint16_t checksum;
93 uint16_t attr;
94 uint8_t _reserved1[2];
95 uint32_t ctime;
96 uint32_t mtime;
97 uint32_t atime;
98 uint8_t ctime_fine;
99 uint8_t mtime_fine;
100 uint8_t ctime_tz;
101 uint8_t mtime_tz;
102 uint8_t atime_tz;
103 uint8_t _reserved2[7];
104} __attribute__((packed)) exfat_file_dentry_t;
105
106typedef struct {
107 uint8_t flags;
108 uint8_t _reserved1[1];
109 uint8_t name_size;
110 uint16_t hash;
111 uint8_t _reserved2[2];
112 uint64_t valid_data_size;
113 uint8_t _reserved3[4];
114 uint32_t firstc;
115 uint64_t data_size;
116} __attribute__((packed)) exfat_stream_dentry_t;
117
118typedef struct {
119 uint8_t flags;
120 uint16_t name[EXFAT_NAME_PART_LEN];
121} __attribute__((packed)) exfat_name_dentry_t;
122
123typedef struct {
124 uint8_t type;
125 union {
126 exfat_vollabel_dentry_t vollabel;
127 exfat_bitmap_dentry_t bitmap;
128 exfat_uctable_dentry_t uctable;
129 exfat_guid_dentry_t guid;
130 exfat_file_dentry_t file;
131 exfat_stream_dentry_t stream;
132 exfat_name_dentry_t name;
133 };
134} __attribute__((packed)) exfat_dentry_t;
135
136typedef enum {
137 EXFAT_DENTRY_SKIP,
138 EXFAT_DENTRY_LAST,
139 EXFAT_DENTRY_FREE,
140 EXFAT_DENTRY_VOLLABEL,
141 EXFAT_DENTRY_BITMAP,
142 EXFAT_DENTRY_UCTABLE,
143 EXFAT_DENTRY_GUID,
144 EXFAT_DENTRY_FILE,
145 EXFAT_DENTRY_STREAM,
146 EXFAT_DENTRY_NAME
147} exfat_dentry_clsf_t;
148
149extern exfat_dentry_clsf_t exfat_classify_dentry(const exfat_dentry_t *);
150
151extern uint16_t exfat_name_hash(const uint16_t *, const uint16_t *, size_t);
152
153extern void exfat_dentry_get_name(const exfat_name_dentry_t *, size_t,
154 uint16_t *, size_t *);
155extern void exfat_dentry_get_vollabel(const exfat_vollabel_dentry_t *, size_t,
156 uint16_t *);
157
158extern bool exfat_valid_char(wchar_t);
159extern bool exfat_valid_name(const char *);
160
161extern size_t exfat_utf16_length(const uint16_t *);
162
163#endif
164
165/**
166 * @}
167 */
Note: See TracBrowser for help on using the repository browser.