summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <ngkaho1234@gmail.com>2015-09-29 12:56:47 +0000
committerroot <ngkaho1234@gmail.com>2015-09-29 12:56:47 +0000
commitfc60a1283de27fd5c2fe02b7b307eefc66fb2a63 (patch)
tree0fd623fb52f50ac2c57a2ef0d9a92c886d9c39a8
parent9f0a68086c918425a16f4a848c92150ca6c4b402 (diff)
CONFIG_HAVE_OWN_OFLAGS introduced.(In case you want to use those unistd definitions from your OS.)
ext4_dir_entry_rewind introduced.
-rw-r--r--lwext4/ext4.c10
-rw-r--r--lwext4/ext4.h68
-rw-r--r--lwext4/ext4_config.h5
3 files changed, 53 insertions, 30 deletions
diff --git a/lwext4/ext4.c b/lwext4/ext4.c
index 2bb783f..a71389a 100644
--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -2180,7 +2180,10 @@ int ext4_dir_open(ext4_dir *d, const char *path)
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)
{
@@ -2225,6 +2228,11 @@ Finish:
return de;
}
+void ext4_dir_entry_rewind(ext4_dir *d)
+{
+ d->next_off = 0;
+}
+
/**
* @}
*/
diff --git a/lwext4/ext4.h b/lwext4/ext4.h
index fb65378..9702031 100644
--- 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
+ #endif
-#ifndef SEEK_END
-#define SEEK_END 2
+#else
+ #include <unistd.h>
#endif
/********************************OS LOCK INFERFACE***************************/
@@ -385,6 +391,10 @@ int ext4_dir_close(ext4_dir *d);
* @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_ */
/**
diff --git a/lwext4/ext4_config.h b/lwext4/ext4_config.h
index 020c4a9..65c8e10 100644
--- 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_ */
/**