2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Krzysztof Dynowski <k.dynowski@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
22 * @author Krzysztof Dynowski (k.dynowski@samsung.com)
23 * @brief Vasum old API compatibility functions
26 #ifndef __CLIENT_WRAPPER_COMPAT__
27 #define __CLIENT_WRAPPER_COMPAT__
30 #include <sys/epoll.h>
33 typedef int (*fp_create_zone) (vsm_context_h ctx, const char *zone_name,
34 const char *template_name, int flag);
35 typedef int (*fp_destroy_zone) (vsm_context_h ctx, const char *zone_name,
37 typedef int (*fp_start_zone) (vsm_context_h ctx, const char *zone_name);
38 typedef int (*fp_shutdown_zone) (vsm_context_h ctx, const char *zone_name,
40 typedef int (*fp_lock_zone) (vsm_context_h ctx, const char *zone_name,
42 typedef int (*fp_unlock_zone) (vsm_context_h ctx, const char *zone_name);
43 typedef int (*fp_set_foreground) (vsm_zone_h zone);
44 typedef vsm_zone_h(*fp_get_foreground) (vsm_context_h ctx);
45 typedef int (*fp_iterate_zone) (vsm_context_h ctx, vsm_zone_iter_cb callback,
47 typedef vsm_zone_h(*fp_lookup_zone_by_name) (vsm_context_h ctx,
49 typedef vsm_zone_h(*fp_lookup_zone_by_pid) (vsm_context_h ctx, pid_t pid);
50 typedef int (*fp_attach_zone) (vsm_context_h ctx, const char *zone_name,
51 vsm_attach_command_s * command,
52 vsm_attach_options_s * opt,
53 pid_t * attached_process);
54 typedef int (*fp_attach_zone_wait) (vsm_context_h ctx, const char *zone_name,
55 vsm_attach_command_s * command,
56 vsm_attach_options_s * opt);
57 typedef vsm_zone_h(*fp_join_zone) (vsm_zone_h zone);
58 typedef int (*fp_is_equivalent_zone) (vsm_context_h ctx, pid_t pid);
59 typedef int (*fp_get_host_pid) (vsm_zone_h zone, pid_t pid);
60 typedef int (*fp_grant_device) (vsm_zone_h zone, const char *path,
62 typedef int (*fp_revoke_device) (vsm_zone_h zone, const char *path);
63 typedef int (*fp_declare_file) (vsm_context_h ctx, vsm_fso_type_t ftype,
64 const char *path, int flags, vsm_mode_t mode);
65 typedef int (*fp_declare_link) (vsm_context_h ctx, const char *source,
68 fp_create_zone create_zone;
69 fp_destroy_zone destroy_zone;
70 fp_start_zone start_zone;
71 fp_shutdown_zone shutdown_zone;
72 fp_lock_zone lock_zone;
73 fp_unlock_zone unlock_zone;
74 fp_set_foreground set_foreground;
75 fp_get_foreground get_foreground;
76 fp_iterate_zone iterate_zone;
77 fp_lookup_zone_by_name lookup_zone_by_name;
78 fp_lookup_zone_by_pid lookup_zone_by_pid;
79 fp_attach_zone attach_zone;
80 fp_attach_zone_wait attach_zone_wait;
81 fp_join_zone join_zone;
82 fp_get_host_pid get_host_pid;
83 fp_is_equivalent_zone is_equivalent_zone;
84 fp_grant_device grant_device;
85 fp_revoke_device revoke_device;
86 fp_declare_file declare_file;
87 fp_declare_link declare_link;
90 #define SERVICEPATH "\0/domain-control/service.sock"
93 pthread_mutex_t ml_mutex;
94 pthread_rwlock_t lock;
95 struct adt_list watches;
104 struct mxe_proxy *proxy;
105 struct adt_list queue;
109 struct mainloop *mainloop;
110 pthread_rwlock_t endpoint_lock;
111 struct adt_list endpoints;
113 struct mxe_endpoint {
116 struct mxe_engine *engine;
117 pthread_rwlock_t queue_lock;
118 pthread_mutex_t rd_mutex;
119 pthread_mutex_t wr_mutex;
120 struct adt_list queue;
121 struct adt_list list;
126 ML_EVT_OUT = EPOLLOUT,
127 ML_EVT_RDHUP = EPOLLRDHUP,
128 ML_EVT_ERROR = EPOLLERR,
129 ML_EVT_HUP = EPOLLHUP,
133 typedef int (*dev_enumerator)(int type, int major, int minor, void *data);
134 typedef int (*mainloop_callback)(int fd, mainloop_event event, void *data, struct mainloop *mainloop);
136 struct mainloop *mainloop_create(void);
137 struct mxe_endpoint *mxe_create_client(struct mxe_engine *engine, const char * /*addr*/);
138 struct mxe_engine *mxe_prepare_engine(struct mainloop *mainloop, void *data);
140 int wait_for_pid_status(pid_t pid);
142 int vsm_add_state_changed_callback(vsm_context_h /*ctx*/, vsm_zone_state_changed_cb /*callback*/, void * /*user_data*/);
143 int vsm_del_state_changed_callback(vsm_context_h /*ctx*/, int /*id*/);
144 const char * vsm_get_zone_rootpath(vsm_zone_h /*zone*/);
145 const char * vsm_get_zone_name(vsm_zone_h /*zone*/);
146 int vsm_is_host_zone(vsm_zone_h /*zone*/);
147 vsm_zone_h vsm_join_zone(vsm_zone_h zone);
148 int vsm_canonicalize_path(const char *input_path, char **output_path);