]>
sourceware.org Git - lvm2.git/blob - liblvm/lvm_base.c
2 * Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved.
4 * This file is part of LVM2.
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU Lesser General Public License v.2.1.
10 * You should have received a copy of the GNU Lesser General Public License
11 * along with this program; if not, write to the Free Software Foundation,
12 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #include "toolcontext.h"
18 #include "lvm-version.h"
19 #include "metadata-exported.h"
22 const char *lvm_library_get_version(void)
27 lvm_t
lvm_init(const char *system_dir
)
29 struct cmd_context
*cmd
;
31 /* FIXME: logging bound to handle
34 if (!udev_init_library_context())
38 /* FIXME: split create_toolcontext */
39 /* FIXME: make all globals configurable */
40 cmd
= create_toolcontext(0, system_dir
, 1, 0);
48 * FIXME: if an non memory error occured, return the cmd (maybe some
52 /* initialization from lvm_run_command */
53 init_error_message_produced(0);
55 /* FIXME: locking_type config option needed? */
56 /* initialize locking */
57 if (!init_locking(-1, cmd
, 0)) {
58 /* FIXME: use EAGAIN as error code here */
59 lvm_quit((lvm_t
) cmd
);
63 * FIXME: Use cmd->cmd_line as audit trail for liblvm calls. Used in
64 * archive() call. Possible example:
65 * cmd_line = "lvm_vg_create: vg1\nlvm_vg_extend vg1 /dev/sda1\n"
67 cmd
->cmd_line
= "liblvm";
72 void lvm_quit(lvm_t libh
)
74 destroy_toolcontext((struct cmd_context
*)libh
);
75 udev_fin_library_context();
78 int lvm_config_reload(lvm_t libh
)
80 /* FIXME: re-init locking needed here? */
81 if (!refresh_toolcontext((struct cmd_context
*)libh
))
87 * FIXME: submit a patch to document the --config option
89 int lvm_config_override(lvm_t libh
, const char *config_settings
)
91 struct cmd_context
*cmd
= (struct cmd_context
*)libh
;
92 if (override_config_tree_from_string(cmd
, config_settings
))
97 int lvm_config_find_bool(lvm_t libh
, const char *config_path
, int fail
)
99 return find_config_tree_bool((struct cmd_context
*)libh
, config_path
, fail
);
102 int lvm_errno(lvm_t libh
)
104 return stored_errno();
107 const char *lvm_errmsg(lvm_t libh
)
109 return stored_errmsg();
112 const char *lvm_vgname_from_pvid(lvm_t libh
, const char *pvid
)
114 struct cmd_context
*cmd
= (struct cmd_context
*)libh
;
117 if (!id_read_format(&id
, pvid
)) {
118 log_error(INTERNAL_ERROR
"Unable to convert uuid");
121 return find_vgname_from_pvid(cmd
, (char *)id
.uuid
);
124 const char *lvm_vgname_from_device(lvm_t libh
, const char *device
)
126 struct cmd_context
*cmd
= (struct cmd_context
*)libh
;
127 return find_vgname_from_pvname(cmd
, device
);
This page took 0.040093 seconds and 5 git commands to generate.