4 * Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved.
6 * This file is part of LVM2.
8 * This copyrighted material is made available to anyone wishing to use,
9 * modify, copy, or redistribute it subject to the terms and conditions
10 * of the GNU Lesser General Public License v.2.1.
12 * You should have received a copy of the GNU Lesser General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "toolcontext.h"
21 #include "lvm-version.h"
23 const char *lvm_library_get_version(void)
28 lvm_t
lvm_init(const char *system_dir
)
30 struct cmd_context
*cmd
;
32 /* FIXME: logging bound to handle
36 /* FIXME: split create_toolcontext */
37 cmd
= create_toolcontext(1, system_dir
);
45 * FIXME: if an non memory error occured, return the cmd (maybe some
49 /* initialization from lvm_run_command */
50 init_error_message_produced(0);
52 /* FIXME: locking_type config option needed? */
53 /* initialize locking */
54 if (!init_locking(-1, cmd
)) {
55 /* FIXME: use EAGAIN as error code here */
56 log_error("Locking initialisation failed.");
57 lvm_quit((lvm_t
) cmd
);
61 * FIXME: Use cmd->cmd_line as audit trail for liblvm calls. Used in
62 * archive() call. Possible example:
63 * cmd_line = "lvm_vg_create: vg1\nlvm_vg_extend vg1 /dev/sda1\n"
65 cmd
->cmd_line
= (char *)"liblvm";
70 void lvm_quit(lvm_t libh
)
72 destroy_toolcontext((struct cmd_context
*)libh
);
75 int lvm_config_reload(lvm_t libh
)
77 /* FIXME: re-init locking needed here? */
78 if (!refresh_toolcontext((struct cmd_context
*)libh
))
84 * FIXME: submit a patch to document the --config option
86 int lvm_config_override(lvm_t libh
, const char *config_settings
)
88 struct cmd_context
*cmd
= (struct cmd_context
*)libh
;
89 if (override_config_tree_from_string(cmd
, config_settings
))
94 int lvm_errno(lvm_t libh
)
96 return stored_errno();
99 const char *lvm_errmsg(lvm_t libh
)
101 return stored_errmsg();