]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils: add fastpath routine on mkdir_p function 4098/head
authorLeesoo Ahn <lsahn@ooseel.net>
Sat, 26 Mar 2022 12:09:05 +0000 (21:09 +0900)
committerLeesoo Ahn <lsahn@ooseel.net>
Sat, 26 Mar 2022 13:22:10 +0000 (22:22 +0900)
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 <lsahn@ooseel.net>
src/lxc/utils.c

index b2cfb865d6b8be248761a110078559cad9917761..4acb10585643097121373f772d9579c3599ff4d0 100644 (file)
@@ -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;