shithub: lwext4

Download patch

ref: cbf74d6c41613815366711a6a5322033c7c0ccc1
parent: 4f30abc8be7aeebd0e2276623d37598b0ad626e4
author: gkostka <kostka.grzegorz@gmail.com>
date: Tue Jun 3 06:28:32 EDT 2014

Added OS locks setup function.

--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -68,7 +68,7 @@
     char name[32];
 
     /**@brief   Os dependent lock/unlock functions.*/
-    struct ext4_lock *os_locks;
+    const struct ext4_lock *os_locks;
 
     /**@brief   Ext4 filesystem internals.*/
     struct ext4_fs fs;
@@ -438,7 +438,6 @@
             mp = &_mp[i];
             break;
         }
-
     }
     if(!mp)
         return ENOENT;
@@ -457,6 +456,25 @@
     memcpy(stats->volume_name, mp->fs.sb.volume_name, 16);
     EXT4_MP_UNLOCK(mp);
 
+    return EOK;
+}
+
+int ext4_mount_setup_locks(const char * mount_point,
+    const struct ext4_lock *locks)
+{
+    uint32_t i;
+    struct ext4_mountpoint    *mp = 0;
+
+    for (i = 0; i < CONFIG_EXT4_MOUNTPOINTS_COUNT; ++i) {
+        if(!strcmp(_mp[i].name, mount_point)){
+            mp = &_mp[i];
+            break;
+        }
+    }
+    if(!mp)
+        return ENOENT;
+
+    mp->os_locks = locks;
     return EOK;
 }
 
--- a/lwext4/ext4.h
+++ b/lwext4/ext4.h
@@ -201,6 +201,12 @@
 int ext4_mount_point_stats(const char *mount_point,
     struct ext4_mount_stats *stats);
 
+/**@brief   Setup OS lock routines.
+ * @param   mount_point mount path
+ * @param   locks - lock and unlock functions
+ * @return  standard error code */
+int ext4_mount_setup_locks(const char * mount_point,
+    const struct ext4_lock *locks);
 
 /**@brief   Enable/disable write back cache mode.
  * @warning Default model of cache is write trough. It means that when You do: