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, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 * Methods implemented for gen_multipath "objects"
30 struct gen_multipath_ops {
32 * method: get_pathgroups(gmp)
33 * caller is responsible to returned data using rel_pathgroups()
34 * caller is also responsible to lock the gmp (directly or indirectly)
35 * while working with the return value.
36 * @param gmp: generic multipath object to act on
37 * @returns a vector of const struct gen_pathgroup*
39 const struct _vector* (*get_pathgroups)(const struct gen_multipath*);
41 * method: rel_pathgroups(gmp, v)
42 * free data allocated by get_pathgroups(), if any
43 * @param gmp: generic multipath object to act on
44 * @param v the value returned by get_pathgroups()
46 void (*rel_pathgroups)(const struct gen_multipath*,
47 const struct _vector*);
49 * method: snprint(gmp, buf, len, wildcard)
50 * prints the property of the multipath map matching
51 * the passed-in wildcard character into "buf",
52 * 0-terminated, no more than "len" characters including trailing '\0'.
54 * @param gmp: generic multipath object to act on
55 * @param buf: output buffer
56 * @param buflen: buffer size
57 * @param wildcard: the multipath wildcard (see print.c)
58 * @returns the number of characters printed (without trailing '\0').
60 int (*snprint)(const struct gen_multipath*,
61 char *buf, int len, char wildcard);
63 * method: style(gmp, buf, len, verbosity)
64 * returns the format string to be used for the multipath object,
65 * defined with the wildcards as defined in print.c
66 * generic_style() should work well in most cases.
67 * @param gmp: generic multipath object to act on
68 * @param buf: output buffer
69 * @param buflen: buffer size
70 * @param verbosity: verbosity level
71 * @returns number of format chars printed
73 int (*style)(const struct gen_multipath*,
74 char *buf, int len, int verbosity);
78 * Methods implemented for gen_pathgroup "objects"
80 struct gen_pathgroup_ops {
82 * method: get_paths(gpg)
83 * caller is responsible to returned data using rel_paths()
84 * @param gpg: generic pathgroup object to act on
85 * @returns a vector of const struct gen_path*
87 const struct _vector* (*get_paths)(const struct gen_pathgroup*);
89 * method: rel_paths(gpg, v)
90 * free data allocated by get_paths(), if any
91 * @param gmp: generic pathgroup object to act on
92 * @param v the value returned by get_paths()
94 void (*rel_paths)(const struct gen_pathgroup*, const struct _vector*);
97 * see gen_multipath_ops->snprint() above
99 int (*snprint)(const struct gen_pathgroup*,
100 char *buf, int len, char wildcard);
103 struct gen_path_ops {
106 * see gen_multipath_ops->snprint() above
108 int (*snprint)(const struct gen_path*,
109 char *buf, int len, char wildcard);
112 struct gen_multipath {
113 const struct gen_multipath_ops *ops;
116 struct gen_pathgroup {
117 const struct gen_pathgroup_ops *ops;
121 const struct gen_path_ops *ops;
125 * Helper functions for setting up the various generic_X_ops
130 * A simple style() method (see above) that should fit most
133 int generic_style(const struct gen_multipath*,
134 char *buf, int len, int verbosity);
136 #endif /* _GENERIC_H */