Add nffs compat with multiple fs

Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/9f731125
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9f731125
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9f731125

Branch: refs/heads/develop
Commit: 9f7311256c9a4814e44d18e1b3f2edce4af489df
Parents: 45e0416
Author: Fabio Utzig <[email protected]>
Authored: Thu Jan 5 20:36:12 2017 -0200
Committer: Fabio Utzig <[email protected]>
Committed: Thu Jan 12 10:51:46 2017 -0200

----------------------------------------------------------------------
 fs/nffs/src/nffs.c      | 2 +-
 fs/nffs/src/nffs_dir.c  | 5 +++++
 fs/nffs/src/nffs_file.c | 4 ++++
 fs/nffs/src/nffs_priv.h | 3 +++
 4 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f731125/fs/nffs/src/nffs.c
----------------------------------------------------------------------
diff --git a/fs/nffs/src/nffs.c b/fs/nffs/src/nffs.c
index eacec07..4475420 100644
--- a/fs/nffs/src/nffs.c
+++ b/fs/nffs/src/nffs.c
@@ -81,7 +81,7 @@ static int nffs_dirent_name(const struct fs_dirent 
*fs_dirent, size_t max_len,
   char *out_name, uint8_t *out_name_len);
 static int nffs_dirent_is_dir(const struct fs_dirent *fs_dirent);
 
-static struct fs_ops nffs_ops = {
+struct fs_ops nffs_ops = {
     .f_open = nffs_open,
     .f_close = nffs_close,
     .f_read = nffs_read,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f731125/fs/nffs/src/nffs_dir.c
----------------------------------------------------------------------
diff --git a/fs/nffs/src/nffs_dir.c b/fs/nffs/src/nffs_dir.c
index 7d5ce00..8cdefa9 100644
--- a/fs/nffs/src/nffs_dir.c
+++ b/fs/nffs/src/nffs_dir.c
@@ -21,6 +21,9 @@
 #include <string.h>
 #include "nffs_priv.h"
 #include "nffs/nffs.h"
+#include "fs/fs_if.h"
+
+struct fs_ops nffs_ops;
 
 static struct nffs_dir *
 nffs_dir_alloc(void)
@@ -74,6 +77,7 @@ nffs_dir_open(const char *path, struct nffs_dir **out_dir)
     dir->nd_parent_inode_entry = parent_inode_entry;
     nffs_inode_inc_refcnt(dir->nd_parent_inode_entry);
     memset(&dir->nd_dirent, 0, sizeof dir->nd_dirent);
+    dir->fops = &nffs_ops;
 
     *out_dir = dir;
 
@@ -104,6 +108,7 @@ nffs_dir_read(struct nffs_dir *dir, struct nffs_dirent 
**out_dirent)
     }
 
     nffs_inode_inc_refcnt(child);
+    dir->nd_dirent.fops = &nffs_ops;
     *out_dirent = &dir->nd_dirent;
 
     return 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f731125/fs/nffs/src/nffs_file.c
----------------------------------------------------------------------
diff --git a/fs/nffs/src/nffs_file.c b/fs/nffs/src/nffs_file.c
index e065926..c542a66 100644
--- a/fs/nffs/src/nffs_file.c
+++ b/fs/nffs/src/nffs_file.c
@@ -21,6 +21,9 @@
 #include <string.h>
 #include "nffs_priv.h"
 #include "nffs/nffs.h"
+#include "fs/fs_if.h"
+
+struct fs_ops nffs_ops;
 
 static struct nffs_file *
 nffs_file_alloc(void)
@@ -242,6 +245,7 @@ nffs_file_open(struct nffs_file **out_file, const char 
*path,
     }
     nffs_inode_inc_refcnt(file->nf_inode_entry);
     file->nf_access_flags = access_flags;
+    file->fops = &nffs_ops;
 
     *out_file = file;
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f731125/fs/nffs/src/nffs_priv.h
----------------------------------------------------------------------
diff --git a/fs/nffs/src/nffs_priv.h b/fs/nffs/src/nffs_priv.h
index c871962..50cbc85 100644
--- a/fs/nffs/src/nffs_priv.h
+++ b/fs/nffs/src/nffs_priv.h
@@ -171,6 +171,7 @@ struct nffs_block {
 };
 
 struct nffs_file {
+    struct fs_ops *fops;
     struct nffs_inode_entry *nf_inode_entry;
     uint32_t nf_offset;
     uint8_t nf_access_flags;
@@ -238,10 +239,12 @@ struct nffs_cache_inode {
 };
 
 struct nffs_dirent {
+    struct fs_ops *fops;
     struct nffs_inode_entry *nde_inode_entry;
 };
 
 struct nffs_dir {
+    struct fs_ops *fops;
     struct nffs_inode_entry *nd_parent_inode_entry;
     struct nffs_dirent nd_dirent;
 };

Reply via email to