Xenomai 3.3.2
Loading...
Searching...
No Matches
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
29struct fsobj;
30
31#define REGISTRY_SHARED 1
32#define REGISTRY_ANON 2
33
34#ifdef CONFIG_XENO_REGISTRY
35
36struct 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
47struct regfs_dir;
48
49struct 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
64extern "C" {
65#endif
66
67int registry_add_dir(const char *fmt, ...);
68
69int registry_init_file(struct fsobj *fsobj,
70 const struct registry_operations *ops,
71 size_t privsz);
72
73int registry_add_file(struct fsobj *fsobj,
74 int mode,
75 const char *fmt, ...);
76
77void registry_destroy_file(struct fsobj *fsobj);
78
79void registry_touch_file(struct fsobj *fsobj);
80
81int __registry_pkg_init(const char *arg0,
82 char *mountpt,
83 int flags);
84
85int registry_pkg_init(const char *arg0,
86 int flags);
87
88void registry_pkg_destroy(void);
89
90#ifdef __cplusplus
91}
92#endif
93
94#else /* !CONFIG_XENO_REGISTRY */
95
96struct fsobj {
97};
98
99struct registry_operations {
100};
101
102static inline
103int registry_add_dir(const char *fmt, ...)
104{
105 return 0;
106}
107
108static inline
109void registry_init_file(struct fsobj *fsobj,
110 const struct registry_operations *ops,
111 size_t privsz)
112{
113}
114
115static inline
116int registry_add_file(struct fsobj *fsobj,
117 int mode,
118 const char *fmt, ...)
119{
120 return 0;
121}
122
123static inline
124void registry_destroy_file(struct fsobj *fsobj)
125{
126}
127
128static inline
129void registry_touch_file(struct fsobj *fsobj)
130{
131}
132
133static inline
134int __registry_pkg_init(const char *arg0,
135 char *mountpt, int flags)
136{
137 return 0;
138}
139
140static inline
141int registry_pkg_init(const char *arg0,
142 int flags)
143{
144 return 0;
145}
146
147static inline
148void registry_pkg_destroy(void)
149{
150}
151
152#endif /* !CONFIG_XENO_REGISTRY */
153
154#endif /* !_COPPERPLATE_REGISTRY_H */