File: generic.c

package info (click to toggle)
multipath-tools 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,992 kB
  • sloc: ansic: 63,788; perl: 1,622; makefile: 729; sh: 647; pascal: 150
file content (25 lines) | stat: -rw-r--r-- 648 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// SPDX-License-Identifier: GPL-2.0-or-later
/*
  Copyright (c) 2018 Martin Wilck, SUSE Linux GmbH
 */

#include "generic.h"
#include "structs.h"
#include "util.h"
#include "strbuf.h"

int generic_style(const struct gen_multipath* gm, struct strbuf *buf,
		  __attribute__((unused)) int verbosity)
{
	STRBUF_ON_STACK(tmp);
	char *alias_buf __attribute__((cleanup(cleanup_charp)));
	const char *wwid_buf;

	gm->ops->snprint(gm, &tmp, 'n');
	alias_buf = steal_strbuf_str(&tmp);
	gm->ops->snprint(gm, &tmp, 'w');
	wwid_buf = get_strbuf_str(&tmp);

	return print_strbuf(buf, "%%n %s[%%G]:%%d %%s",
			    strcmp(alias_buf, wwid_buf) ? "(%w) " : "");
}