[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160708152133.GK31763@krava>
Date: Fri, 8 Jul 2016 17:21:33 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Song Shan Gong <gongss@...ux.vnet.ibm.com>
Cc: acme@...nel.org, jolsa@...nel.org, dsahern@...il.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map
On Thu, Jul 07, 2016 at 09:49:36AM +0800, Song Shan Gong wrote:
SNIP
> + char *line = NULL;
> + size_t n;
> + char *sep;
> +
> + module_name[len - 1] = '\0';
> + module_name += 1;
> + snprintf(path, PATH_MAX, "%s/sys/module/%s/sections/.text",
> + machine->root_dir, module_name);
> + file = fopen(path, "r");
> + if (file == NULL)
> + return -1;
> +
> + len = getline(&line, &n, file);
> + if (len < 0) {
> + err = -1;
> + goto out;
> + }
> + line[--len] = '\0'; /* \n */
> + sep = strrchr(line, 'x');
> + if (sep == NULL) {
> + err = -1;
> + goto out;
> + }
> + hex2u64(sep + 1, &text_start);
we have following functions in tools/lib/api/fs to read
single number from file, which I assume you do above:
int sysfs__read_int(const char *entry, int *value);
int sysfs__read_ull(const char *entry, unsigned long long *value);
please check if you could use some of them,
we could add some more generic one if needed
thanks,
jirka
Powered by blists - more mailing lists