fs: fat: remember the starting cluster number of directory
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Tue, 11 Sep 2018 06:59:09 +0000 (15:59 +0900)
committerAlexander Graf <agraf@suse.de>
Sun, 23 Sep 2018 19:55:29 +0000 (21:55 +0200)
The starting cluster number of directory is needed to initialize ".."
(parent directory) entry when creating a new directory.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
fs/fat/fat.c

index 6d7012c84159d14b66f7d7dbd7f6f56a18336676..73ffdeae63ebb123bf206151ed6c7e27650222e1 100644 (file)
@@ -631,6 +631,7 @@ static int get_fs_info(fsdata *mydata)
 
 typedef struct {
        fsdata    *fsdata;        /* filesystem parameters */
+       unsigned   start_clust;   /* first cluster */
        unsigned   clust;         /* current cluster */
        unsigned   next_clust;    /* next cluster if remaining == 0 */
        int        last_cluster;  /* set once we've read last cluster */
@@ -663,6 +664,7 @@ static int fat_itr_root(fat_itr *itr, fsdata *fsdata)
                return -ENXIO;
 
        itr->fsdata = fsdata;
+       itr->start_clust = 0;
        itr->clust = fsdata->root_cluster;
        itr->next_clust = fsdata->root_cluster;
        itr->dent = NULL;
@@ -698,6 +700,7 @@ static void fat_itr_child(fat_itr *itr, fat_itr *parent)
        assert(fat_itr_isdir(parent));
 
        itr->fsdata = parent->fsdata;
+       itr->start_clust = clustnum;
        if (clustnum > 0) {
                itr->clust = clustnum;
                itr->next_clust = clustnum;