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: <37D7C6CF3E00A74B8858931C1DB2F077537D8814@SHSMSX103.ccr.corp.intel.com>
Date:   Mon, 23 Oct 2017 16:19:19 +0000
From:   "Liang, Kan" <kan.liang@...el.com>
To:     Jiri Olsa <jolsa@...hat.com>
CC:     "acme@...nel.org" <acme@...nel.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "jolsa@...nel.org" <jolsa@...nel.org>,
        "wangnan0@...wei.com" <wangnan0@...wei.com>,
        "hekuang@...wei.com" <hekuang@...wei.com>,
        "namhyung@...nel.org" <namhyung@...nel.org>,
        "alexander.shishkin@...ux.intel.com" 
        <alexander.shishkin@...ux.intel.com>,
        "Hunter, Adrian" <adrian.hunter@...el.com>,
        "ak@...ux.intel.com" <ak@...ux.intel.com>
Subject: RE: [PATCH V3 4/6] perf tools: add perf_data_file__open_tmp

> > From: Kan Liang <Kan.liang@...el.com>
> >
> > And an interface for perf_data_file to open tmp file.
> > Automatically generate the tmp file name if it's not assigned. The
> > name cannot be const char. Introduce char *tmp_path for it.
> > The tmp file will be deleted after close.
> >
> > It will be used as per-thread file to temporarily store event
> > synthesizd result in the following patch.
> >
> > Signed-off-by: Kan Liang <Kan.liang@...el.com>
> > ---
> >  tools/perf/util/data.c | 26 ++++++++++++++++++++++++++
> > tools/perf/util/data.h |  2 ++
> >  2 files changed, 28 insertions(+)
> >
> > diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index
> > 1123b30..cd6fdf9 100644
> > --- a/tools/perf/util/data.c
> > +++ b/tools/perf/util/data.c
> > @@ -139,9 +139,35 @@ int perf_data_file__open(struct perf_data_file
> *file)
> >  	return open_file(file);
> >  }
> >
> > +int perf_data_file__open_tmp(struct perf_data_file *file) {
> > +	int fd;
> > +
> > +	if (!file->tmp_path &&
> > +	    (asprintf(&file->tmp_path, "perf.tmp.XXXXXX") < 0))
> > +		goto err;
> > +
> > +	fd = mkstemp(file->tmp_path);
> > +	if (fd < 0) {
> > +		free(file->tmp_path);
> > +		goto err;
> > +	}
> > +
> > +	file->fd = fd;
> > +	return 0;
> > +err:
> > +	file->tmp_path = NULL;
> > +	return -1;
> > +}
> > +
> >  void perf_data_file__close(struct perf_data_file *file)  {
> >  	close(file->fd);
> > +	if (file->tmp_path) {
> > +		unlink(file->tmp_path);
> > +		free(file->tmp_path);
> > +		file->tmp_path = NULL;
> > +	}
> >  }
> >
> >  ssize_t perf_data_file__write(struct perf_data_file *file, diff --git
> > a/tools/perf/util/data.h b/tools/perf/util/data.h index
> > ae510ce..892b3d5 100644
> > --- a/tools/perf/util/data.h
> > +++ b/tools/perf/util/data.h
> > @@ -10,6 +10,7 @@ enum perf_data_mode {
> >
> >  struct perf_data_file {
> >  	const char		*path;
> > +	char			*tmp_path;
> 
> could we add is_tmp instead of new path pointer and keep the path for the
> name..?

The 'path' is const char. I think it's not good for tmp file which
generate the file name in real time.

Thanks,
Kan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ