#define EXFAT_ENAME_MAX 15
-struct exfat_bitmap /* allocated clusters bitmap */
+struct exfat_entry_bitmap /* allocated clusters bitmap */
{
uint8_t type; /* EXFAT_ENTRY_BITMAP */
uint8_t __unknown1[19];
le64_t size; /* in bytes */
};
-struct exfat_upcase /* upper case translation table */
+struct exfat_entry_upcase /* upper case translation table */
{
uint8_t type; /* EXFAT_ENTRY_UPCASE */
uint8_t __unknown1[3];
le64_t size; /* in bytes */
};
-struct exfat_label /* volume label */
+struct exfat_entry_label /* volume label */
{
uint8_t type; /* EXFAT_ENTRY_LABEL */
uint8_t length; /* number of characters */
#define EXFAT_ATTRIB_DIR 0x10
#define EXFAT_ATTRIB_ARCH 0x20
-struct exfat_file /* file or directory */
+struct exfat_entry_meta1 /* file or directory info (part 1) */
{
uint8_t type; /* EXFAT_ENTRY_FILE */
uint8_t continuations;
#define EXFAT_FLAG_FRAGMENTED 1
#define EXFAT_FLAG_CONTIGUOUS 3
-struct exfat_file_info /* file or directory info */
+struct exfat_entry_meta2 /* file or directory info (part 2) */
{
uint8_t type; /* EXFAT_ENTRY_FILE_INFO */
uint8_t flag; /* fragmented or contiguous */
le64_t size; /* in bytes, equals to real_size */
};
-struct exfat_file_name /* file or directory name */
+struct exfat_entry_name /* file or directory name */
{
uint8_t type; /* EXFAT_ENTRY_FILE_NAME */
uint8_t __unknown;
}
static void init_node_meta1(struct exfat_node* node,
- const struct exfat_file* meta1)
+ const struct exfat_entry_meta1* meta1)
{
node->flags = le16_to_cpu(meta1->attrib);
node->mtime = exfat_exfat2unix(meta1->mdate, meta1->mtime);
}
static void init_node_meta2(struct exfat_node* node,
- const struct exfat_file_info* meta2)
+ const struct exfat_entry_meta2* meta2)
{
node->size = le64_to_cpu(meta2->size);
node->start_cluster = le32_to_cpu(meta2->start_cluster);
struct exfat_node** node, struct iterator* it)
{
const struct exfat_entry* entry;
- const struct exfat_file* file;
- const struct exfat_file_info* file_info;
- const struct exfat_file_name* file_name;
- const struct exfat_upcase* upcase;
- const struct exfat_bitmap* bitmap;
- const struct exfat_label* label;
+ const struct exfat_entry_meta1* meta1;
+ const struct exfat_entry_meta2* meta2;
+ const struct exfat_entry_name* file_name;
+ const struct exfat_entry_upcase* upcase;
+ const struct exfat_entry_bitmap* bitmap;
+ const struct exfat_entry_label* label;
uint8_t continuations = 0;
le16_t* namep = NULL;
uint16_t reference_checksum = 0;
continuations);
goto error;
}
- file = (const struct exfat_file*) entry;
- continuations = file->continuations;
+ meta1 = (const struct exfat_entry_meta1*) entry;
+ continuations = meta1->continuations;
/* each file entry must have at least 2 continuations:
info and name */
if (continuations < 2)
exfat_error("too few continuations (%hhu)", continuations);
return -EIO;
}
- reference_checksum = le16_to_cpu(file->checksum);
- actual_checksum = exfat_start_checksum(file);
+ reference_checksum = le16_to_cpu(meta1->checksum);
+ actual_checksum = exfat_start_checksum(meta1);
*node = allocate_node();
if (*node == NULL)
return -ENOMEM;
/* new node has zero reference counter */
(*node)->entry_cluster = it->cluster;
(*node)->entry_offset = it->offset % CLUSTER_SIZE(*ef->sb);
- init_node_meta1(*node, file);
+ init_node_meta1(*node, meta1);
namep = (*node)->name;
break;
continuations);
goto error;
}
- file_info = (const struct exfat_file_info*) entry;
- init_node_meta2(*node, file_info);
+ meta2 = (const struct exfat_entry_meta2*) entry;
+ init_node_meta2(*node, meta2);
actual_checksum = exfat_add_checksum(entry, actual_checksum);
/* There are two fields that contain file size. Maybe they plan
to add compression support in the future and one of those
fields is visible (uncompressed) size and the other is real
(compressed) size. Anyway, currently it looks like exFAT does
not support compression and both fields must be equal. */
- if (le64_to_cpu(file_info->real_size) != (*node)->size)
+ if (le64_to_cpu(meta2->real_size) != (*node)->size)
{
exfat_error("real size does not equal to size "
"(%"PRIu64" != %"PRIu64")",
- le64_to_cpu(file_info->real_size), (*node)->size);
+ le64_to_cpu(meta2->real_size), (*node)->size);
goto error;
}
/* directories must be aligned on at cluster boundary */
exfat_error("unexpected continuation");
goto error;
}
- file_name = (const struct exfat_file_name*) entry;
+ file_name = (const struct exfat_entry_name*) entry;
actual_checksum = exfat_add_checksum(entry, actual_checksum);
memcpy(namep, file_name->name, EXFAT_ENAME_MAX * sizeof(le16_t));
case EXFAT_ENTRY_UPCASE:
if (ef->upcase != NULL)
break;
- upcase = (const struct exfat_upcase*) entry;
+ upcase = (const struct exfat_entry_upcase*) entry;
if (CLUSTER_INVALID(le32_to_cpu(upcase->start_cluster)))
{
exfat_error("invalid cluster in upcase table");
break;
case EXFAT_ENTRY_BITMAP:
- bitmap = (const struct exfat_bitmap*) entry;
+ bitmap = (const struct exfat_entry_bitmap*) entry;
if (CLUSTER_INVALID(le32_to_cpu(bitmap->start_cluster)))
{
exfat_error("invalid cluster in clusters bitmap");
break;
case EXFAT_ENTRY_LABEL:
- label = (const struct exfat_label*) entry;
+ label = (const struct exfat_entry_label*) entry;
if (label->length > EXFAT_ENAME_MAX)
{
exfat_error("too long label (%hhu chars)", label->length);
cluster_t cluster;
off_t offset;
off_t meta1_offset, meta2_offset;
- struct exfat_file meta1;
- struct exfat_file_info meta2;
+ struct exfat_entry_meta1 meta1;
+ struct exfat_entry_meta2 meta2;
if (ef->ro)
exfat_bug("unable to flush node to read-only FS");
const le16_t* name, cluster_t cluster, off_t offset, uint16_t attrib)
{
struct exfat_node* node;
- struct exfat_file meta1;
- struct exfat_file_info meta2;
+ struct exfat_entry_meta1 meta1;
+ struct exfat_entry_meta2 meta2;
const size_t name_length = utf16_length(name);
const int name_entries = DIV_ROUND_UP(name_length, EXFAT_ENAME_MAX);
int i;
ef->fd);
for (i = 0; i < name_entries; i++)
{
- struct exfat_file_name name_entry = {EXFAT_ENTRY_FILE_NAME, 0};
+ struct exfat_entry_name name_entry = {EXFAT_ENTRY_FILE_NAME, 0};
memcpy(name_entry.name, node->name + i * EXFAT_ENAME_MAX,
EXFAT_ENAME_MAX * sizeof(le16_t));
next_entry(ef, dir, &cluster, &offset);
struct exfat_node* node, const le16_t* name, cluster_t new_cluster,
off_t new_offset)
{
- struct exfat_file meta1;
- struct exfat_file_info meta2;
+ struct exfat_entry_meta1 meta1;
+ struct exfat_entry_meta2 meta2;
cluster_t old_cluster = node->entry_cluster;
off_t old_offset = node->entry_offset;
const size_t name_length = utf16_length(name);
for (i = 0; i < name_entries; i++)
{
- struct exfat_file_name name_entry = {EXFAT_ENTRY_FILE_NAME, 0};
+ struct exfat_entry_name name_entry = {EXFAT_ENTRY_FILE_NAME, 0};
memcpy(name_entry.name, name + i * EXFAT_ENAME_MAX,
EXFAT_ENAME_MAX * sizeof(le16_t));
next_entry(ef, dir, &new_cluster, &new_offset);