lkml.org 
[lkml]   [2019]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 10/20] perf data: Add directory support
    On Mon, Feb 25, 2019 at 12:07:22PM -0300, Arnaldo Carvalho de Melo wrote:

    SNIP

    > > > > +}
    > > > > +
    > > > > static int open_file_read(struct perf_data *data)
    > > > > {
    > > > > struct stat st;
    > > > > @@ -254,6 +270,22 @@ static int open_file_dup(struct perf_data *data)
    > > > > return open_file(data);
    > > > > }
    > > > >
    > > > > +static int open_dir(struct perf_data *data)
    > > > > +{
    > > > > + if (perf_data__is_write(data) &&
    > > > > + mkdir(data->path, S_IRWXU) < 0)
    > > > > + return -1;
    > > > > +
    > > > > + /*
    > > > > + * So far we open only the header, so we
    > > > > + * can read the data version and layout.
    > > > > + */
    > > > > + if (asprintf(&data->file.path, "%s/header", data->path) < 0)
    > > > > + return -ENOMEM;
    > > >
    > > > so, if this fails, then we should unwind the mkdir, if it was
    > > > performed, so that we leave things as they were before calling
    > > > open_dir(), right?
    > >
    > > I think we need to some global solution on this,
    >
    > If we don't add more, that would be a good thing :-)
    >
    > The other parts also need to be investigated to see what is best in that
    > case, but here, undoing the mkdir() if the asprintf() fails is the right
    > thing to do :-)

    true ;-) will resend

    thanks,
    jirka

    \
     
     \ /
      Last update: 2019-02-25 16:37    [W:5.210 / U:0.060 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site