xref: /dflybsd-src/contrib/lvm2/dist/include/libdevmapper-event.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /*	$NetBSD: libdevmapper-event.h,v 1.1.1.1 2008/12/22 00:18:48 haad Exp $	*/
286d7f5d3SJohn Marino 
386d7f5d3SJohn Marino /*
486d7f5d3SJohn Marino  * Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
586d7f5d3SJohn Marino  *
686d7f5d3SJohn Marino  * This file is part of the device-mapper userspace tools.
786d7f5d3SJohn Marino  *
886d7f5d3SJohn Marino  * This copyrighted material is made available to anyone wishing to use,
986d7f5d3SJohn Marino  * modify, copy, or redistribute it subject to the terms and conditions
1086d7f5d3SJohn Marino  * of the GNU Lesser General Public License v.2.1.
1186d7f5d3SJohn Marino  *
1286d7f5d3SJohn Marino  * You should have received a copy of the GNU Lesser General Public License
1386d7f5d3SJohn Marino  * along with this program; if not, write to the Free Software Foundation,
1486d7f5d3SJohn Marino  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1586d7f5d3SJohn Marino  */
1686d7f5d3SJohn Marino 
1786d7f5d3SJohn Marino /*
1886d7f5d3SJohn Marino  * Note that this file is released only as part of a technology preview
1986d7f5d3SJohn Marino  * and its contents may change in future updates in ways that do not
2086d7f5d3SJohn Marino  * preserve compatibility.
2186d7f5d3SJohn Marino  */
2286d7f5d3SJohn Marino 
2386d7f5d3SJohn Marino #ifndef LIB_DMEVENT_H
2486d7f5d3SJohn Marino #define LIB_DMEVENT_H
2586d7f5d3SJohn Marino 
2686d7f5d3SJohn Marino #include <stdint.h>
2786d7f5d3SJohn Marino 
2886d7f5d3SJohn Marino /*
2986d7f5d3SJohn Marino  * Event library interface.
3086d7f5d3SJohn Marino  */
3186d7f5d3SJohn Marino 
3286d7f5d3SJohn Marino enum dm_event_mask {
3386d7f5d3SJohn Marino 	DM_EVENT_SETTINGS_MASK  = 0x0000FF,
3486d7f5d3SJohn Marino 	DM_EVENT_SINGLE		= 0x000001, /* Report multiple errors just once. */
3586d7f5d3SJohn Marino 	DM_EVENT_MULTI		= 0x000002, /* Report all of them. */
3686d7f5d3SJohn Marino 
3786d7f5d3SJohn Marino 	DM_EVENT_ERROR_MASK     = 0x00FF00,
3886d7f5d3SJohn Marino 	DM_EVENT_SECTOR_ERROR	= 0x000100, /* Failure on a particular sector. */
3986d7f5d3SJohn Marino 	DM_EVENT_DEVICE_ERROR	= 0x000200, /* Device failure. */
4086d7f5d3SJohn Marino 	DM_EVENT_PATH_ERROR	= 0x000400, /* Failure on an io path. */
4186d7f5d3SJohn Marino 	DM_EVENT_ADAPTOR_ERROR	= 0x000800, /* Failure of a host adaptor. */
4286d7f5d3SJohn Marino 
4386d7f5d3SJohn Marino 	DM_EVENT_STATUS_MASK    = 0xFF0000,
4486d7f5d3SJohn Marino 	DM_EVENT_SYNC_STATUS	= 0x010000, /* Mirror synchronization completed/failed. */
4586d7f5d3SJohn Marino 	DM_EVENT_TIMEOUT	= 0x020000, /* Timeout has occured */
4686d7f5d3SJohn Marino 
4786d7f5d3SJohn Marino 	DM_EVENT_REGISTRATION_PENDING = 0x1000000, /* Monitor thread is setting-up/shutting-down */
4886d7f5d3SJohn Marino };
4986d7f5d3SJohn Marino 
5086d7f5d3SJohn Marino #define DM_EVENT_ALL_ERRORS DM_EVENT_ERROR_MASK
5186d7f5d3SJohn Marino 
5286d7f5d3SJohn Marino struct dm_event_handler;
5386d7f5d3SJohn Marino 
5486d7f5d3SJohn Marino struct dm_event_handler *dm_event_handler_create(void);
5586d7f5d3SJohn Marino void dm_event_handler_destroy(struct dm_event_handler *dmevh);
5686d7f5d3SJohn Marino 
5786d7f5d3SJohn Marino /*
5886d7f5d3SJohn Marino  * Path of shared library to handle events.
5986d7f5d3SJohn Marino  *
6086d7f5d3SJohn Marino  * All of dso, device_name and uuid strings are duplicated, you do not
6186d7f5d3SJohn Marino  * need to keep the pointers valid after the call succeeds. Thes may
6286d7f5d3SJohn Marino  * return -ENOMEM though.
6386d7f5d3SJohn Marino  */
6486d7f5d3SJohn Marino int dm_event_handler_set_dso(struct dm_event_handler *dmevh, const char *path);
6586d7f5d3SJohn Marino 
6686d7f5d3SJohn Marino /*
6786d7f5d3SJohn Marino  * Identify the device to monitor by exactly one of device_name, uuid or
6886d7f5d3SJohn Marino  * device number. String arguments are duplicated, see above.
6986d7f5d3SJohn Marino  */
7086d7f5d3SJohn Marino int dm_event_handler_set_dev_name(struct dm_event_handler *dmevh, const char *device_name);
7186d7f5d3SJohn Marino 
7286d7f5d3SJohn Marino int dm_event_handler_set_uuid(struct dm_event_handler *dmevh, const char *uuid);
7386d7f5d3SJohn Marino 
7486d7f5d3SJohn Marino void dm_event_handler_set_major(struct dm_event_handler *dmevh, int major);
7586d7f5d3SJohn Marino void dm_event_handler_set_minor(struct dm_event_handler *dmevh, int minor);
7686d7f5d3SJohn Marino void dm_event_handler_set_timeout(struct dm_event_handler *dmevh, int timeout);
7786d7f5d3SJohn Marino 
7886d7f5d3SJohn Marino /*
7986d7f5d3SJohn Marino  * Specify mask for events to monitor.
8086d7f5d3SJohn Marino  */
8186d7f5d3SJohn Marino void dm_event_handler_set_event_mask(struct dm_event_handler *dmevh,
8286d7f5d3SJohn Marino 				     enum dm_event_mask evmask);
8386d7f5d3SJohn Marino 
8486d7f5d3SJohn Marino const char *dm_event_handler_get_dso(const struct dm_event_handler *dmevh);
8586d7f5d3SJohn Marino const char *dm_event_handler_get_dev_name(const struct dm_event_handler *dmevh);
8686d7f5d3SJohn Marino const char *dm_event_handler_get_uuid(const struct dm_event_handler *dmevh);
8786d7f5d3SJohn Marino int dm_event_handler_get_major(const struct dm_event_handler *dmevh);
8886d7f5d3SJohn Marino int dm_event_handler_get_minor(const struct dm_event_handler *dmevh);
8986d7f5d3SJohn Marino int dm_event_handler_get_timeout(const struct dm_event_handler *dmevh);
9086d7f5d3SJohn Marino enum dm_event_mask dm_event_handler_get_event_mask(const struct dm_event_handler *dmevh);
9186d7f5d3SJohn Marino 
9286d7f5d3SJohn Marino /* FIXME Review interface (what about this next thing?) */
9386d7f5d3SJohn Marino int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next);
9486d7f5d3SJohn Marino 
9586d7f5d3SJohn Marino /*
9686d7f5d3SJohn Marino  * Initiate monitoring using dmeventd.
9786d7f5d3SJohn Marino  */
9886d7f5d3SJohn Marino int dm_event_register_handler(const struct dm_event_handler *dmevh);
9986d7f5d3SJohn Marino int dm_event_unregister_handler(const struct dm_event_handler *dmevh);
10086d7f5d3SJohn Marino 
10186d7f5d3SJohn Marino /* Prototypes for DSO interface, see dmeventd.c, struct dso_data for
10286d7f5d3SJohn Marino    detailed descriptions. */
10386d7f5d3SJohn Marino void process_event(struct dm_task *dmt, enum dm_event_mask evmask, void **user);
10486d7f5d3SJohn Marino int register_device(const char *device_name, const char *uuid, int major, int minor, void **user);
10586d7f5d3SJohn Marino int unregister_device(const char *device_name, const char *uuid, int major,
10686d7f5d3SJohn Marino 		      int minor, void **user);
10786d7f5d3SJohn Marino 
10886d7f5d3SJohn Marino #endif
109