]>
sourceware.org Git - lvm2.git/blob - tools/lvmcmdlib.c
2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
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.
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
17 #include "lvm2cmdline.h"
20 #include "lvm-version.h"
29 #include <sys/resource.h>
31 void *cmdlib_lvm2_init(unsigned static_compile
)
33 struct cmd_context
*cmd
;
35 lvm_register_commands();
37 init_is_static(static_compile
);
38 if (!(cmd
= init_lvm()))
44 int lvm2_run(void *handle
, const char *cmdline
)
46 int argc
, ret
, oneoff
= 0;
47 char *args
[MAX_ARGS
], **argv
, *cmdcopy
= NULL
;
48 struct cmd_context
*cmd
;
54 if (!(handle
= lvm2_init())) {
55 log_error("Handle initialisation failed.");
60 cmd
= (struct cmd_context
*) handle
;
64 if (!(cmdcopy
= dm_strdup(cmdline
))) {
65 log_error("Cmdline copy failed.");
70 if (lvm_split(cmdcopy
, &argc
, argv
, MAX_ARGS
) == MAX_ARGS
) {
71 log_error("Too many arguments. Limit is %d.", MAX_ARGS
);
72 ret
= EINVALID_CMD_LINE
;
77 log_error("No command supplied");
78 ret
= EINVALID_CMD_LINE
;
82 /* FIXME Temporary - move to libdevmapper */
84 if (!strcmp(cmdline
, "_memlock_inc"))
85 memlock_inc_daemon(cmd
);
86 else if (!strcmp(cmdline
, "_memlock_dec"))
87 memlock_dec_daemon(cmd
);
89 ret
= lvm_run_command(cmd
, argc
, argv
);
100 void lvm2_disable_dmeventd_monitoring(void *handle
) {
101 init_dmeventd_monitor(DMEVENTD_MONITOR_IGNORE
);
104 void lvm2_log_level(void *handle
, int level
)
106 struct cmd_context
*cmd
= (struct cmd_context
*) handle
;
108 cmd
->default_settings
.verbose
= level
- VERBOSE_BASE_LEVEL
;
111 void lvm2_log_fn(lvm2_log_fn_t log_fn
)
116 void lvm2_exit(void *handle
)
118 struct cmd_context
*cmd
= (struct cmd_context
*) handle
;
This page took 0.044514 seconds and 5 git commands to generate.