2 Copyright (c) 2018 Martin Wilck, SUSE Linux GmbH
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>.
26 * Methods implemented for gen_multipath "objects"
28 struct gen_multipath_ops {
30 * method: get_pathgroups(gmp)
31 * caller is responsible to returned data using rel_pathgroups()
32 * caller is also responsible to lock the gmp (directly or indirectly)
33 * while working with the return value.
34 * @param gmp: generic multipath object to act on
35 * @returns a vector of const struct gen_pathgroup*
37 const struct _vector* (*get_pathgroups)(const struct gen_multipath*);
39 * method: rel_pathgroups(gmp, v)
40 * free data allocated by get_pathgroups(), if any
41 * @param gmp: generic multipath object to act on
42 * @param v the value returned by get_pathgroups()
44 void (*rel_pathgroups)(const struct gen_multipath*,
45 const struct _vector*);
47 * method: snprint(gmp, buf, len, wildcard)
48 * prints the property of the multipath map matching
49 * the passed-in wildcard character into "buf",
50 * 0-terminated, no more than "len" characters including trailing '\0'.
52 * @param gmp: generic multipath object to act on
53 * @param buf: output buffer
54 * @param buflen: buffer size
55 * @param wildcard: the multipath wildcard (see print.c)
56 * @returns the number of characters printed (without trailing '\0').
58 int (*snprint)(const struct gen_multipath*,
59 char *buf, int len, char wildcard);
61 * method: style(gmp, buf, len, verbosity)
62 * returns the format string to be used for the multipath object,
63 * defined with the wildcards as defined in print.c
64 * generic_style() should work well in most cases.
65 * @param gmp: generic multipath object to act on
66 * @param buf: output buffer
67 * @param buflen: buffer size
68 * @param verbosity: verbosity level
69 * @returns number of format chars printed
71 int (*style)(const struct gen_multipath*,
72 char *buf, int len, int verbosity);
76 * Methods implemented for gen_pathgroup "objects"
78 struct gen_pathgroup_ops {
80 * method: get_paths(gpg)
81 * caller is responsible to returned data using rel_paths()
82 * @param gpg: generic pathgroup object to act on
83 * @returns a vector of const struct gen_path*
85 const struct _vector* (*get_paths)(const struct gen_pathgroup*);
87 * method: rel_paths(gpg, v)
88 * free data allocated by get_paths(), if any
89 * @param gmp: generic pathgroup object to act on
90 * @param v the value returned by get_paths()
92 void (*rel_paths)(const struct gen_pathgroup*, const struct _vector*);
95 * see gen_multipath_ops->snprint() above
97 int (*snprint)(const struct gen_pathgroup*,
98 char *buf, int len, char wildcard);
101 struct gen_path_ops {
104 * see gen_multipath_ops->snprint() above
106 int (*snprint)(const struct gen_path*,
107 char *buf, int len, char wildcard);
110 struct gen_multipath {
111 const struct gen_multipath_ops *ops;
114 struct gen_pathgroup {
115 const struct gen_pathgroup_ops *ops;
119 const struct gen_path_ops *ops;
123 * Helper functions for setting up the various generic_X_ops
128 * A simple style() method (see above) that should fit most
131 int generic_style(const struct gen_multipath*,
132 char *buf, int len, int verbosity);
134 #endif /* _GENERIC_H */