Commit 65e7c963 authored by Alexey Bayduraev's avatar Alexey Bayduraev Committed by Arnaldo Carvalho de Melo
Browse files

perf data: Adding error message if perf_data__create_dir() fails



Add proper return codes for all cases of data directory creation failure
and add error message output based on these codes.

Signed-off-by: default avatarAlexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220222091417.11020-1-alexey.v.bayduraev@linux.intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 859f7e45
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1186,8 +1186,10 @@ static int record__mmap_evlist(struct record *rec,

	if (record__threads_enabled(rec)) {
		ret = perf_data__create_dir(&rec->data, evlist->core.nr_mmaps);
		if (ret)
		if (ret) {
			pr_err("Failed to create data directory: %s\n", strerror(-ret));
			return ret;
		}
		for (i = 0; i < evlist->core.nr_mmaps; i++) {
			if (evlist->mmap)
				evlist->mmap[i].file = &rec->data.dir.files[i];
+6 −2
Original line number Diff line number Diff line
@@ -52,12 +52,16 @@ int perf_data__create_dir(struct perf_data *data, int nr)
		struct perf_data_file *file = &files[i];

		ret = asprintf(&file->path, "%s/data.%d", data->path, i);
		if (ret < 0)
		if (ret < 0) {
			ret = -ENOMEM;
			goto out_err;
		}

		ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
		if (ret < 0)
		if (ret < 0) {
			ret = -errno;
			goto out_err;
		}

		file->fd = ret;
	}