Xenomai  3.0.5
registry.h
1 /*
2  * Copyright (C) 2008 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 
19 #ifndef _COPPERPLATE_REGISTRY_H
20 #define _COPPERPLATE_REGISTRY_H
21 
22 #include <sys/types.h>
23 #include <pthread.h>
24 #include <fcntl.h>
25 #include <boilerplate/list.h>
26 #include <boilerplate/hash.h>
27 #include <boilerplate/obstack.h>
28 
29 struct fsobj;
30 
31 #define REGISTRY_SHARED 1
32 #define REGISTRY_ANON 2
33 
34 #ifdef CONFIG_XENO_REGISTRY
35 
36 struct registry_operations {
37  int (*open)(struct fsobj *fsobj, void *priv);
38  int (*release)(struct fsobj *fsobj, void *priv);
39  ssize_t (*read)(struct fsobj *fsobj,
40  char *buf, size_t size, off_t offset,
41  void *priv);
42  ssize_t (*write)(struct fsobj *fsobj,
43  const char *buf, size_t size, off_t offset,
44  void *priv);
45 };
46 
47 struct regfs_dir;
48 
49 struct fsobj {
50  pthread_mutex_t lock;
51  char *path;
52  const char *basename;
53  int mode;
54  size_t privsz;
55  struct regfs_dir *dir;
56  struct timespec ctime;
57  struct timespec mtime;
58  const struct registry_operations *ops;
59  struct pvholder link;
60  struct pvhashobj hobj;
61 };
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 int registry_add_dir(const char *fmt, ...);
68 
69 int registry_init_file(struct fsobj *fsobj,
70  const struct registry_operations *ops,
71  size_t privsz);
72 
73 int registry_add_file(struct fsobj *fsobj,
74  int mode,
75  const char *fmt, ...);
76 
77 void registry_destroy_file(struct fsobj *fsobj);
78 
79 void registry_touch_file(struct fsobj *fsobj);
80 
81 int __registry_pkg_init(const char *arg0,
82  char *mountpt,
83  int flags);
84 
85 int registry_pkg_init(const char *arg0,
86  int flags);
87 
88 void registry_pkg_destroy(void);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #else /* !CONFIG_XENO_REGISTRY */
95 
96 struct fsobj {
97 };
98 
99 struct registry_operations {
100 };
101 
102 static inline
103 int registry_add_dir(const char *fmt, ...)
104 {
105  return 0;
106 }
107 
108 static inline
109 void registry_init_file(struct fsobj *fsobj,
110  const struct registry_operations *ops,
111  size_t privsz)
112 {
113 }
114 
115 static inline
116 int registry_add_file(struct fsobj *fsobj,
117  int mode,
118  const char *fmt, ...)
119 {
120  return 0;
121 }
122 
123 static inline
124 void registry_destroy_file(struct fsobj *fsobj)
125 {
126 }
127 
128 static inline
129 void registry_touch_file(struct fsobj *fsobj)
130 {
131 }
132 
133 static inline
134 int __registry_pkg_init(const char *arg0,
135  char *mountpt, int flags)
136 {
137  return 0;
138 }
139 
140 static inline
141 int registry_pkg_init(const char *arg0,
142  int flags)
143 {
144  return 0;
145 }
146 
147 static inline
148 void registry_pkg_destroy(void)
149 {
150 }
151 
152 #endif /* !CONFIG_XENO_REGISTRY */
153 
154 #endif /* !_COPPERPLATE_REGISTRY_H */