shithub: lwext4

Download patch

ref: 90ed580cfaf169c57bc1a3e2117a6f72184b36ec
parent: 4a137bb50e4645bd562a7b6662167e0708f4a428
author: root <ngkaho1234@gmail.com>
date: Wed Sep 30 05:48:58 EDT 2015

ext4_mount_point_stats should handle the path of files as well.

--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -450,18 +450,25 @@
 	return ext4_block_fini(mp->fs.bdev);
 }
 
+static struct ext4_mountpoint *ext4_get_mount(const char *path)
+{
+	int i;
+	for (i = 0; i < CONFIG_EXT4_MOUNTPOINTS_COUNT; ++i) {
+
+		if (!_mp[i].mounted)
+			continue;
+
+		if (!strncmp(_mp[i].name, path, strlen(_mp[i].name)))
+			return &_mp[i];
+	}
+	return 0;
+}
+
 int ext4_mount_point_stats(const char *mount_point,
 			   struct ext4_mount_stats *stats)
 {
-	uint32_t i;
-	struct ext4_mountpoint *mp = 0;
+	struct ext4_mountpoint *mp = ext4_get_mount(mount_point);
 
-	for (i = 0; i < CONFIG_EXT4_MOUNTPOINTS_COUNT; ++i) {
-		if (!strcmp(_mp[i].name, mount_point)) {
-			mp = &_mp[i];
-			break;
-		}
-	}
 	if (!mp)
 		return ENOENT;
 
@@ -502,20 +509,6 @@
 }
 
 /********************************FILE OPERATIONS*****************************/
-
-static struct ext4_mountpoint *ext4_get_mount(const char *path)
-{
-	int i;
-	for (i = 0; i < CONFIG_EXT4_MOUNTPOINTS_COUNT; ++i) {
-
-		if (!_mp[i].mounted)
-			continue;
-
-		if (!strncmp(_mp[i].name, path, strlen(_mp[i].name)))
-			return &_mp[i];
-	}
-	return 0;
-}
 
 static int ext4_path_check(const char *path, bool *is_goal)
 {