On Thu, 12 Nov 2020 11:11:07 +0200 "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote: > +struct tracefs_instance *tracefs_instance_create(const char *name) > { > + struct tracefs_instance *inst = NULL; > struct stat st; > char *path; > int ret; > > - path = tracefs_instance_get_dir(instance); > + inst = instance_alloc(name); > + if (!inst) > + return NULL; > + > + path = tracefs_instance_get_dir(inst); > ret = stat(path, &st); > - if (ret < 0) > - ret = mkdir(path, 0777); > - else > - ret = 1; > + if (ret < 0) { > + /* Cannot create the top instance, if it does not exist! */ > + if (!name) > + goto error; > + if (mkdir(path, 0777)) Not something you have to address now (but perhaps add a new patch?). This should not be 0777, but instead be a macro, and define it as 0770, or possibly even look at the permissions of the top level and use whatever that is set as? Again, this doesn't affect this series, but something we should change in the near future. -- Steve > + goto error; > + inst->flags |= FLAG_INSTANCE_NEWLY_CREATED; > + } > tracefs_put_tracing_file(path); > - return ret; > + return inst; > + > +error: > + tracefs_instance_free(inst); > + return NULL; > } >