diff mbox series

[12/17] fs: fat: remember the starting cluster number of directory

Message ID 20180720025723.6736-13-takahiro.akashi@linaro.org
State Superseded
Headers show
Series fs: fat: extend FAT write operations | expand

Commit Message

AKASHI Takahiro July 20, 2018, 2:57 a.m. UTC
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>
---
 fs/fat/fat.c  | 2 ++
 include/fat.h | 1 +
 2 files changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 9bafc3a40c..ade5264551 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -639,6 +639,7 @@  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;
@@ -674,6 +675,7 @@  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;
diff --git a/include/fat.h b/include/fat.h
index bc0f77abb5..295da0f243 100644
--- a/include/fat.h
+++ b/include/fat.h
@@ -197,6 +197,7 @@  static inline u32 sect_to_clust(fsdata *fsdata, int sect)
 
 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 */