}
__attribute__((__packed__));
-#define EXFAT_FLAG_FRAGMENTED 1
-#define EXFAT_FLAG_CONTIGUOUS 3
+#define EXFAT_FLAG_ALWAYS1 (1u << 0)
+#define EXFAT_FLAG_CONTIGUOUS (1u << 1)
struct exfat_entry_meta2 /* file or directory info (part 2) */
{
uint8_t type; /* EXFAT_ENTRY_FILE_INFO */
- uint8_t flag; /* fragmented or contiguous */
+ uint8_t flags; /* combination of EXFAT_FLAG_xxx */
uint8_t __unknown1;
uint8_t name_length;
le16_t name_hash;
node->size = le64_to_cpu(meta2->size);
node->start_cluster = le32_to_cpu(meta2->start_cluster);
node->fptr_cluster = node->start_cluster;
- if (meta2->flag == EXFAT_FLAG_CONTIGUOUS)
+ if (meta2->flags & EXFAT_FLAG_CONTIGUOUS)
node->flags |= EXFAT_ATTRIB_CONTIGUOUS;
}
goto error;
}
meta2 = (const struct exfat_entry_meta2*) entry;
+ if (meta2->flags & ~(EXFAT_FLAG_ALWAYS1 | EXFAT_FLAG_CONTIGUOUS))
+ {
+ exfat_error("unknown flags in meta2 (0x%hhx)", meta2->flags);
+ goto error;
+ }
init_node_meta2(*node, meta2);
actual_checksum = exfat_add_checksum(entry, actual_checksum);
/* There are two fields that contain file size. Maybe they plan
le64_to_cpu(meta2->real_size), (*node)->size);
goto error;
}
+ /* empty files must be marked as non-contiguous */
+ if ((*node)->size == 0 && (meta2->flags & EXFAT_FLAG_CONTIGUOUS))
+ {
+ exfat_error("empty file marked as contiguous (0x%hhx)",
+ meta2->flags);
+ goto error;
+ }
/* directories must be aligned on at cluster boundary */
if (((*node)->flags & EXFAT_ATTRIB_DIR) &&
(*node)->size % CLUSTER_SIZE(*ef->sb) != 0)
exfat_bug("invalid type of meta2: 0x%hhx", meta2.type);
meta2.size = meta2.real_size = cpu_to_le64(node->size);
meta2.start_cluster = cpu_to_le32(node->start_cluster);
- /* empty files must be marked as fragmented */
+ meta2.flags = EXFAT_FLAG_ALWAYS1;
+ /* empty files must not be marked as contiguous */
if (node->size != 0 && IS_CONTIGUOUS(*node))
- meta2.flag = EXFAT_FLAG_CONTIGUOUS;
- else
- meta2.flag = EXFAT_FLAG_FRAGMENTED;
+ meta2.flags |= EXFAT_FLAG_CONTIGUOUS;
/* name hash remains unchanged, no need to recalculate it */
meta1.checksum = exfat_calc_checksum(&meta1, &meta2, node->name);
memset(&meta2, 0, sizeof(meta2));
meta2.type = EXFAT_ENTRY_FILE_INFO;
- meta2.flag = EXFAT_FLAG_FRAGMENTED;
+ meta2.flags = EXFAT_FLAG_ALWAYS1;
meta2.name_length = name_length;
meta2.name_hash = exfat_calc_name_hash(ef, node->name);
meta2.start_cluster = cpu_to_le32(EXFAT_CLUSTER_FREE);