shithub: lwext4

Download patch

ref: 241ba2c8b4e76232dea9a44f3478ee6408ee41c1
parent: 8cb6e4527381e9d50aef3b9ffb013026afb9a51f
author: root <ngkaho1234@gmail.com>
date: Sun Sep 20 18:47:37 EDT 2015

FIX: the parent directory reference in child directory inode, a.k.a '..' dirent is not correctly reset during rename.

--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -253,7 +253,7 @@
 
 			} else {
 #if CONFIG_DIR_INDEX_ENABLE
-				rc = ext4_dir_dx_reset_parent_inode(parent,
+				rc = ext4_dir_dx_reset_parent_inode(child,
 						parent->index);
 				if (rc != EOK)
 					return rc;
@@ -1218,6 +1218,25 @@
 	ext4_fs_put_inode_ref(&ref);
 	return r;
 
+}
+
+int ext4_fopen_all(ext4_file *f, const char *path, int flags)
+{
+	struct ext4_mountpoint *mp = ext4_get_mount(path);
+	int r;
+	int filetype;
+
+	if (!mp)
+		return ENOENT;
+
+	filetype = EXT4_DIRECTORY_FILETYPE_UNKNOWN;
+
+	EXT4_MP_LOCK(mp);
+	ext4_block_cache_write_back(mp->fs.bdev, 1);
+	r = ext4_generic_open2(f, path, flags, filetype, 0, 0);
+	ext4_block_cache_write_back(mp->fs.bdev, 0);
+	EXT4_MP_UNLOCK(mp);
+	return r;
 }
 
 int ext4_ftruncate(ext4_file *f, uint64_t size)