OSDN Git Service

Rename entries structures for consistency.
authorrelan <relan@users.noreply.github.com>
Thu, 14 Jan 2010 19:48:42 +0000 (19:48 +0000)
committerrelan <relan@users.noreply.github.com>
Mon, 24 Aug 2015 05:26:11 +0000 (08:26 +0300)
libexfat/exfat.h
libexfat/exfatfs.h
libexfat/node.c
libexfat/utils.c

index a51b922..3ae96ad 100644 (file)
@@ -136,10 +136,10 @@ void exfat_stat(const struct exfat* ef, const struct exfat_node* node,
 time_t exfat_exfat2unix(le16_t date, le16_t time);
 void exfat_unix2exfat(time_t unix_time, le16_t* date, le16_t* time);
 void exfat_get_name(const struct exfat_node* node, char* buffer, size_t n);
-uint16_t exfat_start_checksum(const struct exfat_file* entry);
+uint16_t exfat_start_checksum(const struct exfat_entry_meta1* entry);
 uint16_t exfat_add_checksum(const void* entry, uint16_t sum);
-le16_t exfat_calc_checksum(const struct exfat_file* meta1,
-               const struct exfat_file_info* meta2, const le16_t* name);
+le16_t exfat_calc_checksum(const struct exfat_entry_meta1* meta1,
+               const struct exfat_entry_meta2* meta2, const le16_t* name);
 le16_t exfat_calc_name_hash(const struct exfat* ef, const le16_t* name);
 
 int utf16_to_utf8(char* output, const le16_t* input, size_t outsize,
index d0df276..4a5c7dd 100644 (file)
@@ -74,7 +74,7 @@ struct exfat_entry                                    /* common container for all entries */
 
 #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];
@@ -82,7 +82,7 @@ struct exfat_bitmap                                   /* allocated clusters bitmap */
        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];
@@ -92,7 +92,7 @@ struct exfat_upcase                                   /* upper case translation table */
        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 */
@@ -106,7 +106,7 @@ struct exfat_label                                  /* volume label */
 #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;
@@ -124,7 +124,7 @@ struct exfat_file                                   /* file or directory */
 #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 */
@@ -138,7 +138,7 @@ struct exfat_file_info                              /* file or directory info */
        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;
index 987434d..7bc2177 100644 (file)
@@ -125,7 +125,7 @@ static struct exfat_node* allocate_node(void)
 }
 
 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);
@@ -133,7 +133,7 @@ static void init_node_meta1(struct exfat_node* node,
 }
 
 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);
@@ -150,12 +150,12 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
                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;
@@ -188,8 +188,8 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
                                                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)
@@ -197,15 +197,15 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
                                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;
 
@@ -216,19 +216,19 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
                                                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 */
@@ -251,7 +251,7 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
                                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));
@@ -273,7 +273,7 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
                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");
@@ -301,7 +301,7 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
                        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");
@@ -331,7 +331,7 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
                        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);
@@ -451,8 +451,8 @@ void exfat_flush_node(struct exfat* ef, struct exfat_node* node)
        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");
@@ -642,8 +642,8 @@ static int write_entry(struct exfat* ef, struct exfat_node* dir,
                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;
@@ -681,7 +681,7 @@ static int write_entry(struct exfat* ef, struct exfat_node* dir,
                        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);
@@ -753,8 +753,8 @@ static void rename_entry(struct exfat* ef, struct exfat_node* dir,
                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);
@@ -784,7 +784,7 @@ static void rename_entry(struct exfat* ef, struct exfat_node* dir,
 
        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);
index fc951a1..232061d 100644 (file)
@@ -177,7 +177,7 @@ void exfat_get_name(const struct exfat_node* node, char* buffer, size_t n)
                exfat_bug("failed to convert name to UTF-8");
 }
 
-uint16_t exfat_start_checksum(const struct exfat_file* entry)
+uint16_t exfat_start_checksum(const struct exfat_entry_meta1* entry)
 {
        uint16_t sum = 0;
        int i;
@@ -197,8 +197,8 @@ uint16_t exfat_add_checksum(const void* entry, uint16_t sum)
        return sum;
 }
 
-le16_t exfat_calc_checksum(const struct exfat_file* meta1,
-               const struct exfat_file_info* meta2, const le16_t* name)
+le16_t exfat_calc_checksum(const struct exfat_entry_meta1* meta1,
+               const struct exfat_entry_meta2* meta2, const le16_t* name)
 {
        uint16_t checksum;
        const int name_entries = DIV_ROUND_UP(utf16_length(name), EXFAT_ENAME_MAX);
@@ -208,7 +208,7 @@ le16_t exfat_calc_checksum(const struct exfat_file* meta1,
        checksum = exfat_add_checksum(meta2, checksum);
        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));
                checksum = exfat_add_checksum(&name_entry, checksum);