Skip to content

Commit

Permalink
Merge pull request torvalds#300 from lkl/issue-294
Browse files Browse the repository at this point in the history
lkl tools: cpfromfs: fix root directory copy
  • Loading branch information
tavip authored Jan 19, 2017
2 parents d747073 + 98b31ca commit c874d36
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tools/lkl/cptofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,27 @@ static int searchdir(const char *src, const char *dst, const char *match)
return ret;
}

static int match_root(const char *src)
{
const char *c = src;

while (*c) {
switch (*c) {
case '.':
if (c > src && c[-1] == '.')
return 0;
break;
case '/':
break;
default:
return 0;
}
c++;
}

return 1;
}

int copy_one(const char *src, const char *mpoint, const char *dst)
{
char *src_path_dir, *src_path_base;
Expand All @@ -493,6 +514,9 @@ int copy_one(const char *src, const char *mpoint, const char *dst)
snprintf(dst_path, sizeof(dst_path), "%s", dst);
}

if (match_root(src))
return searchdir(src_path, dst, NULL);

src_path_dir = dirname(strdup(src_path));
src_path_base = basename(strdup(src_path));

Expand Down

0 comments on commit c874d36

Please sign in to comment.