Messages in this thread | | | From | Namhyung Kim <> | Subject | Re: [PATCH 09/19] perf ftrace: Add 'record' sub-command | Date | Thu, 11 Jul 2013 17:00:36 +0900 |
| |
On Wed, 10 Jul 2013 16:28:21 +0200, Jiri Olsa wrote: > On Wed, Jun 26, 2013 at 04:14:12PM +0900, Namhyung Kim wrote: >> From: Namhyung Kim <namhyung.kim@lge.com> > > SNIP > >> + >> +static int create_perf_directory(struct perf_ftrace *ftrace) >> +{ >> + int err; >> + char buf[PATH_MAX]; >> + struct stat statbuf; >> + >> + scnprintf(buf, sizeof(buf), "%s.dir", ftrace->dirname); >> + >> + if (stat(buf, &statbuf) == 0) { >> + /* same name already exists - rename to *.old.dir */ >> + char *old_name = malloc(strlen(buf) + 5); >> + if (old_name == NULL) >> + return -1; >> + >> + scnprintf(old_name, strlen(buf) + 5, >> + "%s.old.dir", ftrace->dirname); >> + >> + if (remove_directory(old_name) < 0) { >> + perror("rmdir"); >> + return -1; >> + } >> + >> + if (rename(buf, old_name) < 0) { >> + perror("rename"); >> + free(old_name); >> + return -1; >> + } >> + >> + free(old_name); >> + } >> + >> + err = mkdir(buf, 0755); >> + if (err < 0) { >> + perror("mkdir"); >> + return -1; >> + } >> + >> + strcat(buf, "/perf.header"); >> + >> + err = open(buf, O_RDWR | O_CREAT | O_TRUNC, 0644); >> + return err; >> +} > > nitpick.. should this be rather be called create_perf_header, > which calls create_perf_directory inside?
Looks reasonable. I'll change the name.
Thanks, Namhyung
| |