OSDN Git Service

Add __packed__ attribute to all on-disk structures definitions.
authorrelan <relan@users.noreply.github.com>
Wed, 9 Jun 2010 20:45:38 +0000 (20:45 +0000)
committerrelan <relan@users.noreply.github.com>
Mon, 24 Aug 2015 05:26:12 +0000 (08:26 +0300)
libexfat/exfatfs.h
libexfat/utils.c

index 5bc1f7a..d9a197c 100644 (file)
@@ -53,7 +53,8 @@ struct exfat_super_block
        uint8_t allocated_percent;              /* 0x70 percentage of allocated space */
        uint8_t __unused2[397];                 /* 0x71 always 0 */
        le16_t boot_signature;                  /* the value of 0xAA55 */
-};
+}
+__attribute__((__packed__));
 
 #define EXFAT_ENTRY_VALID     0x80
 #define EXFAT_ENTRY_CONTINUED 0x40
@@ -70,7 +71,8 @@ struct exfat_entry                                    /* common container for all entries */
 {
        uint8_t type;                                   /* any of EXFAT_ENTRY_xxx */
        uint8_t data[31];
-};
+}
+__attribute__((__packed__));
 
 #define EXFAT_ENAME_MAX 15
 
@@ -80,7 +82,8 @@ struct exfat_entry_bitmap                     /* allocated clusters bitmap */
        uint8_t __unknown1[19];
        le32_t start_cluster;
        le64_t size;                                    /* in bytes */
-};
+}
+__attribute__((__packed__));
 
 struct exfat_entry_upcase                      /* upper case translation table */
 {
@@ -90,14 +93,16 @@ struct exfat_entry_upcase                   /* upper case translation table */
        uint8_t __unknown2[12];
        le32_t start_cluster;
        le64_t size;                                    /* in bytes */
-};
+}
+__attribute__((__packed__));
 
 struct exfat_entry_label                       /* volume label */
 {
        uint8_t type;                                   /* EXFAT_ENTRY_LABEL */
        uint8_t length;                                 /* number of characters */
        le16_t name[EXFAT_ENAME_MAX];   /* in UTF-16LE */
-};
+}
+__attribute__((__packed__));
 
 #define EXFAT_ATTRIB_RO     0x01
 #define EXFAT_ATTRIB_HIDDEN 0x02
@@ -119,7 +124,8 @@ struct exfat_entry_meta1                    /* file or directory info (part 1) */
        uint8_t crtime_cs;                              /* creation time in cs (centiseconds) */
        uint8_t mtime_cs;                               /* latest modification time in cs */
        uint8_t __unknown2[10];
-};
+}
+__attribute__((__packed__));
 
 #define EXFAT_FLAG_FRAGMENTED 1
 #define EXFAT_FLAG_CONTIGUOUS 3
@@ -136,13 +142,15 @@ struct exfat_entry_meta2                  /* file or directory info (part 2) */
        uint8_t __unknown3[4];
        le32_t start_cluster;
        le64_t size;                                    /* in bytes, equals to real_size */
-};
+}
+__attribute__((__packed__));
 
 struct exfat_entry_name                                /* file or directory name */
 {
        uint8_t type;                                   /* EXFAT_ENTRY_FILE_NAME */
        uint8_t __unknown;
        le16_t name[EXFAT_ENAME_MAX];   /* in UTF-16LE */
-};
+}
+__attribute__((__packed__));
 
 #endif /* ifndef EXFATFS_H_INCLUDED */
index 232061d..5e71775 100644 (file)
@@ -78,7 +78,8 @@ union exfat_date
                uint16_t month : 4; /* 1-12 */
                uint16_t year  : 7; /* 1-127 (+1980) */
        };
-};
+}
+__attribute__((__packed__));
 
 union exfat_time
 {
@@ -89,7 +90,8 @@ union exfat_time
                uint16_t min    : 6; /* 0-59 */
                uint16_t hour   : 5; /* 0-23 */
        };
-};
+}
+__attribute__((__packed__));
 
 time_t exfat_exfat2unix(le16_t date, le16_t time)
 {