From: Leesoo Ahn Date: Sat, 26 Mar 2022 12:09:05 +0000 (+0900) Subject: utils: add fastpath routine on mkdir_p function X-Git-Tag: lxc-5.0.0~25^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4098%2Fhead;p=thirdparty%2Flxc.git 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 --- 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;