Module: xenomai-forge
Branch: master
Commit: 944784028026abcb98d3bef114788700f5686404
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=944784028026abcb98d3bef114788700f5686404

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Oct 23 12:03:45 2013 +0200

copperplate/registry: expose file open(), release() to client code

---

 include/copperplate/registry.h |    2 ++
 lib/copperplate/registry.c     |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/include/copperplate/registry.h b/include/copperplate/registry.h
index 2a2a2ac..893bfb1 100644
--- a/include/copperplate/registry.h
+++ b/include/copperplate/registry.h
@@ -30,6 +30,8 @@ struct fsobj;
 #ifdef CONFIG_XENO_REGISTRY
 
 struct registry_operations {
+       int (*open)(struct fsobj *fsobj);
+       int (*release)(struct fsobj *fsobj);
        ssize_t (*read)(struct fsobj *fsobj,
                        char *buf, size_t size, off_t offset);
        ssize_t (*write)(struct fsobj *fsobj,
diff --git a/lib/copperplate/registry.c b/lib/copperplate/registry.c
index 4057143..67b5982 100644
--- a/lib/copperplate/registry.c
+++ b/lib/copperplate/registry.c
@@ -371,6 +371,32 @@ static int regfs_open(const char *path, struct 
fuse_file_info *fi)
        fsobj = container_of(hobj, struct fsobj, hobj);
        if (((fi->flags + 1) & (fsobj->mode + 1)) == 0)
                ret = -EACCES;
+       else if (fsobj->ops->open)
+               ret = __bt(fsobj->ops->open(fsobj));
+done:
+       read_unlock(&p->lock);
+
+       return __bt(ret);
+}
+
+static int regfs_release(const char *path, struct fuse_file_info *fi)
+{
+       struct regfs_data *p = regfs_get_context();
+       struct pvhashobj *hobj;
+       struct fsobj *fsobj;
+       int ret = 0;
+
+       read_lock_nocancel(&p->lock);
+
+       hobj = pvhash_search(&p->files, path, strlen(path));
+       if (hobj == NULL) {
+               ret = -ENOENT;
+               goto done;
+       }
+
+       fsobj = container_of(hobj, struct fsobj, hobj);
+       if (fsobj->ops->release)
+               ret = __bt(fsobj->ops->release(fsobj));
 done:
        read_unlock(&p->lock);
 
@@ -484,6 +510,7 @@ static struct fuse_operations regfs_opts = {
        .getattr        = regfs_getattr,
        .readdir        = regfs_readdir,
        .open           = regfs_open,
+       .release        = regfs_release,
        .read           = regfs_read,
        .write          = regfs_write,
        /* Those must be defined for writing to files too. */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to