Fix build break
[platform/core/security/vasum.git] / client / vasum-client.h
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
5  *
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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
17  */
18
19
20 /**
21  * @file
22  * @author   Mateusz Malicki (m.malicki2@samsung.com)
23  * @brief    This file contains the public API for Vasum Client
24  * @defgroup libvasum-client libvasum-client
25  * @brief    C library for interfacing Vasum
26  *
27  * All functionalities that are possible using the Vasum's Command Line Interface can also be done with libvasum-client's calls.
28  *
29  * @par Simple usage:
30  * Basic usage:
31  * - Create VsmClient with vsm_client_create(). It'll be needed for all communication with Vasum.
32  * - Establish the connection with the daemon using vsm_connect()
33  * - Do what you need to do with the zones
34  * - Free the client with vsm_client_free()
35  *
36  * @code
37 #include <stdio.h>
38 #include <vasum-client.h>
39
40 int main(int argc, char** argv)
41 {
42     VsmStatus status;
43     VsmClient client;
44     VsmArrayString values = NULL;
45     int ret = 0;
46
47     // Create client handle
48     client = vsm_client_create();
49     if (NULL == client) {
50         // error!
51         ret = 1;
52         goto finish;
53     }
54
55     // Connect to Vasum
56     status = vsm_connect(client);
57     if (VSMCLIENT_SUCCESS != status) {
58         // error!
59         ret = 1;
60         goto finish;
61     }
62
63     status = vsm_get_zone_ids(client, &values);
64     if (VSMCLIENT_SUCCESS != status) {
65         // error!
66         ret = 1;
67         goto finish;
68     }
69
70     // print array
71     for (VsmArrayString iValues = values; *iValues; iValues++) {
72         printf("%s\n", *iValues);
73     }
74
75 finish:
76     vsm_array_string_free(values); // free memory
77     vsm_client_free(client); // destroy client handle
78     return ret;
79 }
80  @endcode
81
82  * @par Polling loop
83  *
84  * By default libVasum will create a separate thread for his communication with Vasum. Most of the time it'll sleep so it shouldn't be a concern.
85  * It's also possible to connect to an existing polling loop. To do this you'll need to:
86  * - Get the poll file descriptor with vsm_get_poll_fd()
87  * - Use epoll/poll/select to wait for events on the file descriptor
88  * - Call vsm_enter_eventloop() every time there's an event
89  *
90  * For example:
91  * @code
92 #include <pthread.h>
93 #include <assert.h>
94 #include <stdio.h>
95 #include <signal.h>
96 #include <sys/epoll.h>
97 #include <vasum-client.h>
98
99 volatile static sig_atomic_t running;
100 static int LOOP_INTERVAL = 1000; // ms
101
102 void* main_loop(void* client)
103 {
104     int fd = -1;
105     VsmStatus status = vsm_get_poll_fd(client, &fd);
106     assert(VSMCLIENT_SUCCESS == status);
107
108     while (running) {
109         struct epoll_event event;
110         int num = epoll_wait(fd, &event, 1, LOOP_INTERVAL);
111         if (num > 0) {
112             status = vsm_enter_eventloop(client, 0 , 0);
113             assert(VSMCLIENT_SUCCESS == status);
114         }
115     }
116     return NULL;
117 }
118
119 int main(int argc, char** argv)
120 {
121     pthread_t loop;
122     VsmStatus status;
123     VsmClient client;
124     int ret = 0;
125
126     client = vsm_client_create();
127     assert(client);
128
129     status = vsm_set_dispatcher_type(client, VSMDISPATCHER_EXTERNAL);
130     assert(VSMCLIENT_SUCCESS == status);
131
132     status = vsm_connect(client);
133     assert(VSMCLIENT_SUCCESS == status);
134
135     // start event loop
136     running = 1;
137     ret = pthread_create(&loop, NULL, main_loop, client);
138     assert(ret == 0);
139
140     // make vsm_* calls on client
141     // ...
142
143     status = vsm_disconnect(client);
144     assert(VSMCLIENT_SUCCESS == status);
145
146     //stop event loop
147     running = 0;
148     ret = pthread_join(loop, NULL);
149     assert(ret == 0);
150
151     vsm_client_free(client); // destroy client handle
152     return ret;
153 }
154  @endcode
155  */
156 /*@{*/
157 #ifndef VASUM_CLIENT_H
158 #define VASUM_CLIENT_H
159
160 #include <stdint.h>
161 #include <sys/stat.h>
162 #include <netinet/ip.h>
163 #include <linux/if_link.h>
164
165 #ifdef __cplusplus
166 extern "C"
167 {
168 #endif
169
170 /**
171  * vasum-server's opaque client pointer.
172  */
173 typedef void* VsmClient;
174
175 /**
176  * NULL-terminated string type.
177  *
178  * @sa vsm_string_free
179  */
180 typedef char* VsmString;
181
182 /**
183  * NULL-terminated array of strings type.
184  *
185  * @sa vsm_array_string_free
186  */
187 typedef VsmString* VsmArrayString;
188
189 /**
190  * Completion status of libvasum-client's functions
191  */
192 typedef enum {
193     VSMCLIENT_CUSTOM_ERROR,     /**< User specified error */
194     VSMCLIENT_IO_ERROR,         /**< Input/Output error */
195     VSMCLIENT_OPERATION_FAILED, /**< Operation failed */
196     VSMCLIENT_INVALID_ARGUMENT, /**< Invalid argument */
197     VSMCLIENT_OTHER_ERROR,      /**< Other error */
198     VSMCLIENT_SUCCESS           /**< Success */
199 } VsmStatus;
200
201 /**
202  * Subscription id
203  */
204 typedef unsigned int VsmSubscriptionId;
205
206 /**
207  * States of zone
208  */
209 typedef enum {
210     STOPPED,
211     STARTING,
212     RUNNING,
213     STOPPING,
214     ABORTING,
215     FREEZING,
216     FROZEN,
217     THAWED,
218     LOCKED,
219     MAX_STATE,
220     ACTIVATING = 128
221 } VsmZoneState;
222
223 /**
224  * Zone information structure
225  */
226 typedef struct {
227     char* id;
228     int terminal;
229     VsmZoneState state;
230     char *rootfs_path;
231 } VsmZoneStructure;
232
233 /**
234  * Zone information
235  */
236 typedef VsmZoneStructure* VsmZone;
237
238 /**
239  * Netowrk device type
240  */
241 typedef enum {
242     VSMNETDEV_VETH,
243     VSMNETDEV_PHYS,
244     VSMNETDEV_MACVLAN
245 } VsmNetdevType;
246
247 /**
248  * Network device information structure
249  */
250 typedef struct {
251     char* name;
252     VsmNetdevType type;
253 } VsmNetdevStructure;
254
255 /**
256  * Network device information
257  */
258 typedef VsmNetdevStructure* VsmNetdev;
259
260 /**
261  * File type
262  */
263 typedef enum {
264     VSMFILE_DIRECTORY,
265     VSMFILE_FIFO,
266     VSMFILE_REGULAR
267 } VsmFileType;
268
269 /**
270  * Event dispacher types.
271  */
272 typedef enum {
273     VSMDISPATCHER_EXTERNAL,         /**< User must handle dispatching messages */
274     VSMDISPATCHER_INTERNAL          /**< Library will take care of dispatching messages */
275 } VsmDispacherType;
276
277 #ifndef __VASUM_WRAPPER_SOURCE__
278
279 /**
280  * Get file descriptor associated with event dispatcher of zone client
281  *
282  * The function vsm_get_poll_fd() returns the file descriptor associated with the event dispatcher of vsm client.
283  * The file descriptor can be bound to another I/O multiplexing facilities like epoll, select, and poll.
284  *
285  * @param[in] client vsm client
286  * @param[out] fd epoll file descriptor
287  * @return status of this function call
288 */
289 VsmStatus vsm_get_poll_fd(VsmClient client, int* fd);
290
291 /**
292  * Wait for an I/O event on a vsm client
293  *
294  * vsm_enter_eventloop() waits for event on the vsm client
295  *
296  * The call waits for a maximum time of timout milliseconds. Specifying a timeout of -1 makes vsm_enter_eventloop() wait indefinitely,
297  * while specifying a timeout equal to zero makes vsm_enter_eventloop() to return immediately even if no events are available.
298  *
299  * @param[in] client vasum-server's client
300  * @param[in] flags Reserved
301  * @param[in] timeout Timeout time (milisecond), -1 is infinite
302  * @return status of this function call
303 */
304 VsmStatus vsm_enter_eventloop(VsmClient client, int flags, int timeout);
305
306 /**
307  * Set dispatching method
308  *
309  * @param[in] client vasum-server's client
310  * @param[in] dispacher dispatching method
311  * @return status of this function call
312  */
313 VsmStatus vsm_set_dispatcher_type(VsmClient client, VsmDispacherType dispacher);
314
315 /**
316  * Get dispatching method
317  *
318  * @param[in] client vasum-server's client
319  * @param[out] dispacher dispatching method
320  * @return status of this function call
321  */
322 VsmStatus vsm_get_dispatcher_type(VsmClient client, VsmDispacherType* dispacher);
323
324 /**
325  * Create a new vasum-server's client.
326  *
327  * @return Created client pointer or NULL on failure.
328  */
329 VsmClient vsm_client_create();
330
331 /**
332  * Release client resources.
333  *
334  * @param[in] client vasum-server's client
335  */
336 void vsm_client_free(VsmClient client);
337
338 /**
339  * Get status code of last vasum-server communication.
340  *
341  * @param[in] client vasum-server's client
342  * @return status of this function call
343  */
344 VsmStatus vsm_get_status(VsmClient client);
345
346 /**
347  * Get status message of the last vasum-server communication.
348  *
349  * @param[in] client vasum-server's client
350  * @return last status message from vasum-server communication
351  */
352 const char* vsm_get_status_message(VsmClient client);
353
354 /**
355  * Connect client to the vasum-server.
356  *
357  * @param[in] client vasum-server's client
358  * @return status of this function call
359  */
360 VsmStatus vsm_connect(VsmClient client);
361
362 /**
363  * Connect client to the vasum-server via custom address.
364  *
365  * @param[in] client vasum-server's client
366  * @param[in] address dbus address
367  * @return status of this function call
368  */
369 VsmStatus vsm_connect_custom(VsmClient client, const char* address);
370
371 /**
372  * Disconnect client from vasum-server.
373  *
374  * @param[in] client vasum-server's client
375  * @return status of this function call
376  */
377 VsmStatus vsm_disconnect(VsmClient client);
378
379 /**
380  * Release VsmArrayString.
381  *
382  * @param[in] astring VsmArrayString
383  */
384 void vsm_array_string_free(VsmArrayString astring);
385
386 /**
387  * Release VsmString.
388  *
389  * @param string VsmString
390  */
391 void vsm_string_free(VsmString string);
392
393 /**
394  * Release VsmZone
395  *
396  * @param zone VsmZone
397  */
398 void vsm_zone_free(VsmZone zone);
399
400 /**
401  * Release VsmNetdev
402  *
403  * @param netdev VsmNetdev
404  */
405 void vsm_netdev_free(VsmNetdev netdev);
406
407 /**
408  * Zone's D-Bus state change callback function signature.
409  *
410  * @param[in] zoneId affected zone id
411  * @param[in] address new D-Bus address
412  * @param data custom user's data pointer passed to vsm_add_state_callback() function
413  */
414 typedef void (*VsmZoneDbusStateCallback)(const char* zoneId,
415                                              const char* address,
416                                              void* data);
417
418 /**
419  * Lock the command queue exclusively.
420  *
421  * @param[in] client vasum-server's client
422  * @return status of this function call
423  */
424 VsmStatus vsm_lock_queue(VsmClient client);
425
426 /**
427  * Unlock the command queue.
428  *
429  * @param[in] client vasum-server's client
430  * @return status of this function call
431  */
432 VsmStatus vsm_unlock_queue(VsmClient client);
433
434 /**
435  * Get dbus address of each zone.
436  *
437  * @param[in] client vasum-server's client
438  * @param[out] keys array of zones name
439  * @param[out] values array of zones dbus address
440  * @return status of this function call
441  * @post keys[i] corresponds to values[i]
442  * @remark Use vsm_array_string_free() to free memory occupied by @p keys and @p values.
443  */
444 VsmStatus vsm_get_zone_dbuses(VsmClient client, VsmArrayString* keys, VsmArrayString* values);
445
446 /**
447  * Get zones name.
448  *
449  * @param[in] client vasum-server's client
450  * @param[out] array array of zones name
451  * @return status of this function call
452  * @remark Use vsm_array_string_free() to free memory occupied by @p array.
453  */
454 VsmStatus vsm_get_zone_ids(VsmClient client, VsmArrayString* array);
455
456 /**
457  * Get active (foreground) zone name.
458  *
459  * @param[in] client vasum-server's client
460  * @param[out] id active zone name
461  * @return status of this function call
462  * @remark Use @p vsm_string_free() to free memory occupied by @p id.
463  */
464 VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id);
465
466 /**
467  * Get zone rootfs path.
468  *
469  * @param[in] client vasum-server's client
470  * @param[in] id zone name
471  * @param[out] rootpath zone rootfs path
472  * @return status of this function call
473  * @remark Use @p vsm_string_free() to free memory occupied by @p rootpath.
474  */
475 VsmStatus vsm_get_zone_rootpath(VsmClient client, const char* id, VsmString* rootpath);
476
477 /**
478  * Get zone name of process with given pid.
479  *
480  * @param[in] client vasum-server's client
481  * @param[in] pid process id
482  * @param[out] id active zone name
483  * @return status of this function call
484  * @remark Use @p vsm_string_free() to free memory occupied by @p id.
485  */
486 VsmStatus vsm_lookup_zone_by_pid(VsmClient client, int pid, VsmString* id);
487
488 /**
489  * Get zone informations of zone with given id.
490  *
491  * @param[in] client vasum-server's client
492  * @param[in] id zone name
493  * @param[out] zone zone informations
494  * @return status of this function call
495  * @remark Use @p vsm_zone_free() to free memory occupied by @p zone
496  */
497 VsmStatus vsm_lookup_zone_by_id(VsmClient client, const char* id, VsmZone* zone);
498
499 /**
500  * Get zone name with given terminal.
501  *
502  * @param[in] client vasum-server's client
503  * @param[in] terminal terminal id
504  * @param[out] id zone name with given terminal
505  * @return status of this function call
506  * @remark Use @p vsm_string_free() to free memory occupied by @p id.
507  */
508 VsmStatus vsm_lookup_zone_by_terminal_id(VsmClient client, int terminal, VsmString* id);
509
510 /**
511  * Set active (foreground) zone.
512  *
513  * @param[in] client vasum-server's client
514  * @param[in] id zone name
515  * @return status of this function call
516  */
517 VsmStatus vsm_set_active_zone(VsmClient client, const char* id);
518
519 /**
520  * Create and add zone
521  *
522  * @param[in] client vasum-server's client
523  * @param[in] id zone id
524  * @param[in] tname template name, NULL is equivalent to "default"
525  * @return status of this function call
526  */
527 VsmStatus vsm_create_zone(VsmClient client, const char* id, const char* tname);
528
529 /**
530  * Remove zone
531  *
532  * @param[in] client vasum-server's client
533  * @param[in] id zone id
534  * @param[in] force if 0 data will be kept, otherwise data will be lost
535  * @return status of this function call
536  */
537 VsmStatus vsm_destroy_zone(VsmClient client, const char* id, int force);
538
539 /**
540  * Shutdown zone
541  *
542  * @param[in] client vasum-server's client
543  * @param[in] id zone name
544  * @return status of this function call
545  */
546 VsmStatus vsm_shutdown_zone(VsmClient client, const char* id);
547
548 /**
549  * Start zone
550  *
551  * @param[in] client vasum-server's client
552  * @param[in] id zone name
553  * @return status of this function call
554  */
555 VsmStatus vsm_start_zone(VsmClient client, const char* id);
556
557 /**
558  * Lock zone
559  *
560  * @param[in] client vasum-server's client
561  * @param[in] id zone name
562  * @return status of this function call
563  */
564 VsmStatus vsm_lock_zone(VsmClient client, const char* id);
565
566 /**
567  * Unlock zone
568  *
569  * @param[in] client vasum-server's client
570  * @param[in] id zone name
571  * @return status of this function call
572  */
573 VsmStatus vsm_unlock_zone(VsmClient client, const char* id);
574
575 /**
576  * Register dbus state change callback function.
577  *
578  * @note The callback function will be invoked on a different thread.
579  *
580  * @param[in] client vasum-server's client
581  * @param[in] zoneDbusStateCallback callback function
582  * @param[in] data some extra data that will be passed to callback function
583  * @param[out] subscriptionId subscription identifier that can be used to unsubscribe signal,
584  *                      pointer can be NULL.
585  * @return status of this function call
586  */
587 VsmStatus vsm_add_state_callback(VsmClient client,
588                                  VsmZoneDbusStateCallback zoneDbusStateCallback,
589                                  void* data,
590                                  VsmSubscriptionId* subscriptionId);
591
592 /**
593  * Unregister dbus state change callback function.
594  *
595  * @param[in] client vasum-server's client
596  * @param[in] subscriptionId subscription identifier returned by vsm_add_state_callback
597  * @return status of this function call
598  */
599 VsmStatus vsm_del_state_callback(VsmClient client, VsmSubscriptionId subscriptionId);
600
601 /**
602  * Grant access to device
603  *
604  * @param[in] client vasum-server's client
605  * @param[in] zone zone name
606  * @param[in] device device path
607  * @param[in] flags access flags
608  * @return status of this function call
609  */
610 VsmStatus vsm_grant_device(VsmClient client,
611                            const char* zone,
612                            const char* device,
613                            uint32_t flags);
614
615 /**
616  * Revoke access to device
617  *
618  * @param[in] client vasum-server's client
619  * @param[in] zone zone name
620  * @param[in] device device path
621  * @return status of this function call
622  */
623 VsmStatus vsm_revoke_device(VsmClient client, const char* zone, const char* device);
624
625 /**
626  * Get array of netdev from given zone
627  *
628  * @param[in] client vasum-server's client
629  * @param[in] zone zone name
630  * @param[out] netdevIds array of netdev id
631  * @return status of this function call
632  * @remark Use vsm_array_string_free() to free memory occupied by @p netdevIds.
633  */
634 VsmStatus vsm_zone_get_netdevs(VsmClient client, const char* zone, VsmArrayString* netdevIds);
635
636 /**
637  * Get ipv4 address for given netdevId
638  *
639  * @param[in] client vasum-server's client
640  * @param[in] zone zone name
641  * @param[in] netdevId netdev id
642  * @param[out] addr ipv4 address
643  * @return status of this function call
644  */
645 VsmStatus vsm_netdev_get_ipv4_addr(VsmClient client,
646                                    const char* zone,
647                                    const char* netdevId,
648                                    struct in_addr *addr);
649
650 /**
651  * Get ipv6 address for given netdevId
652  *
653  * @param[in] client vasum-server's client
654  * @param[in] zone zone name
655  * @param[in] netdevId netdev id
656  * @param[out] addr ipv6 address
657  * @return status of this function call
658  */
659 VsmStatus vsm_netdev_get_ipv6_addr(VsmClient client,
660                                    const char* zone,
661                                    const char* netdevId,
662                                    struct in6_addr *addr);
663
664 /**
665  * Set ipv4 address for given netdevId
666  *
667  * @param[in] client vasum-server's client
668  * @param[in] zone zone name
669  * @param[in] netdevId netdev id
670  * @param[in] addr ipv4 address
671  * @param[in] prefix bit-length of the network prefix
672  * @return status of this function call
673  */
674 VsmStatus vsm_netdev_set_ipv4_addr(VsmClient client,
675                                    const char* zone,
676                                    const char* netdevId,
677                                    struct in_addr *addr,
678                                    int prefix);
679
680 /**
681  * Set ipv6 address for given netdevId
682  *
683  * @param[in] client vasum-server's client
684  * @param[in] zone zone name
685  * @param[in] netdevId netdev id
686  * @param[in] addr ipv6 address
687  * @param[in] prefix bit-length of the network prefix
688  * @return status of this function call
689  */
690 VsmStatus vsm_netdev_set_ipv6_addr(VsmClient client,
691                                    const char* zone,
692                                    const char* netdevId,
693                                    struct in6_addr *addr,
694                                    int prefix);
695
696 /**
697  * Remove ipv4 address from netdev
698  *
699  * @param[in] client vasum-server's client
700  * @param[in] zone zone name
701  * @param[in] netdevId network device id
702  * @param[in] addr ipv4 address
703  * @param[in] prefix bit-length of the network prefix
704  * @return status of this function call
705  */
706 VsmStatus vsm_netdev_del_ipv4_addr(VsmClient client,
707                                    const char* zone,
708                                    const char* netdevId,
709                                    struct in_addr* addr,
710                                    int prefix);
711
712 /**
713  * Remove ipv6 address from netdev
714  *
715  * @param[in] client vasum-server's client
716  * @param[in] zone zone name
717  * @param[in] netdevId network device id
718  * @param[in] addr ipv6 address
719  * @param[in] prefix bit-length of the network prefix
720  * @return status of this function call
721  */
722 VsmStatus vsm_netdev_del_ipv6_addr(VsmClient client,
723                                    const char* zone,
724                                    const char* netdevId,
725                                    struct in6_addr* addr,
726                                    int prefix);
727
728 /**
729  * Turn up a network device in the zone
730  *
731  * @param[in] client vasum-server's client
732  * @param[in] zone zone name
733  * @param[in] netdevId netdev id
734  * @return status of this function call
735  */
736 VsmStatus vsm_netdev_up(VsmClient client,
737                         const char* zone,
738                         const char* netdevId);
739
740 /**
741  * Turn down a network device in the zone
742  *
743  * @param[in] client vasum-server's client
744  * @param[in] zone zone name
745  * @param[in] netdevId netdev id
746  * @return status of this function call
747  */
748 VsmStatus vsm_netdev_down(VsmClient client,
749                           const char* zone,
750                           const char* netdevId);
751
752
753 /**
754  * Create veth netdev in zone
755  *
756  * @param[in] client vasum-server's client
757  * @param[in] zone zone name
758  * @param[in] zoneDev  Device ID in Zone network
759  * @param[in] hostDev  Device ID in Host network
760  * @return status of this function call
761  */
762 VsmStatus vsm_create_netdev_veth(VsmClient client,
763                                  const char* zone,
764                                  const char* zoneDev,
765                                  const char* hostDev);
766 /**
767  * Create macvlan in zone
768  *
769  * @param[in] client   vasum-server's client
770  * @param[in] zone     Zone name
771  * @param[in] zoneDev  Device ID in Zone network
772  * @param[in] hostDev  Device ID in Host network
773  * @param[in] mode     Mode with which macvlan will be created.
774  * @return status of this function call
775  *
776  * @see macvlan_mode
777  */
778 VsmStatus vsm_create_netdev_macvlan(VsmClient client,
779                                     const char* zone,
780                                     const char* zoneDev,
781                                     const char* hostDev,
782                                     enum macvlan_mode mode);
783 /**
784  * Create/move phys netdev in/to zone
785  *
786  * @param[in] client vasum-server's client
787  * @param[in] zone zone name
788  * @param[in] devId network device id
789  * @return status of this function call
790  */
791 VsmStatus vsm_create_netdev_phys(VsmClient client, const char* zone, const char* devId);
792
793 /**
794  * Get netdev informations
795  *
796  * @param[in] client vasum-server's client
797  * @param[in] zone zone name
798  * @param[in] netdevId network device id
799  * @param[out] netdev netdev informations
800  * @return status of this function call
801  * @remark Use vsm_netdev_free() to free memory occupied by @p netdev.
802  */
803 VsmStatus vsm_lookup_netdev_by_name(VsmClient client,
804                                     const char* zone,
805                                     const char* netdevId,
806                                     VsmNetdev* netdev);
807
808 /**
809  * Remove netdev from zone
810  *
811  * @param[in] client vasum-server's client
812  * @param[in] zone zone name
813  * @param[in] devId network device id
814  * @return status of this function call
815  */
816 VsmStatus vsm_destroy_netdev(VsmClient client, const char* zone, const char* devId);
817
818 /**
819  * Create file, directory or pipe in zone
820  *
821  * Declare file, directory or pipe that will be created while zone startup
822  *
823  * @param[in] client vasum-server's client
824  * @param[in] type file type
825  * @param[in] zone zone id
826  * @param[in] path path to file
827  * @param[in] flags if O_CREAT bit is set then file will be created in zone,
828  *                  otherwise file will by copied from host;
829  *                  it is meaningful only when O_CREAT is set
830  * @param[in] mode mode of file
831  * @return status of this function call
832  */
833 VsmStatus vsm_declare_file(VsmClient client,
834                            const char* zone,
835                            VsmFileType type,
836                            const char* path,
837                            int32_t flags,
838                            mode_t mode);
839
840 /**
841  * Create mount point in zone
842  *
843  * Declare mount that will be created while zone startup
844  * Parameters are passed to mount system function
845  *
846  * @param[in] client vasum-server's client
847  * @param[in] source device path (path in host)
848  * @param[in] zone zone id
849  * @param[in] target mount point (path in zone)
850  * @param[in] type filesystem type
851  * @param[in] flags mount flags as in mount function
852  * @param[in] data additional data as in mount function
853  * @return status of this function call
854  */
855 VsmStatus vsm_declare_mount(VsmClient client,
856                             const char* source,
857                             const char* zone,
858                             const char* target,
859                             const char* type,
860                             uint64_t flags,
861                             const char* data);
862
863 /**
864  * Create link in zone
865  *
866  * Declare link that will be created while zone startup
867  * Parameters are passed to link system function
868  *
869  * @param[in] client vasum-server's client
870  * @param[in] source path to link source (in host)
871  * @param[in] zone zone id
872  * @param[in] target path to link name (in zone)
873  * @return status of this function call
874  */
875 VsmStatus vsm_declare_link(VsmClient client,
876                            const char *source,
877                            const char* zone,
878                            const char *target);
879
880 /**
881  * Get all declarations
882  *
883  * Gets all declarations of resourcies
884  * (@see ::vsm_declare_link, @see ::vsm_declare_mount, @see ::vsm_declare_file)
885  *
886  * @param[in] client vasum-server's client
887  * @param[in] zone zone id
888  * @param[out] declarations array of declarations id
889  * @return status of this function call
890  */
891 VsmStatus vsm_list_declarations(VsmClient client,
892                                 const char* zone,
893                                 VsmArrayString* declarations);
894
895 /**
896  * Remove declaration
897  *
898  * Removes given declaration by its id (@see ::vsm_list_declarations)
899  *
900  * @param[in] client vasum-server's client
901  * @param[in] zone zone id
902  * @param[in] declaration declaration id
903  * @return status of this function call
904  */
905 VsmStatus vsm_remove_declaration(VsmClient client,
906                                  const char* zone,
907                                  VsmString declaration);
908
909 /**
910  * Clean up zones root directory
911  *
912  * Removes all unknown zones root directory entry
913  * @return status of this function call
914  */
915 VsmStatus vsm_clean_up_zones_root(VsmClient client);
916
917 #endif /* __VASUM_WRAPPER_SOURCE__ */
918
919 #ifdef __cplusplus
920 }
921 #endif
922
923 #endif /* VASUM_CLIENT_H */
924 /*@}*/