OSDN Git Service

Fix searching for free slots in the root directory.
authorm4rkusxxl <m4rkusxxl@users.noreply.github.com>
Fri, 19 Jan 2018 06:44:43 +0000 (09:44 +0300)
committerrelan <relan@users.noreply.github.com>
Fri, 19 Jan 2018 06:44:43 +0000 (09:44 +0300)
When we need to place n entries and slot at position x is occupied, we
should check x+1 instead of jumping to x+n. Otherwise we may end up
putting new entries beyond a 0x00 entry, which Windows 10 interprets as
an end-of-directory mark and does not look farther.

libexfat/node.c

index b544bd9..2ba2313 100644 (file)
@@ -855,7 +855,8 @@ static int find_slot(struct exfat* ef, struct exfat_node* dir,
                                        free(dmap);
                                        return -EIO;
                                case -EINVAL:
-                                       /* slot is occupied, continue searching */
+                                       /* slot at (i-n) is occupied, go back and check (i-n+1) */
+                                       i -= contiguous - 1;
                                        contiguous = 0;
                                        break;
                                }