Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / liblvm / lvm_base.c
blobd02fb7fd7c1ec83f09176bbfafddb822ceda5826
1 /* $NetBSD$ */
3 /*
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
17 #include "lib.h"
18 #include "lvm2app.h"
19 #include "toolcontext.h"
20 #include "locking.h"
21 #include "lvm-version.h"
23 const char *lvm_library_get_version(void)
25 return LVM_VERSION;
28 lvm_t lvm_init(const char *system_dir)
30 struct cmd_context *cmd;
32 /* FIXME: logging bound to handle
35 /* create context */
36 /* FIXME: split create_toolcontext */
37 cmd = create_toolcontext(1, system_dir);
38 if (!cmd)
39 return NULL;
41 if (stored_errno())
42 return (lvm_t) cmd;
45 * FIXME: if an non memory error occured, return the cmd (maybe some
46 * cleanup needed).
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);
58 return NULL;
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";
67 return (lvm_t) cmd;
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))
79 return -1;
80 return 0;
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))
90 return -1;
91 return 0;
94 int lvm_errno(lvm_t libh)
96 return stored_errno();
99 const char *lvm_errmsg(lvm_t libh)
101 return stored_errmsg();