From 0a0911faee6c41c99a6c78b2e7a540560ebd2441 Mon Sep 17 00:00:00 2001 From: Leesoo Ahn Date: Sat, 26 Mar 2022 21:09:05 +0900 Subject: [PATCH] utils: add fastpath routine on mkdir_p function Call 'access' to examine whether 'dir' is already existed or not instead of directly calling 'mkdir' on each dir name separated by slash '/' even though 'dir' is existed. Signed-off-by: Leesoo Ahn --- src/lxc/utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lxc/utils.c b/src/lxc/utils.c index b2cfb865d..4acb10585 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -218,6 +218,9 @@ int mkdir_p(const char *dir, mode_t mode) const char *tmp = dir; const char *orig = dir; + if (access(dir, F_OK) != -1) + return 0; + do { __do_free char *makeme = NULL; int ret;