Tizen 2.1 base
[external/device-mapper.git] / lib / activate / activate.h
1 /*
2  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
3  * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
4  *
5  * This file is part of LVM2.
6  *
7  * This copyrighted material is made available to anyone wishing to use,
8  * modify, copy, or redistribute it subject to the terms and conditions
9  * of the GNU Lesser General Public License v.2.1.
10  *
11  * You should have received a copy of the GNU Lesser General Public License
12  * along with this program; if not, write to the Free Software Foundation,
13  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14  */
15
16 #ifndef LVM_ACTIVATE_H
17 #define LVM_ACTIVATE_H
18
19 #include "metadata-exported.h"
20
21 struct lvinfo {
22         int exists;
23         int suspended;
24         unsigned int open_count;
25         int major;
26         int minor;
27         int read_only;
28         int live_table;
29         int inactive_table;
30         uint32_t read_ahead;
31 };
32
33 /* target attribute flags */
34 #define MIRROR_LOG_CLUSTERED    0x00000001U
35
36 void set_activation(int activation);
37 int activation(void);
38
39 int driver_version(char *version, size_t size);
40 int library_version(char *version, size_t size);
41 int lvm1_present(struct cmd_context *cmd);
42
43 int module_present(struct cmd_context *cmd, const char *target_name);
44 int target_present(struct cmd_context *cmd, const char *target_name,
45                    int use_modprobe);
46 int target_version(const char *target_name, uint32_t *maj,
47                    uint32_t *min, uint32_t *patchlevel);
48 int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
49                          struct dm_list *modules);
50 int list_lv_modules(struct dm_pool *mem, const struct logical_volume *lv,
51                     struct dm_list *modules);
52
53 void activation_release(void);
54 void activation_exit(void);
55
56 /* int lv_suspend(struct cmd_context *cmd, const char *lvid_s); */
57 int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
58 int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
59 int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
60 int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive);
61 int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s,
62                             int exclusive);
63 int lv_deactivate(struct cmd_context *cmd, const char *lvid_s);
64
65 int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv);
66
67 /*
68  * Returns 1 if info structure has been populated, else 0.
69  */
70 int lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
71             unsigned origin_only, struct lvinfo *info,
72             int with_open_count, int with_read_ahead);
73 int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only,
74                     struct lvinfo *info, int with_open_count, int with_read_ahead);
75
76 /*
77  * Returns 1 if activate_lv has been set: 1 = activate; 0 = don't.
78  */
79 int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
80                          int *activate_lv);
81
82 int lv_check_transient(struct logical_volume *lv);
83 /*
84  * Returns 1 if percent has been set, else 0.
85  */
86 int lv_snapshot_percent(const struct logical_volume *lv, percent_t *percent);
87 int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
88                       int wait, percent_t *percent, uint32_t *event_nr);
89
90 /*
91  * Return number of LVs in the VG that are active.
92  */
93 int lvs_in_vg_activated(struct volume_group *vg);
94 int lvs_in_vg_opened(const struct volume_group *vg);
95
96 int lv_is_active(struct logical_volume *lv);
97
98 int lv_has_target_type(struct dm_pool *mem, struct logical_volume *lv,
99                        const char *layer, const char *target_type);
100
101 int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv,
102                            unsigned origin_only, int do_reg);
103
104 #ifdef DMEVENTD
105 #  include "libdevmapper-event.h"
106 char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath);
107 int target_registered_with_dmeventd(struct cmd_context *cmd, const char *libpath,
108                                     struct logical_volume *lv, int *pending);
109 int target_register_events(struct cmd_context *cmd, const char *dso, struct logical_volume *lv,
110                             int evmask __attribute__((unused)), int set, int timeout);
111 #endif
112
113 /*
114  * Returns 1 if PV has a dependency tree that uses anything in VG.
115  */
116 int pv_uses_vg(struct physical_volume *pv,
117                struct volume_group *vg);
118
119 /*
120  * Returns 1 if mapped device is not suspended.
121  */
122 int device_is_usable(struct device *dev);
123
124 #endif