From: tip-bot for Alexander Shishkin <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, adrian.hunter@intel.com, acme@redhat.com,
a.p.zijlstra@chello.nl, alexander.shishkin@linux.intel.com,
tglx@linutronix.de, eranian@google.com, vince@deater.net,
hpa@zytor.com, linux-kernel@vger.kernel.org
Subject: [tip:perf/core] tools lib api fs: Introduce sysfs__read_bool
Date: Mon, 20 Mar 2017 23:50:32 -0700 [thread overview]
Message-ID: <tip-b9835a90084bd3cc45d7ab80c37f282046bc13d3@git.kernel.org> (raw)
In-Reply-To: <8760j941ig.fsf@ashishki-desk.ger.corp.intel.com>
Commit-ID: b9835a90084bd3cc45d7ab80c37f282046bc13d3
Gitweb: http://git.kernel.org/tip/b9835a90084bd3cc45d7ab80c37f282046bc13d3
Author: Alexander Shishkin <alexander.shishkin@linux.intel.com>
AuthorDate: Thu, 16 Mar 2017 18:41:59 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 17 Mar 2017 11:49:09 -0300
tools lib api fs: Introduce sysfs__read_bool
Will be used in a upcoming patch warning about PERF_RECORD_AUX data
gaps, reading the "module/kvm_intel/parameters/vmm_exclusive" sysfs
entry.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vince@deater.net>
Link: http://lkml.kernel.org/r/8760j941ig.fsf@ashishki-desk.ger.corp.intel.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/api/fs/fs.c | 29 +++++++++++++++++++++++++++++
tools/lib/api/fs/fs.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 4b6bfc4..809c772 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -439,6 +439,35 @@ int sysfs__read_str(const char *entry, char **buf, size_t *sizep)
return filename__read_str(path, buf, sizep);
}
+int sysfs__read_bool(const char *entry, bool *value)
+{
+ char *buf;
+ size_t size;
+ int ret;
+
+ ret = sysfs__read_str(entry, &buf, &size);
+ if (ret < 0)
+ return ret;
+
+ switch (buf[0]) {
+ case '1':
+ case 'y':
+ case 'Y':
+ *value = true;
+ break;
+ case '0':
+ case 'n':
+ case 'N':
+ *value = false;
+ break;
+ default:
+ ret = -1;
+ }
+
+ free(buf);
+
+ return ret;
+}
int sysctl__read_int(const char *sysctl, int *value)
{
char path[PATH_MAX];
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 6b332dc..956c211 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -37,4 +37,5 @@ int sysctl__read_int(const char *sysctl, int *value);
int sysfs__read_int(const char *entry, int *value);
int sysfs__read_ull(const char *entry, unsigned long long *value);
int sysfs__read_str(const char *entry, char **buf, size_t *sizep);
+int sysfs__read_bool(const char *entry, bool *value);
#endif /* __API_FS__ */
next prev parent reply other threads:[~2017-03-21 6:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-20 13:33 [PATCH 0/4] perf, pt, coresight: AUX flags and VMX update Alexander Shishkin
2017-02-20 13:33 ` [PATCH 1/4] perf: Export AUX buffer helpers to modules Alexander Shishkin
2017-02-20 13:33 ` [PATCH 2/4] perf: Keep AUX flags in the output handle Alexander Shishkin
2017-02-20 17:01 ` kbuild test robot
2017-02-20 17:17 ` Alexander Shishkin
2017-02-20 20:42 ` Mathieu Poirier
2017-02-21 10:42 ` Will Deacon
2017-02-21 10:54 ` Alexander Shishkin
2017-03-16 11:22 ` [tip:perf/core] perf/core: " tip-bot for Will Deacon
2017-02-20 13:33 ` [PATCH 3/4] perf: Add a flag for partial AUX records Alexander Shishkin
2017-03-16 11:23 ` [tip:perf/core] perf/core: " tip-bot for Alexander Shishkin
2017-03-16 14:24 ` Vince Weaver
2017-02-20 13:33 ` [PATCH 4/4] perf/x86/intel/pt: Handle VMX better Alexander Shishkin
2017-03-16 11:24 ` [tip:perf/core] " tip-bot for Alexander Shishkin
2017-02-20 15:18 ` [PATCH 0/4] perf, pt, coresight: AUX flags and VMX update Alexander Shishkin
2017-02-20 15:39 ` Adrian Hunter
2017-02-20 16:09 ` Arnaldo Carvalho de Melo
2017-02-20 16:31 ` Alexander Shishkin
2017-03-16 16:41 ` Alexander Shishkin
2017-03-21 6:50 ` tip-bot for Alexander Shishkin [this message]
2017-03-21 6:51 ` [tip:perf/core] tools include: Sync {,tools/}include/uapi/linux/perf_event.h tip-bot for Alexander Shishkin
2017-03-21 6:51 ` [tip:perf/core] perf tools: Handle partial AUX records and print a warning tip-bot for Alexander Shishkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-b9835a90084bd3cc45d7ab80c37f282046bc13d3@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=vince@deater.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.