lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1359230650-10415-5-git-send-email-jolsa@redhat.com>
Date:	Sat, 26 Jan 2013 21:04:06 +0100
From:	Jiri Olsa <jolsa@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Jiri Olsa <jolsa@...hat.com>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...e.hu>,
	Namhyung Kim <namhyung@...nel.org>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Andi Kleen <ak@...ux.intel.com>,
	Stephane Eranian <eranian@...gle.com>
Subject: [PATCH 4/8] perf tools: Add pmu interface to parse single file of aliases

Adding pmu_aliases_parse_multi function to parse and add
aliases from single file. The file format follows the
alias format, each line for single alias. Each line
must contains 'name' term, like:

  name=BR_MISP_EXEC.ALL_BRANCHES,event=0x89,umask=0xff
  name=BR_MISP_EXEC.COND,event=0x89,umask=0x1

Signed-off-by: Jiri Olsa <jolsa@...hat.com>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Stephane Eranian <eranian@...gle.com>
---
 tools/perf/util/pmu.c | 23 +++++++++++++++++++++++
 tools/perf/util/pmu.h |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 0d45ccd..68d6c86 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -146,11 +146,34 @@ static int perf_pmu__new_alias(struct list_head *list, char *name, char *data)
 		}
 	}
 
+	pr_debug3("adding alias '%s' => '%s'\n", name, data);
+
 	alias->name = strdup(name);
 	list_add_tail(&alias->list, list);
 	return 0;
 }
 
+int pmu_aliases_parse_multi(char *path, struct list_head *head)
+{
+	FILE *file;
+	char *data = NULL;
+	size_t len;
+	int ret = -EINVAL;
+
+	file = fopen(path, "r");
+	if (!file)
+		return -EINVAL;
+
+	while ((getline(&data, &len, file)) != -1) {
+		ret = perf_pmu__new_alias(head, NULL, data);
+		free(data);
+		data = NULL;
+	}
+
+	fclose(file);
+	return ret;
+}
+
 /*
  * Process all the sysfs attributes located under the directory
  * specified in 'dir' parameter.
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 54cd809..add249b 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -43,5 +43,7 @@ struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
 
 char *perf_pmu__event_name(struct list_head *head_terms, bool remove);
 
+int pmu_aliases_parse_multi(char *path, struct list_head *head);
+
 int perf_pmu__test(void);
 #endif /* __PMU_H */
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ