xref: /freebsd/lib/libdevdctl/event.h (revision b3e76948)
17a0c41d5SAlan Somers /*-
27a0c41d5SAlan Somers  * Copyright (c) 2011, 2012, 2013, 2016 Spectra Logic Corporation
37a0c41d5SAlan Somers  * All rights reserved.
47a0c41d5SAlan Somers  *
57a0c41d5SAlan Somers  * Redistribution and use in source and binary forms, with or without
67a0c41d5SAlan Somers  * modification, are permitted provided that the following conditions
77a0c41d5SAlan Somers  * are met:
87a0c41d5SAlan Somers  * 1. Redistributions of source code must retain the above copyright
97a0c41d5SAlan Somers  *    notice, this list of conditions, and the following disclaimer,
107a0c41d5SAlan Somers  *    without modification.
117a0c41d5SAlan Somers  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
127a0c41d5SAlan Somers  *    substantially similar to the "NO WARRANTY" disclaimer below
137a0c41d5SAlan Somers  *    ("Disclaimer") and any redistribution must be conditioned upon
147a0c41d5SAlan Somers  *    including a substantially similar Disclaimer requirement for further
157a0c41d5SAlan Somers  *    binary redistribution.
167a0c41d5SAlan Somers  *
177a0c41d5SAlan Somers  * NO WARRANTY
187a0c41d5SAlan Somers  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
197a0c41d5SAlan Somers  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
207a0c41d5SAlan Somers  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
217a0c41d5SAlan Somers  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
227a0c41d5SAlan Somers  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
237a0c41d5SAlan Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
247a0c41d5SAlan Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
257a0c41d5SAlan Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
267a0c41d5SAlan Somers  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
277a0c41d5SAlan Somers  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
287a0c41d5SAlan Somers  * POSSIBILITY OF SUCH DAMAGES.
297a0c41d5SAlan Somers  *
307a0c41d5SAlan Somers  * Authors: Justin T. Gibbs     (Spectra Logic Corporation)
317a0c41d5SAlan Somers  */
327a0c41d5SAlan Somers 
337a0c41d5SAlan Somers /**
347a0c41d5SAlan Somers  * \file devdctl_event.h
357a0c41d5SAlan Somers  *
367a0c41d5SAlan Somers  * \brief Class hierarchy used to express events received via
377a0c41d5SAlan Somers  *        the devdctl API.
387a0c41d5SAlan Somers  */
397a0c41d5SAlan Somers 
407a0c41d5SAlan Somers #ifndef _DEVDCTL_EVENT_H_
417a0c41d5SAlan Somers #define	_DEVDCTL_EVENT_H_
427a0c41d5SAlan Somers 
437a0c41d5SAlan Somers /*============================ Namespace Control =============================*/
447a0c41d5SAlan Somers namespace DevdCtl
457a0c41d5SAlan Somers {
467a0c41d5SAlan Somers 
477a0c41d5SAlan Somers /*=========================== Forward Declarations ===========================*/
487a0c41d5SAlan Somers class EventFactory;
497a0c41d5SAlan Somers 
507a0c41d5SAlan Somers /*============================= Class Definitions ============================*/
517a0c41d5SAlan Somers /*-------------------------------- NVPairMap ---------------------------------*/
527a0c41d5SAlan Somers /**
537a0c41d5SAlan Somers  * NVPairMap is a specialization of the standard map STL container.
547a0c41d5SAlan Somers  */
557a0c41d5SAlan Somers typedef std::map<std::string, std::string> NVPairMap;
567a0c41d5SAlan Somers 
577a0c41d5SAlan Somers /*----------------------------------- Event ----------------------------------*/
587a0c41d5SAlan Somers /**
597a0c41d5SAlan Somers  * \brief Container for the name => value pairs that comprise the content of
607a0c41d5SAlan Somers  *        a device control event.
617a0c41d5SAlan Somers  *
627a0c41d5SAlan Somers  * All name => value data for events can be accessed via the Contains()
637a0c41d5SAlan Somers  * and Value() methods.  name => value pairs for data not explicitly
647a0c41d5SAlan Somers  * received as a name => value pair are synthesized during parsing.  For
657a0c41d5SAlan Somers  * example, ATTACH and DETACH events have "device-name" and "parent"
667a0c41d5SAlan Somers  * name => value pairs added.
677a0c41d5SAlan Somers  */
687a0c41d5SAlan Somers class Event
697a0c41d5SAlan Somers {
707a0c41d5SAlan Somers 	friend class EventFactory;
717a0c41d5SAlan Somers 
727a0c41d5SAlan Somers public:
737a0c41d5SAlan Somers 	/** Event type */
747a0c41d5SAlan Somers 	enum Type {
757a0c41d5SAlan Somers 		/** Generic event notification. */
767a0c41d5SAlan Somers 		NOTIFY  = '!',
777a0c41d5SAlan Somers 
787a0c41d5SAlan Somers 		/** A driver was not found for this device. */
797a0c41d5SAlan Somers 		NOMATCH = '?',
807a0c41d5SAlan Somers 
817a0c41d5SAlan Somers 		/** A bus device instance has been added. */
827a0c41d5SAlan Somers 		ATTACH  = '+',
837a0c41d5SAlan Somers 
847a0c41d5SAlan Somers 		/** A bus device instance has been removed. */
857a0c41d5SAlan Somers 		DETACH  = '-'
867a0c41d5SAlan Somers 	};
877a0c41d5SAlan Somers 
887a0c41d5SAlan Somers 	/**
897a0c41d5SAlan Somers 	 * Factory method type to construct an Event given
907a0c41d5SAlan Somers 	 * the type of event and an NVPairMap populated from
917a0c41d5SAlan Somers 	 * the event string received from devd.
927a0c41d5SAlan Somers 	 */
937a0c41d5SAlan Somers 	typedef Event* (BuildMethod)(Type, NVPairMap &, const std::string &);
947a0c41d5SAlan Somers 
957a0c41d5SAlan Somers 	/** Generic Event object factory. */
967a0c41d5SAlan Somers 	static BuildMethod Builder;
977a0c41d5SAlan Somers 
987a0c41d5SAlan Somers 	static Event *CreateEvent(const EventFactory &factory,
997a0c41d5SAlan Somers 				  const std::string &eventString);
1007a0c41d5SAlan Somers 
1017a0c41d5SAlan Somers 	/**
1027a0c41d5SAlan Somers 	 * Returns the devname, if any, associated with the event
1037a0c41d5SAlan Somers 	 *
1047a0c41d5SAlan Somers 	 * \param name	Devname, returned by reference
1057a0c41d5SAlan Somers 	 * \return	True iff the event contained a devname
1067a0c41d5SAlan Somers 	 */
1077a0c41d5SAlan Somers 	virtual bool DevName(std::string &name)	const;
1087a0c41d5SAlan Somers 
1097a0c41d5SAlan Somers 	/**
1107a0c41d5SAlan Somers 	 * Returns the absolute pathname of the device associated with this
1117a0c41d5SAlan Somers 	 * event.
1127a0c41d5SAlan Somers 	 *
1137a0c41d5SAlan Somers 	 * \param name	Devname, returned by reference
1147a0c41d5SAlan Somers 	 * \return	True iff the event contained a devname
1157a0c41d5SAlan Somers 	 */
1167a0c41d5SAlan Somers 	bool DevPath(std::string &path)		const;
1177a0c41d5SAlan Somers 
1187a0c41d5SAlan Somers 	/**
1197a0c41d5SAlan Somers 	 * Returns true iff this event refers to a disk device
1207a0c41d5SAlan Somers 	 */
1217a0c41d5SAlan Somers 	bool IsDiskDev()			const;
1227a0c41d5SAlan Somers 
1237a0c41d5SAlan Somers 	/** Returns the physical path of the device, if any
1247a0c41d5SAlan Somers 	 *
1257a0c41d5SAlan Somers 	 * \param path	Physical path, returned by reference
1267a0c41d5SAlan Somers 	 * \return	True iff the event contains a device with a physical
1277a0c41d5SAlan Somers 	 * 		path
1287a0c41d5SAlan Somers 	 */
1297a0c41d5SAlan Somers 	bool PhysicalPath(std::string &path)	const;
1307a0c41d5SAlan Somers 
1317a0c41d5SAlan Somers 	/**
1327a0c41d5SAlan Somers 	 * Provide a user friendly string representation of an
1337a0c41d5SAlan Somers 	 * event type.
1347a0c41d5SAlan Somers 	 *
1357a0c41d5SAlan Somers 	 * \param type  The type of event to map to a string.
1367a0c41d5SAlan Somers 	 *
1377a0c41d5SAlan Somers 	 * \return  A user friendly string representing the input type.
1387a0c41d5SAlan Somers 	 */
1397a0c41d5SAlan Somers 	static const char  *TypeToString(Type type);
1407a0c41d5SAlan Somers 
1417a0c41d5SAlan Somers 	/**
1427a0c41d5SAlan Somers 	 * Determine the availability of a name => value pair by name.
1437a0c41d5SAlan Somers 	 *
1447a0c41d5SAlan Somers 	 * \param name  The key name to search for in this event instance.
1457a0c41d5SAlan Somers 	 *
1467a0c41d5SAlan Somers 	 * \return  true if the specified key is available in this
1477a0c41d5SAlan Somers 	 *          event, otherwise false.
1487a0c41d5SAlan Somers 	 */
1497a0c41d5SAlan Somers 	bool Contains(const std::string &name)		 const;
1507a0c41d5SAlan Somers 
1517a0c41d5SAlan Somers 	/**
1527a0c41d5SAlan Somers 	 * \param key  The name of the key for which to retrieve its
1537a0c41d5SAlan Somers 	 *             associated value.
1547a0c41d5SAlan Somers 	 *
1557a0c41d5SAlan Somers 	 * \return  A const reference to the string representing the
1567a0c41d5SAlan Somers 	 *          value associated with key.
1577a0c41d5SAlan Somers 	 *
1587a0c41d5SAlan Somers 	 * \note  For key's with no registered value, the empty string
1597a0c41d5SAlan Somers 	 *        is returned.
1607a0c41d5SAlan Somers 	 */
1617a0c41d5SAlan Somers 	const std::string &Value(const std::string &key) const;
1627a0c41d5SAlan Somers 
1637a0c41d5SAlan Somers 	/**
1647a0c41d5SAlan Somers 	 * Get the type of this event instance.
1657a0c41d5SAlan Somers 	 *
1667a0c41d5SAlan Somers 	 * \return  The type of this event instance.
1677a0c41d5SAlan Somers 	 */
1687a0c41d5SAlan Somers 	Type GetType()					 const;
1697a0c41d5SAlan Somers 
1707a0c41d5SAlan Somers 	/**
171c2b4f3c9SPedro F. Giffuni 	 * Get the original DevdCtl event string for this event.
1727a0c41d5SAlan Somers 	 *
1737a0c41d5SAlan Somers 	 * \return  The DevdCtl event string.
1747a0c41d5SAlan Somers 	 */
1757a0c41d5SAlan Somers 	const std::string &GetEventString()		 const;
1767a0c41d5SAlan Somers 
1777a0c41d5SAlan Somers 	/**
1787a0c41d5SAlan Somers 	 * Convert the event instance into a string suitable for
1797a0c41d5SAlan Somers 	 * printing to the console or emitting to syslog.
1807a0c41d5SAlan Somers 	 *
1817a0c41d5SAlan Somers 	 * \return  A string of formatted event data.
1827a0c41d5SAlan Somers 	 */
1837a0c41d5SAlan Somers 	std::string ToString()				 const;
1847a0c41d5SAlan Somers 
1857a0c41d5SAlan Somers 	/**
1867a0c41d5SAlan Somers 	 * Pretty-print this event instance to cout.
1877a0c41d5SAlan Somers 	 */
1887a0c41d5SAlan Somers 	void Print()					 const;
1897a0c41d5SAlan Somers 
1907a0c41d5SAlan Somers 	/**
1917a0c41d5SAlan Somers 	 * Pretty-print this event instance to syslog.
1927a0c41d5SAlan Somers 	 *
1937a0c41d5SAlan Somers 	 * \param priority  The logging priority/facility.
1947a0c41d5SAlan Somers 	 *                  See syslog(3).
1957a0c41d5SAlan Somers 	 */
1967a0c41d5SAlan Somers 	void Log(int priority)				 const;
1977a0c41d5SAlan Somers 
1987a0c41d5SAlan Somers 	/**
1997a0c41d5SAlan Somers 	 * Create and return a fully independent clone
2007a0c41d5SAlan Somers 	 * of this event.
2017a0c41d5SAlan Somers 	 */
2027a0c41d5SAlan Somers 	virtual Event *DeepCopy()			 const;
2037a0c41d5SAlan Somers 
2047a0c41d5SAlan Somers 	/** Destructor */
2057a0c41d5SAlan Somers 	virtual ~Event();
2067a0c41d5SAlan Somers 
2077a0c41d5SAlan Somers 	/**
2087a0c41d5SAlan Somers 	 * Interpret and perform any actions necessary to
2097a0c41d5SAlan Somers 	 * consume the event.
2107a0c41d5SAlan Somers 	 *
2117a0c41d5SAlan Somers 	 * \return True if this event should be queued for later reevaluation
2127a0c41d5SAlan Somers 	 */
2137a0c41d5SAlan Somers 	virtual bool Process()				 const;
2147a0c41d5SAlan Somers 
2157a0c41d5SAlan Somers 	/**
2167a0c41d5SAlan Somers 	 * Get the time that the event was created
2177a0c41d5SAlan Somers 	 */
2187a0c41d5SAlan Somers 	timeval GetTimestamp()				 const;
2197a0c41d5SAlan Somers 
2207a0c41d5SAlan Somers 	/**
2217a0c41d5SAlan Somers 	 * Add a timestamp to the event string, if one does not already exist
2227a0c41d5SAlan Somers 	 * TODO: make this an instance method that operates on the std::map
2237a0c41d5SAlan Somers 	 * instead of the string.  We must fix zfsd's CaseFile serialization
2247a0c41d5SAlan Somers 	 * routines first, so that they don't need the raw event string.
2257a0c41d5SAlan Somers 	 *
2267a0c41d5SAlan Somers 	 * \param[in,out] eventString The devd event string to modify
2277a0c41d5SAlan Somers 	 */
2287a0c41d5SAlan Somers 	static void TimestampEventString(std::string &eventString);
2297a0c41d5SAlan Somers 
2307a0c41d5SAlan Somers 	/**
2317a0c41d5SAlan Somers 	 * Access all parsed key => value pairs.
2327a0c41d5SAlan Somers 	 */
2337a0c41d5SAlan Somers 	const NVPairMap &GetMap()			 const;
2347a0c41d5SAlan Somers 
2357a0c41d5SAlan Somers protected:
2367a0c41d5SAlan Somers 	/** Table entries used to map a type to a user friendly string. */
2377a0c41d5SAlan Somers 	struct EventTypeRecord
2387a0c41d5SAlan Somers 	{
2397a0c41d5SAlan Somers 		Type         m_type;
2407a0c41d5SAlan Somers 		const char  *m_typeName;
2417a0c41d5SAlan Somers 	};
2427a0c41d5SAlan Somers 
2437a0c41d5SAlan Somers 	/**
2447a0c41d5SAlan Somers 	 * Constructor
2457a0c41d5SAlan Somers 	 *
2467a0c41d5SAlan Somers 	 * \param type  The type of event to create.
2477a0c41d5SAlan Somers 	 */
2487a0c41d5SAlan Somers 	Event(Type type, NVPairMap &map, const std::string &eventString);
2497a0c41d5SAlan Somers 
2507a0c41d5SAlan Somers 	/** Deep copy constructor. */
2517a0c41d5SAlan Somers 	Event(const Event &src);
2527a0c41d5SAlan Somers 
2537a0c41d5SAlan Somers 	/** Always empty string returned when NVPairMap lookups fail. */
2547a0c41d5SAlan Somers 	static const std::string    s_theEmptyString;
2557a0c41d5SAlan Somers 
2567a0c41d5SAlan Somers 	/** Unsorted table of event types. */
2577a0c41d5SAlan Somers 	static EventTypeRecord      s_typeTable[];
2587a0c41d5SAlan Somers 
2597a0c41d5SAlan Somers 	/** The type of this event. */
2607a0c41d5SAlan Somers 	const Type                  m_type;
2617a0c41d5SAlan Somers 
2627a0c41d5SAlan Somers 	/**
2637a0c41d5SAlan Somers 	 * Event attribute storage.
2647a0c41d5SAlan Somers 	 *
2657a0c41d5SAlan Somers 	 * \note Although stored by reference (since m_nvPairs can
2667a0c41d5SAlan Somers 	 *       never be NULL), the NVPairMap referenced by this field
2677a0c41d5SAlan Somers 	 *       is dynamically allocated and owned by this event object.
268c2b4f3c9SPedro F. Giffuni 	 *       m_nvPairs must be deleted at event destruction.
2697a0c41d5SAlan Somers 	 */
2707a0c41d5SAlan Somers 	NVPairMap                  &m_nvPairs;
2717a0c41d5SAlan Somers 
2727a0c41d5SAlan Somers 	/**
2737a0c41d5SAlan Somers 	 * The unaltered event string, as received from devd, used to
2747a0c41d5SAlan Somers 	 * create this event object.
2757a0c41d5SAlan Somers 	 */
2767a0c41d5SAlan Somers 	std::string                 m_eventString;
2777a0c41d5SAlan Somers 
2787a0c41d5SAlan Somers private:
2797a0c41d5SAlan Somers 	/**
2807a0c41d5SAlan Somers 	 * Ingest event data from the supplied string.
2817a0c41d5SAlan Somers 	 *
2827a0c41d5SAlan Somers 	 * \param[in] eventString  The string of devd event data to parse.
2837a0c41d5SAlan Somers 	 * \param[out] nvpairs     Returns the parsed data
2847a0c41d5SAlan Somers 	 */
2857a0c41d5SAlan Somers 	static void ParseEventString(Type type, const std::string &eventString,
2867a0c41d5SAlan Somers 				     NVPairMap &nvpairs);
2877a0c41d5SAlan Somers };
2887a0c41d5SAlan Somers 
2897a0c41d5SAlan Somers inline Event::Type
GetType()2907a0c41d5SAlan Somers Event::GetType() const
2917a0c41d5SAlan Somers {
2927a0c41d5SAlan Somers 	return (m_type);
2937a0c41d5SAlan Somers }
2947a0c41d5SAlan Somers 
2957a0c41d5SAlan Somers inline const std::string &
GetEventString()2967a0c41d5SAlan Somers Event::GetEventString() const
2977a0c41d5SAlan Somers {
2987a0c41d5SAlan Somers 	return (m_eventString);
2997a0c41d5SAlan Somers }
3007a0c41d5SAlan Somers 
3017a0c41d5SAlan Somers inline const NVPairMap &
GetMap()3027a0c41d5SAlan Somers Event::GetMap()	const
3037a0c41d5SAlan Somers {
3047a0c41d5SAlan Somers 	return (m_nvPairs);
3057a0c41d5SAlan Somers }
3067a0c41d5SAlan Somers 
3077a0c41d5SAlan Somers /*--------------------------------- EventList --------------------------------*/
3087a0c41d5SAlan Somers /**
3097a0c41d5SAlan Somers  * EventList is a specialization of the standard list STL container.
3107a0c41d5SAlan Somers  */
3117a0c41d5SAlan Somers typedef std::list<Event *> EventList;
3127a0c41d5SAlan Somers 
3137a0c41d5SAlan Somers /*-------------------------------- DevfsEvent --------------------------------*/
3147a0c41d5SAlan Somers class DevfsEvent : public Event
3157a0c41d5SAlan Somers {
3167a0c41d5SAlan Somers public:
3177a0c41d5SAlan Somers 	/** Specialized Event object factory for Devfs events. */
3187a0c41d5SAlan Somers 	static BuildMethod Builder;
3197a0c41d5SAlan Somers 
3207a0c41d5SAlan Somers 	virtual Event *DeepCopy()		const;
3217a0c41d5SAlan Somers 
3227a0c41d5SAlan Somers 	/**
3237a0c41d5SAlan Somers 	 * Interpret and perform any actions necessary to
3247a0c41d5SAlan Somers 	 * consume the event.
3257a0c41d5SAlan Somers 	 * \return True if this event should be queued for later reevaluation
3267a0c41d5SAlan Somers 	 */
3277a0c41d5SAlan Somers 	virtual bool Process()			const;
3287a0c41d5SAlan Somers 
3297a0c41d5SAlan Somers 	bool IsWholeDev()			const;
3307a0c41d5SAlan Somers 	virtual bool DevName(std::string &name)	const;
3317a0c41d5SAlan Somers 
3327a0c41d5SAlan Somers protected:
3337a0c41d5SAlan Somers 	/**
3347a0c41d5SAlan Somers 	 * Given the device name of a disk, determine if the device
3357a0c41d5SAlan Somers 	 * represents the whole device, not just a partition.
3367a0c41d5SAlan Somers 	 *
3377a0c41d5SAlan Somers 	 * \param devName  Device name of disk device to test.
3387a0c41d5SAlan Somers 	 *
3397a0c41d5SAlan Somers 	 * \return  True if the device name represents the whole device.
3407a0c41d5SAlan Somers 	 *          Otherwise false.
3417a0c41d5SAlan Somers 	 */
3427a0c41d5SAlan Somers 	static bool IsWholeDev(const std::string &devName);
3437a0c41d5SAlan Somers 
3447a0c41d5SAlan Somers 	/** DeepCopy Constructor. */
3457a0c41d5SAlan Somers 	DevfsEvent(const DevfsEvent &src);
3467a0c41d5SAlan Somers 
3477a0c41d5SAlan Somers 	/** Constructor */
3487a0c41d5SAlan Somers 	DevfsEvent(Type, NVPairMap &, const std::string &);
3497a0c41d5SAlan Somers };
3507a0c41d5SAlan Somers 
3517a0c41d5SAlan Somers /*--------------------------------- GeomEvent --------------------------------*/
3527a0c41d5SAlan Somers class GeomEvent : public Event
3537a0c41d5SAlan Somers {
3547a0c41d5SAlan Somers public:
3557a0c41d5SAlan Somers 	/** Specialized Event object factory for GEOM events. */
3567a0c41d5SAlan Somers 	static BuildMethod Builder;
3577a0c41d5SAlan Somers 
3587a0c41d5SAlan Somers 	virtual Event *DeepCopy()	const;
3597a0c41d5SAlan Somers 
3607a0c41d5SAlan Somers 	virtual bool DevName(std::string &name)	const;
3617a0c41d5SAlan Somers 
3627a0c41d5SAlan Somers 	const std::string &DeviceName()	const;
3637a0c41d5SAlan Somers 
3647a0c41d5SAlan Somers protected:
3657a0c41d5SAlan Somers 	/** Constructor */
3667a0c41d5SAlan Somers 	GeomEvent(Type, NVPairMap &, const std::string &);
3677a0c41d5SAlan Somers 
3687a0c41d5SAlan Somers 	/** Deep copy constructor. */
3697a0c41d5SAlan Somers 	GeomEvent(const GeomEvent &src);
3707a0c41d5SAlan Somers 
3717a0c41d5SAlan Somers 	std::string m_devname;
3727a0c41d5SAlan Somers };
3737a0c41d5SAlan Somers 
3747a0c41d5SAlan Somers /*--------------------------------- ZfsEvent ---------------------------------*/
3757a0c41d5SAlan Somers class ZfsEvent : public Event
3767a0c41d5SAlan Somers {
3777a0c41d5SAlan Somers public:
3787a0c41d5SAlan Somers 	/** Specialized Event object factory for ZFS events. */
3797a0c41d5SAlan Somers 	static BuildMethod Builder;
3807a0c41d5SAlan Somers 
3817a0c41d5SAlan Somers 	virtual Event *DeepCopy()	const;
3827a0c41d5SAlan Somers 
3837a0c41d5SAlan Somers 	virtual bool DevName(std::string &name)	const;
3847a0c41d5SAlan Somers 
3857a0c41d5SAlan Somers 	const std::string &PoolName()	const;
3867a0c41d5SAlan Somers 	Guid		   PoolGUID()	const;
3877a0c41d5SAlan Somers 	Guid		   VdevGUID()	const;
3887a0c41d5SAlan Somers 
3897a0c41d5SAlan Somers protected:
3907a0c41d5SAlan Somers 	/** Constructor */
3917a0c41d5SAlan Somers 	ZfsEvent(Type, NVPairMap &, const std::string &);
3927a0c41d5SAlan Somers 
3937a0c41d5SAlan Somers 	/** Deep copy constructor. */
3947a0c41d5SAlan Somers 	ZfsEvent(const ZfsEvent &src);
3957a0c41d5SAlan Somers 
3967a0c41d5SAlan Somers 	Guid	m_poolGUID;
3977a0c41d5SAlan Somers 	Guid	m_vdevGUID;
3987a0c41d5SAlan Somers };
3997a0c41d5SAlan Somers 
4007a0c41d5SAlan Somers //- ZfsEvent Inline Public Methods --------------------------------------------
4017a0c41d5SAlan Somers inline const std::string&
PoolName()4027a0c41d5SAlan Somers ZfsEvent::PoolName() const
4037a0c41d5SAlan Somers {
4047a0c41d5SAlan Somers 	/* The pool name is reported as the subsystem of ZFS events. */
4057a0c41d5SAlan Somers 	return (Value("subsystem"));
4067a0c41d5SAlan Somers }
4077a0c41d5SAlan Somers 
4087a0c41d5SAlan Somers inline Guid
PoolGUID()4097a0c41d5SAlan Somers ZfsEvent::PoolGUID() const
4107a0c41d5SAlan Somers {
4117a0c41d5SAlan Somers 	return (m_poolGUID);
4127a0c41d5SAlan Somers }
4137a0c41d5SAlan Somers 
4147a0c41d5SAlan Somers inline Guid
VdevGUID()4157a0c41d5SAlan Somers ZfsEvent::VdevGUID() const
4167a0c41d5SAlan Somers {
4177a0c41d5SAlan Somers 	return (m_vdevGUID);
4187a0c41d5SAlan Somers }
4197a0c41d5SAlan Somers 
4207a0c41d5SAlan Somers } // namespace DevdCtl
4217a0c41d5SAlan Somers #endif /*_DEVDCTL_EVENT_H_ */
422