2001-11-21 15:47:42 +03:00
/*
* Copyright ( C ) 2001 Sistina Software ( UK ) Limited .
*
* This file is released under the LGPL .
*/
# ifndef LIB_DEVICE_MAPPER_H
# define LIB_DEVICE_MAPPER_H
2001-12-05 19:41:52 +03:00
# include <inttypes.h>
2002-01-15 18:21:57 +03:00
# include <sys/types.h>
2002-03-06 22:42:23 +03:00
# include <linux/types.h>
2001-12-05 19:41:52 +03:00
2001-11-21 15:47:42 +03:00
/*
* Since it is quite laborious to build the ioctl
* arguments for the device - mapper people are
* encouraged to use this library .
*
* You will need to build a struct dm_task for
* each ioctl command you want to execute .
*/
2002-03-07 23:56:10 +03:00
typedef void ( * dm_log_fn ) ( int level , const char * file , int line ,
const char * f , . . . ) ;
2001-11-21 15:47:42 +03:00
/*
* The library user may wish to register their own
* logging function , by default errors go to
* stderr .
*/
void dm_log_init ( dm_log_fn fn ) ;
2003-01-22 00:25:11 +03:00
void dm_log_init_verbose ( int level ) ;
2001-11-21 15:47:42 +03:00
enum {
DM_DEVICE_CREATE ,
DM_DEVICE_RELOAD ,
DM_DEVICE_REMOVE ,
2002-03-07 23:56:10 +03:00
DM_DEVICE_REMOVE_ALL ,
2001-11-21 15:47:42 +03:00
DM_DEVICE_SUSPEND ,
DM_DEVICE_RESUME ,
DM_DEVICE_INFO ,
2002-03-06 17:38:25 +03:00
DM_DEVICE_DEPS ,
2002-01-11 02:29:16 +03:00
DM_DEVICE_RENAME ,
2002-01-15 18:21:57 +03:00
DM_DEVICE_VERSION ,
2002-05-03 15:55:58 +04:00
DM_DEVICE_STATUS ,
DM_DEVICE_TABLE ,
DM_DEVICE_WAITEVENT
2001-11-21 15:47:42 +03:00
} ;
struct dm_task ;
struct dm_task * dm_task_create ( int type ) ;
void dm_task_destroy ( struct dm_task * dmt ) ;
int dm_task_set_name ( struct dm_task * dmt , const char * name ) ;
2002-03-12 01:44:36 +03:00
int dm_task_set_uuid ( struct dm_task * dmt , const char * uuid ) ;
2001-11-21 15:47:42 +03:00
/*
* Retrieve attributes after an info .
*/
struct dm_info {
int exists ;
int suspended ;
2003-03-28 21:58:59 +03:00
int32_t open_count ;
2003-04-29 15:34:23 +04:00
uint32_t event_nr ;
2003-03-28 21:58:59 +03:00
uint32_t major ;
uint32_t minor ; /* minor device number */
2002-01-03 18:12:02 +03:00
int read_only ; /* 0:read-write; 1:read-only */
2002-01-03 13:39:21 +03:00
2003-03-28 21:58:59 +03:00
int32_t target_count ;
2001-11-21 15:47:42 +03:00
} ;
2002-03-06 17:38:25 +03:00
struct dm_deps {
2003-03-28 21:58:59 +03:00
uint32_t count ;
uint32_t filler ;
uint64_t device [ 0 ] ;
2002-03-06 17:38:25 +03:00
} ;
2002-01-17 17:13:25 +03:00
int dm_get_library_version ( char * version , size_t size ) ;
2002-03-07 23:56:10 +03:00
int dm_task_get_driver_version ( struct dm_task * dmt , char * version , size_t size ) ;
2001-11-21 15:47:42 +03:00
int dm_task_get_info ( struct dm_task * dmt , struct dm_info * dmi ) ;
2002-03-13 19:19:17 +03:00
const char * dm_task_get_uuid ( struct dm_task * dmt ) ;
2001-11-21 15:47:42 +03:00
2002-03-06 17:38:25 +03:00
struct dm_deps * dm_task_get_deps ( struct dm_task * dmt ) ;
2002-01-03 13:39:21 +03:00
int dm_task_set_ro ( struct dm_task * dmt ) ;
2002-01-11 02:29:16 +03:00
int dm_task_set_newname ( struct dm_task * dmt , const char * newname ) ;
2002-01-11 15:12:46 +03:00
int dm_task_set_minor ( struct dm_task * dmt , int minor ) ;
2003-04-02 23:03:00 +04:00
int dm_task_set_major ( struct dm_task * dmt , int major ) ;
2003-04-29 15:34:23 +04:00
int dm_task_set_event_nr ( struct dm_task * dmt , uint32_t event_nr ) ;
2002-01-11 02:29:16 +03:00
2001-11-21 15:47:42 +03:00
/*
* Use these to prepare for a create or reload .
*/
int dm_task_add_target ( struct dm_task * dmt ,
2001-12-05 19:41:52 +03:00
uint64_t start ,
2002-03-07 23:56:10 +03:00
uint64_t size , const char * ttype , const char * params ) ;
2001-11-21 15:47:42 +03:00
2002-05-03 15:55:58 +04:00
/* Use this to retrive target information returned from a STATUS call */
void * dm_get_next_target ( struct dm_task * dmt ,
2002-05-10 19:25:38 +04:00
void * next , uint64_t * start , uint64_t * length ,
char * * target_type , char * * params ) ;
2002-05-03 15:55:58 +04:00
2001-11-21 15:47:42 +03:00
/*
* Call this to actually run the ioctl .
*/
int dm_task_run ( struct dm_task * dmt ) ;
/*
2001-11-21 20:08:37 +03:00
* Configure the device - mapper directory
2001-11-21 15:47:42 +03:00
*/
2001-11-21 20:08:37 +03:00
int dm_set_dev_dir ( const char * dir ) ;
2001-11-21 15:47:42 +03:00
const char * dm_dir ( void ) ;
2002-03-07 23:56:10 +03:00
# endif /* LIB_DEVICE_MAPPER_H */