2 * Copyright (C) 2015 Red Hat, Inc.
4 * This file is part of the device-mapper multipath userspace tools.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef LIB_MPATH_VALID_H
21 #define LIB_MPATH_VALID_H
27 enum mpath_valid_mode {
36 * MPATH_IS_VALID_NO_CHECK is used to indicate that it is safe to skip
37 * checks to see if the device has already been released to the system
38 * for use by things other that multipath.
39 * MPATH_IS_MAYBE_VALID is used to indicate that this device would
40 * be a valid multipath path device if another device with the same
42 enum mpath_valid_result {
46 MPATH_IS_VALID_NO_CHECK,
50 enum mpath_valid_log_style {
51 MPATH_LOG_STDERR = -1, /* log to STDERR */
52 MPATH_LOG_STDERR_TIMESTAMP, /* log to STDERR, with timestamps */
53 MPATH_LOG_SYSLOG, /* log to system log */
56 enum mpath_valid_verbosity {
57 MPATH_LOG_PRIO_NOLOG = -1, /* log nothing */
60 MPATH_LOG_PRIO_NOTICE,
65 /* Function declarations */
69 * Initialize the device mapper multipath configuration. This
70 * function must be invoked before calling any other
71 * libmpathvalid functions. Call mpathvalid_exit() to cleanup.
72 * @verbosity: the logging level (mpath_valid_verbosity)
73 * @log_style: the logging style (mpath_valid_log_style)
76 * Calling mpathvalid_init() after calling mpathvalid_exit() has no
79 * RETURNS: 0 = Success, -1 = Failure
81 int mpathvalid_init(int verbosity, int log_style);
86 * Reread the multipath configuration files and reinitialize
87 * the device mapper multipath configuration. This function can
88 * be called as many times as necessary.
90 * RETURNS: 0 = Success, -1 = Failure
92 int mpathvalid_reload_config(void);
97 * Release the device mapper multipath configuration. This
98 * function must be called to cleanup resources allocated by
99 * mpathvalid_init(). After calling this function, no further
100 * libmpathvalid functions may be called.
102 * RETURNS: 0 = Success, -1 = Failure
104 int mpathvalid_exit(void);
108 * Return the configured find_multipaths claim mode, using the
109 * configuration from either mpathvalid_init() or
110 * mpathvalid_reload_config()
113 * MPATH_STRICT, MPATH_SMART, MPATH_GREEDY, or MPATH_MODE_ERROR
115 * MPATH_STRICT = find_multiapths (yes|on|no|off)
116 * MPATH_SMART = find_multipaths smart
117 * MPATH_GREEDY = find_multipaths greedy
118 * MPATH_MODE_ERROR = multipath configuration not initialized
120 unsigned int mpathvalid_get_mode(void);
123 * Return whether device-mapper multipath claims a path device,
124 * using the configuration read from either mpathvalid_init() or
125 * mpathvalid_reload_config(). If the device is either claimed or
126 * potentially claimed (MPATH_IS_VALID, MPATH_IS_VALID_NO_CHECK,
127 * or MPATH_IS_MAYBE_VALID) and wwid is not NULL, then *wiid will
128 * be set to point to the wwid of device. If set, *wwid must be
129 * freed by the caller. path_wwids is an obptional parameter that
130 * points to an array of wwids, that were returned from previous
131 * calls to mpathvalid_is_path(). These are wwids of existing
132 * devices that are or potentially are claimed by device-mapper
133 * multipath. path_wwids is used with the MPATH_SMART claim mode,
134 * to claim devices when another device with the same wwid exists.
135 * nr_paths must either be set to the number of elements of
136 * path_wwids, or 0, if path_wwids is NULL.
137 * @name: The kernel name of the device. input argument
138 * @mode: the find_multipaths claim mode (mpath_valid_mode). input argument
139 * @wwid: address of a pointer to the path wwid, or NULL. Output argument.
140 * Set if path is/may be claimed. If set, must be freed by caller
141 * @path_wwids: Array of pointers to path wwids, or NULL. input argument
142 * @nr_paths: number of elements in path_wwids array. input argument.
144 * RETURNS: device claim result (mpath_valid_result)
145 * Also sets *wwid if wwid is not NULL, and the claim result is
146 * MPATH_IS_VALID, MPATH_IS_VALID_NO_CHECK, or
147 * MPATH_IS_MAYBE_VALID
149 int mpathvalid_is_path(const char *name, unsigned int mode, char **wwid,
150 const char **path_wwids, unsigned int nr_paths);
155 #endif /* LIB_PATH_VALID_H */