OSDN Git Service

Interpret version field as a structure for convenience.
authorrelan <relan@users.noreply.github.com>
Tue, 9 Nov 2010 18:58:13 +0000 (18:58 +0000)
committerrelan <relan@users.noreply.github.com>
Mon, 24 Aug 2015 05:26:12 +0000 (08:26 +0300)
libexfat/exfatfs.h
libexfat/mount.c
sbdump/main.c

index d9a197c..c933dae 100644 (file)
@@ -44,7 +44,12 @@ struct exfat_super_block
        le32_t cluster_count;                   /* 0x5C total clusters count */
        le32_t rootdir_cluster;                 /* 0x60 first cluster of the root dir */
        le32_t volume_serial;                   /* 0x64 volume serial number */
-       le16_t version;                                 /* 0x68 FS version */
+       struct                                                  /* 0x68 FS version */
+       {
+               uint8_t minor;
+               uint8_t major;
+       }
+       version;
        le16_t volume_state;                    /* 0x6A volume state flags */
        uint8_t block_bits;                             /* 0x6C block size as (1 << n) */
        uint8_t bpc_bits;                               /* 0x6D blocks per cluster as (1 << n) */
index 730f2cd..cd3f98a 100644 (file)
@@ -96,7 +96,6 @@ static void parse_options(struct exfat* ef, const char* options)
 
 int exfat_mount(struct exfat* ef, const char* spec, const char* options)
 {
-       uint16_t fs_version;
        int rc;
 
        tzset();
@@ -128,13 +127,12 @@ int exfat_mount(struct exfat* ef, const char* spec, const char* options)
                exfat_error("exFAT file system is not found");
                return -EIO;
        }
-       fs_version = le16_to_cpu(ef->sb->version);
-       if (fs_version != 0x0100)
+       if (ef->sb->version.major != 1 || ef->sb->version.minor != 0)
        {
                close(ef->fd);
+               exfat_error("unsupported exFAT version: %hhu.%hhu",
+                               ef->sb->version.major, ef->sb->version.minor);
                free(ef->sb);
-               exfat_error("unsupported exFAT version: %hu.%hu",
-                               fs_version >> 8, fs_version & 0xff);
                return -EIO;
        }
        if (ef->sb->fat_count != 1)
index c87f1c5..68707be 100644 (file)
@@ -46,8 +46,8 @@ static void dump_sb(const struct exfat_super_block* sb)
                        le32_to_cpu(sb->rootdir_cluster));
        printf("Volume serial number    0x%08x\n",
                        le32_to_cpu(sb->volume_serial));
-       printf("FS version                     %hu.%hu\n",
-                       le16_to_cpu(sb->version) >> 8, le16_to_cpu(sb->version) & 0xff);
+       printf("FS version                     %hhu.%hhu\n",
+                       sb->version.major, sb->version.minor);
        printf("Volume state                0x%04hx\n",
                        le16_to_cpu(sb->volume_state));
        printf("Block size                %8u\n",