diff options
author | relan <relan@users.noreply.github.com> | 2014-07-08 12:05:07 +0000 |
---|---|---|
committer | relan <relan@users.noreply.github.com> | 2015-08-24 08:26:16 +0300 |
commit | 5119f7ac553bc41077c9c0f6e10ad9231ecbe451 (patch) | |
tree | f753c060d24995b29c1d56c0bb3daeb04ab0168c | |
parent | 770484564e0153caeb23cdeaa8a47afee4c4f1cd (diff) | |
download | android_external_exfat-5119f7ac553bc41077c9c0f6e10ad9231ecbe451.tar.gz android_external_exfat-5119f7ac553bc41077c9c0f6e10ad9231ecbe451.tar.bz2 android_external_exfat-5119f7ac553bc41077c9c0f6e10ad9231ecbe451.zip |
Rename real_size to valid_size and add comment about this field.
-rw-r--r-- | libexfat/exfatfs.h | 4 | ||||
-rw-r--r-- | libexfat/node.c | 22 |
2 files changed, 14 insertions, 12 deletions
diff --git a/libexfat/exfatfs.h b/libexfat/exfatfs.h index a436daa..503f251 100644 --- a/libexfat/exfatfs.h +++ b/libexfat/exfatfs.h @@ -153,10 +153,10 @@ struct exfat_entry_meta2 /* file or directory info (part 2) */ uint8_t name_length; le16_t name_hash; le16_t __unknown2; - le64_t real_size; /* in bytes, equals to size */ + le64_t valid_size; /* in bytes, less or equal to size */ uint8_t __unknown3[4]; le32_t start_cluster; - le64_t size; /* in bytes, equals to real_size */ + le64_t size; /* in bytes */ } PACKED; STATIC_ASSERT(sizeof(struct exfat_entry_meta2) == 32); diff --git a/libexfat/node.c b/libexfat/node.c index f3207fb..8dd946f 100644 --- a/libexfat/node.c +++ b/libexfat/node.c @@ -194,7 +194,7 @@ static const struct exfat_entry* get_entry_ptr(const struct exfat* ef, } static bool check_node(const struct exfat_node* node, uint16_t actual_checksum, - uint16_t reference_checksum, uint64_t real_size) + uint16_t reference_checksum, uint64_t valid_size) { char buffer[UTF8_BYTES(EXFAT_NAME_MAX) + 1]; @@ -211,14 +211,16 @@ static bool check_node(const struct exfat_node* node, uint16_t actual_checksum, } /* - It's unclear what is real_size field needed for. It usually equals to - the size but may contain any value less than size (including 0). + exFAT does not support sparse files but allows files with uninitialized + clusters. For such files valid_size means initialized data size and + cannot be greater than file size. See SetFileValidData() function + description in MSDN. */ - if (real_size > node->size) + if (valid_size > node->size) { exfat_get_name(node, buffer, sizeof(buffer) - 1); - exfat_error("'%s' has real size (%"PRIu64") greater than size " - "(%"PRIu64")", buffer, real_size, node->size); + exfat_error("'%s' has valid size (%"PRIu64") greater than size " + "(%"PRIu64")", buffer, valid_size, node->size); return false; } @@ -244,7 +246,7 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, le16_t* namep = NULL; uint16_t reference_checksum = 0; uint16_t actual_checksum = 0; - uint64_t real_size = 0; + uint64_t valid_size = 0; *node = NULL; @@ -315,7 +317,7 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, } init_node_meta2(*node, meta2); actual_checksum = exfat_add_checksum(entry, actual_checksum); - real_size = le64_to_cpu(meta2->real_size); + valid_size = le64_to_cpu(meta2->valid_size); /* empty files must be marked as non-contiguous */ if ((*node)->size == 0 && (meta2->flags & EXFAT_FLAG_CONTIGUOUS)) { @@ -351,7 +353,7 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, if (--continuations == 0) { if (!check_node(*node, actual_checksum, reference_checksum, - real_size)) + valid_size)) goto error; if (fetch_next_entry(ef, parent, it) != 0) goto error; @@ -630,7 +632,7 @@ int exfat_flush_node(struct exfat* ef, struct exfat_node* node) } if (meta2.type != EXFAT_ENTRY_FILE_INFO) exfat_bug("invalid type of meta2: 0x%hhx", meta2.type); - meta2.size = meta2.real_size = cpu_to_le64(node->size); + meta2.size = meta2.valid_size = cpu_to_le64(node->size); meta2.start_cluster = cpu_to_le32(node->start_cluster); meta2.flags = EXFAT_FLAG_ALWAYS1; /* empty files must not be marked as contiguous */ |