[CRIU] [PATCH 1/2] Re-create cgroups if necessary
Andrew Vagin
avagin at parallels.com
Mon Jun 23 21:03:25 PDT 2014
On Tue, Jun 24, 2014 at 02:29:27AM +0000, Tycho Andersen wrote:
> On Mon, Jun 23, 2014 at 10:53:48PM +0400, Andrew Vagin wrote:
> >
> > Look at my version. It doesn't copy a path in another place.
>
> The copy is sort of unfortunate, strtok writes a null byte to the
> string it is tokenizing, which seems impolite to do as callers won't
> expect it, even though it might not break anything. I used it because
> I prefer using library functions to rolling my own, but I'm happy to
> switch it if the copy is a big issue.
>
> Tycho
>
The copy isn't a big issue. I don't like strtok:).
Below you can find a version, which don't modify path in place.
strcpy(made_path, path)
> > tok = made_path;
> > while (tok = strchr(tok + 1, "/")) {
> > char c;
> > if (tok != NULL) {
> > c = *tok;
> > *tok = 0;
> > }
> >
> > if (mkdirat(fd, made_path, 0755) < 0 && errno != EEXIST) {
> > pr_perror("couldn't mkdirpat directory\n");
if (tok != NULL)
*tok = c;
> > return -1;
> > }
> >
> > if (tok == NULL)
> > break;
> > else
> > *tok = c;
> > }
> >
> > Thanks.
More information about the CRIU
mailing list