shithub: lwext4

Download patch

ref: fc60a1283de27fd5c2fe02b7b307eefc66fb2a63
parent: 9f0a68086c918425a16f4a848c92150ca6c4b402
author: root <[email protected]>
date: Tue Sep 29 08:56:47 EDT 2015

CONFIG_HAVE_OWN_OFLAGS introduced.(In case you want to use those unistd definitions from your OS.)
ext4_dir_entry_rewind introduced.

--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -2180,7 +2180,10 @@
 	return r;
 }
 
-int ext4_dir_close(ext4_dir *d) { return ext4_fclose(&d->f); }
+int ext4_dir_close(ext4_dir *d)
+{
+    return ext4_fclose(&d->f);
+}
 
 const ext4_direntry *ext4_dir_entry_next(ext4_dir *d)
 {
@@ -2223,6 +2226,11 @@
 Finish:
 	EXT4_MP_UNLOCK(d->f.mp);
 	return de;
+}
+
+void ext4_dir_entry_rewind(ext4_dir *d)
+{
+    d->next_off = 0;
 }
 
 /**
--- a/lwext4/ext4.h
+++ b/lwext4/ext4.h
@@ -47,46 +47,52 @@
 
 /********************************FILE OPEN FLAGS*****************************/
 
-#ifndef O_RDONLY
-#define O_RDONLY 00
-#endif
+#ifdef CONFIG_HAVE_OWN_OFLAGS
 
-#ifndef O_WRONLY
-#define O_WRONLY 01
-#endif
+ #ifndef O_RDONLY
+ #define O_RDONLY 00
+ #endif
 
-#ifndef O_RDWR
-#define O_RDWR 02
-#endif
+ #ifndef O_WRONLY
+ #define O_WRONLY 01
+ #endif
 
-#ifndef O_CREAT
-#define O_CREAT 0100
-#endif
+ #ifndef O_RDWR
+ #define O_RDWR 02
+ #endif
 
-#ifndef O_EXCL
-#define O_EXCL 0200
-#endif
+ #ifndef O_CREAT
+ #define O_CREAT 0100
+ #endif
 
-#ifndef O_TRUNC
-#define O_TRUNC 01000
-#endif
+ #ifndef O_EXCL
+ #define O_EXCL 0200
+ #endif
 
-#ifndef O_APPEND
-#define O_APPEND 02000
-#endif
+ #ifndef O_TRUNC
+ #define O_TRUNC 01000
+ #endif
 
+ #ifndef O_APPEND
+ #define O_APPEND 02000
+ #endif
+
 /********************************FILE SEEK FLAGS*****************************/
 
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
+ #ifndef SEEK_SET
+ #define SEEK_SET 0
+ #endif
 
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
+ #ifndef SEEK_CUR
+ #define SEEK_CUR 1
+ #endif
 
-#ifndef SEEK_END
-#define SEEK_END 2
+ #ifndef SEEK_END
+ #define SEEK_END 2
+ #endif
+
+#else
+ #include <unistd.h>
 #endif
 
 /********************************OS LOCK INFERFACE***************************/
@@ -384,6 +390,10 @@
  * @param   id entry id
  * @return  directory entry id (NULL if no entry)*/
 const ext4_direntry *ext4_dir_entry_next(ext4_dir *d);
+
+/**@brief   Rewine directory entry offset.
+ * @param   d directory handle*/
+void ext4_dir_entry_rewind(ext4_dir *d);
 
 #endif /* EXT4_H_ */
 
--- a/lwext4/ext4_config.h
+++ b/lwext4/ext4_config.h
@@ -137,6 +137,11 @@
 #define CONFIG_EXT4_MOUNTPOINTS_COUNT 2
 #endif
 
+/**@brief   Include open flags from ext4_errno or standard library.*/
+#ifndef CONFIG_HAVE_OWN_OFLAGS
+#define CONFIG_HAVE_OWN_OFLAGS 0
+#endif
+
 #endif /* EXT4_CONFIG_H_ */
 
 /**