xref: /netbsd-src/external/gpl2/lvm2/dist/tools/lvm2cmd.h (revision 7c604eea85b4f330dc75ffe65e947f4d73758aa0)
1*7c604eeaShaad /*	$NetBSD: lvm2cmd.h,v 1.1.1.2 2009/12/02 00:25:51 haad Exp $	*/
256a34939Shaad 
356a34939Shaad /*
456a34939Shaad  * Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
556a34939Shaad  * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
656a34939Shaad  *
756a34939Shaad  * This file is part of LVM2.
856a34939Shaad  *
956a34939Shaad  * This copyrighted material is made available to anyone wishing to use,
1056a34939Shaad  * modify, copy, or redistribute it subject to the terms and conditions
1156a34939Shaad  * of the GNU Lesser General Public License v.2.1.
1256a34939Shaad  *
1356a34939Shaad  * You should have received a copy of the GNU Lesser General Public License
1456a34939Shaad  * along with this program; if not, write to the Free Software Foundation,
1556a34939Shaad  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1656a34939Shaad  */
1756a34939Shaad 
1856a34939Shaad #ifndef _LVM_CMDLIB_H
1956a34939Shaad #define _LVM_CMDLIB_H
2056a34939Shaad 
2156a34939Shaad #ifndef _LVM_LOG_H
2256a34939Shaad typedef void (*lvm2_log_fn_t) (int level, const char *file, int line,
23*7c604eeaShaad                                int dm_errno, const char *message);
24*7c604eeaShaad 
2556a34939Shaad #endif
2656a34939Shaad 
2756a34939Shaad #define LVM2_LOG_SUPPRESS	0
2856a34939Shaad 
2956a34939Shaad /* Logging levels */
3056a34939Shaad #define LVM2_LOG_FATAL		2
3156a34939Shaad #define LVM2_LOG_ERROR		3
3256a34939Shaad #define LVM2_LOG_PRINT		4
3356a34939Shaad #define LVM2_LOG_VERBOSE 	5
3456a34939Shaad #define LVM2_LOG_VERY_VERBOSE	6
3556a34939Shaad #define LVM2_LOG_DEBUG		7
3656a34939Shaad 
3756a34939Shaad /*
3856a34939Shaad  * Define external function to replace the built-in logging function.
3956a34939Shaad  * It receives output line-by-line.
4056a34939Shaad  *
4156a34939Shaad  * level is the logging level (see above)
4256a34939Shaad  * file & line refer to the source code where the message originates.
4356a34939Shaad  */
4456a34939Shaad void lvm2_log_fn(lvm2_log_fn_t log_fn);
4556a34939Shaad 
4656a34939Shaad /*
4756a34939Shaad  * Initialise library.
4856a34939Shaad  * Returns a handle so repeated use of lvm2_run is more efficient.
4956a34939Shaad  */
5056a34939Shaad void *lvm2_init(void);
5156a34939Shaad 
5256a34939Shaad /*
5356a34939Shaad  * Set log level (as above) if using built-in logging function.
5456a34939Shaad  * Default is LVM2_LOG_PRINT.  Use LVM2_LOG_SUPPRESS to suppress output.
5556a34939Shaad  */
5656a34939Shaad void lvm2_log_level(void *handle, int level);
5756a34939Shaad 
5856a34939Shaad /*
5956a34939Shaad  * Run an LVM2 command.
6056a34939Shaad  * Use NULL handle if the call is a one-off and you don't want to bother
6156a34939Shaad  * calling lvm2_init/lvm2_exit.
6256a34939Shaad  */
6356a34939Shaad int lvm2_run(void *handle, const char *cmdline);
6456a34939Shaad 
6556a34939Shaad /* Release handle */
6656a34939Shaad void lvm2_exit(void *handle);
6756a34939Shaad 
6856a34939Shaad #endif
69