1*56a34939Shaad /* $NetBSD: libdevmapper-event.h,v 1.1.1.1 2008/12/22 00:18:56 haad Exp $ */ 2*56a34939Shaad 3*56a34939Shaad /* 4*56a34939Shaad * Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved. 5*56a34939Shaad * 6*56a34939Shaad * This file is part of the device-mapper userspace tools. 7*56a34939Shaad * 8*56a34939Shaad * This copyrighted material is made available to anyone wishing to use, 9*56a34939Shaad * modify, copy, or redistribute it subject to the terms and conditions 10*56a34939Shaad * of the GNU Lesser General Public License v.2.1. 11*56a34939Shaad * 12*56a34939Shaad * You should have received a copy of the GNU Lesser General Public License 13*56a34939Shaad * along with this program; if not, write to the Free Software Foundation, 14*56a34939Shaad * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15*56a34939Shaad */ 16*56a34939Shaad 17*56a34939Shaad /* 18*56a34939Shaad * Note that this file is released only as part of a technology preview 19*56a34939Shaad * and its contents may change in future updates in ways that do not 20*56a34939Shaad * preserve compatibility. 21*56a34939Shaad */ 22*56a34939Shaad 23*56a34939Shaad #ifndef LIB_DMEVENT_H 24*56a34939Shaad #define LIB_DMEVENT_H 25*56a34939Shaad 26*56a34939Shaad #include <stdint.h> 27*56a34939Shaad 28*56a34939Shaad /* 29*56a34939Shaad * Event library interface. 30*56a34939Shaad */ 31*56a34939Shaad 32*56a34939Shaad enum dm_event_mask { 33*56a34939Shaad DM_EVENT_SETTINGS_MASK = 0x0000FF, 34*56a34939Shaad DM_EVENT_SINGLE = 0x000001, /* Report multiple errors just once. */ 35*56a34939Shaad DM_EVENT_MULTI = 0x000002, /* Report all of them. */ 36*56a34939Shaad 37*56a34939Shaad DM_EVENT_ERROR_MASK = 0x00FF00, 38*56a34939Shaad DM_EVENT_SECTOR_ERROR = 0x000100, /* Failure on a particular sector. */ 39*56a34939Shaad DM_EVENT_DEVICE_ERROR = 0x000200, /* Device failure. */ 40*56a34939Shaad DM_EVENT_PATH_ERROR = 0x000400, /* Failure on an io path. */ 41*56a34939Shaad DM_EVENT_ADAPTOR_ERROR = 0x000800, /* Failure of a host adaptor. */ 42*56a34939Shaad 43*56a34939Shaad DM_EVENT_STATUS_MASK = 0xFF0000, 44*56a34939Shaad DM_EVENT_SYNC_STATUS = 0x010000, /* Mirror synchronization completed/failed. */ 45*56a34939Shaad DM_EVENT_TIMEOUT = 0x020000, /* Timeout has occured */ 46*56a34939Shaad 47*56a34939Shaad DM_EVENT_REGISTRATION_PENDING = 0x1000000, /* Monitor thread is setting-up/shutting-down */ 48*56a34939Shaad }; 49*56a34939Shaad 50*56a34939Shaad #define DM_EVENT_ALL_ERRORS DM_EVENT_ERROR_MASK 51*56a34939Shaad 52*56a34939Shaad struct dm_event_handler; 53*56a34939Shaad 54*56a34939Shaad struct dm_event_handler *dm_event_handler_create(void); 55*56a34939Shaad void dm_event_handler_destroy(struct dm_event_handler *dmevh); 56*56a34939Shaad 57*56a34939Shaad /* 58*56a34939Shaad * Path of shared library to handle events. 59*56a34939Shaad * 60*56a34939Shaad * All of dso, device_name and uuid strings are duplicated, you do not 61*56a34939Shaad * need to keep the pointers valid after the call succeeds. Thes may 62*56a34939Shaad * return -ENOMEM though. 63*56a34939Shaad */ 64*56a34939Shaad int dm_event_handler_set_dso(struct dm_event_handler *dmevh, const char *path); 65*56a34939Shaad 66*56a34939Shaad /* 67*56a34939Shaad * Identify the device to monitor by exactly one of device_name, uuid or 68*56a34939Shaad * device number. String arguments are duplicated, see above. 69*56a34939Shaad */ 70*56a34939Shaad int dm_event_handler_set_dev_name(struct dm_event_handler *dmevh, const char *device_name); 71*56a34939Shaad 72*56a34939Shaad int dm_event_handler_set_uuid(struct dm_event_handler *dmevh, const char *uuid); 73*56a34939Shaad 74*56a34939Shaad void dm_event_handler_set_major(struct dm_event_handler *dmevh, int major); 75*56a34939Shaad void dm_event_handler_set_minor(struct dm_event_handler *dmevh, int minor); 76*56a34939Shaad void dm_event_handler_set_timeout(struct dm_event_handler *dmevh, int timeout); 77*56a34939Shaad 78*56a34939Shaad /* 79*56a34939Shaad * Specify mask for events to monitor. 80*56a34939Shaad */ 81*56a34939Shaad void dm_event_handler_set_event_mask(struct dm_event_handler *dmevh, 82*56a34939Shaad enum dm_event_mask evmask); 83*56a34939Shaad 84*56a34939Shaad const char *dm_event_handler_get_dso(const struct dm_event_handler *dmevh); 85*56a34939Shaad const char *dm_event_handler_get_dev_name(const struct dm_event_handler *dmevh); 86*56a34939Shaad const char *dm_event_handler_get_uuid(const struct dm_event_handler *dmevh); 87*56a34939Shaad int dm_event_handler_get_major(const struct dm_event_handler *dmevh); 88*56a34939Shaad int dm_event_handler_get_minor(const struct dm_event_handler *dmevh); 89*56a34939Shaad int dm_event_handler_get_timeout(const struct dm_event_handler *dmevh); 90*56a34939Shaad enum dm_event_mask dm_event_handler_get_event_mask(const struct dm_event_handler *dmevh); 91*56a34939Shaad 92*56a34939Shaad /* FIXME Review interface (what about this next thing?) */ 93*56a34939Shaad int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next); 94*56a34939Shaad 95*56a34939Shaad /* 96*56a34939Shaad * Initiate monitoring using dmeventd. 97*56a34939Shaad */ 98*56a34939Shaad int dm_event_register_handler(const struct dm_event_handler *dmevh); 99*56a34939Shaad int dm_event_unregister_handler(const struct dm_event_handler *dmevh); 100*56a34939Shaad 101*56a34939Shaad /* Prototypes for DSO interface, see dmeventd.c, struct dso_data for 102*56a34939Shaad detailed descriptions. */ 103*56a34939Shaad void process_event(struct dm_task *dmt, enum dm_event_mask evmask, void **user); 104*56a34939Shaad int register_device(const char *device_name, const char *uuid, int major, int minor, void **user); 105*56a34939Shaad int unregister_device(const char *device_name, const char *uuid, int major, 106*56a34939Shaad int minor, void **user); 107*56a34939Shaad 108*56a34939Shaad #endif 109