mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 05:26:07 +00:00
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: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com> Acked-by: Jiri 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: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
859f7e4554
commit
65e7c96326
@ -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];
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user