Xenomai  3.0-rc3
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 #include <copperplate/init.h>
29 
30 struct fsobj;
31 
32 #ifdef CONFIG_XENO_REGISTRY
33 
34 struct registry_operations {
35  int (*open)(struct fsobj *fsobj, void *priv);
36  int (*release)(struct fsobj *fsobj, void *priv);
37  ssize_t (*read)(struct fsobj *fsobj,
38  char *buf, size_t size, off_t offset,
39  void *priv);
40  ssize_t (*write)(struct fsobj *fsobj,
41  const char *buf, size_t size, off_t offset,
42  void *priv);
43 };
44 
45 struct regfs_dir;
46 
47 struct fsobj {
48  pthread_mutex_t lock;
49  char *path;
50  const char *basename;
51  int mode;
52  size_t privsz;
53  struct regfs_dir *dir;
54  struct timespec ctime;
55  struct timespec mtime;
56  const struct registry_operations *ops;
57  struct pvholder link;
58  struct pvhashobj hobj;
59 };
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 int registry_add_dir(const char *fmt, ...);
66 
67 int registry_init_file(struct fsobj *fsobj,
68  const struct registry_operations *ops,
69  size_t privsz);
70 
71 int registry_add_file(struct fsobj *fsobj,
72  int mode,
73  const char *fmt, ...);
74 
75 void registry_destroy_file(struct fsobj *fsobj);
76 
77 void registry_touch_file(struct fsobj *fsobj);
78 
79 int __registry_pkg_init(const char *arg0, char *mountpt, int shared_registry);
80 
81 int registry_pkg_init(const char *arg0);
82 
83 void registry_pkg_destroy(void);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #else /* !CONFIG_XENO_REGISTRY */
90 
91 struct fsobj {
92 };
93 
94 struct registry_operations {
95 };
96 
97 static inline
98 int registry_add_dir(const char *fmt, ...)
99 {
100  return 0;
101 }
102 
103 static inline
104 void registry_init_file(struct fsobj *fsobj,
105  const struct registry_operations *ops,
106  size_t privsz)
107 {
108 }
109 
110 static inline
111 int registry_add_file(struct fsobj *fsobj,
112  int mode,
113  const char *fmt, ...)
114 {
115  return 0;
116 }
117 
118 static inline
119 void registry_destroy_file(struct fsobj *fsobj)
120 {
121 }
122 
123 static inline
124 void registry_touch_file(struct fsobj *fsobj)
125 {
126 }
127 
128 static inline
129 int __registry_pkg_init(const char *arg0, char *mountpt, int shared_registry)
130 {
131  return 0;
132 }
133 
134 static inline
135 int registry_pkg_init(const char *arg0)
136 {
137  return 0;
138 }
139 
140 static inline
141 void registry_pkg_destroy(void)
142 {
143 }
144 
145 #endif /* !CONFIG_XENO_REGISTRY */
146 
147 #endif /* !_COPPERPLATE_REGISTRY_H */