OSDN Git Service

Recognize optional entries.
authorrelan <relan@users.noreply.github.com>
Sat, 11 Jul 2015 08:07:53 +0000 (11:07 +0300)
committerrelan <relan@users.noreply.github.com>
Mon, 24 Aug 2015 05:36:19 +0000 (08:36 +0300)
Memory cards formatted by Sony cameras have mysterious 0xe1 entries.
Looks like they can be safely ignored. So now if entry type is unknown
and has 0x20 flag set there will be a warning instead of error.

libexfat/exfatfs.h
libexfat/node.c

index 7d8f8bf..87b47b5 100644 (file)
@@ -69,6 +69,7 @@ STATIC_ASSERT(sizeof(struct exfat_super_block) == 512);
 
 #define EXFAT_ENTRY_VALID     0x80
 #define EXFAT_ENTRY_CONTINUED 0x40
+#define EXFAT_ENTRY_OPTIONAL  0x20
 
 #define EXFAT_ENTRY_BITMAP    (0x01 | EXFAT_ENTRY_VALID)
 #define EXFAT_ENTRY_UPCASE    (0x02 | EXFAT_ENTRY_VALID)
index 912b4fc..6e18c09 100644 (file)
@@ -454,11 +454,21 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
                        break;
 
                default:
-                       if (entry->type & EXFAT_ENTRY_VALID)
+                       if (!(entry->type & EXFAT_ENTRY_VALID))
+                               break; /* deleted entry, ignore it */
+                       if (!(entry->type & EXFAT_ENTRY_OPTIONAL))
                        {
-                               exfat_error("unknown entry type 0x%hhx", entry->type);
+                               exfat_error("unknown entry type %#hhx", entry->type);
                                goto error;
                        }
+                       /* optional entry, warn and skip */
+                       exfat_warn("unknown entry type %#hhx", entry->type);
+                       if (continuations == 0)
+                       {
+                               exfat_error("unexpected continuation");
+                               goto error;
+                       }
+                       --continuations;
                        break;
                }