From: Serge Hallyn Date: Thu, 14 Dec 2017 19:16:02 +0000 (-0600) Subject: dir_detect: warn on eperm X-Git-Tag: lxc-3.0.0.beta1~109^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d8869c36987fe79bad34dbb934b58b63754952d;p=thirdparty%2Flxc.git dir_detect: warn on eperm if user has lxc.rootfs.path = /some/path/foo, but can't access some piece of that path, then we'll get an unhelpful "failed to mount" without any indication of the problem. At least show that there is a permission problem. Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/storage/dir.c b/src/lxc/storage/dir.c index fd2e07526..bfd3827de 100644 --- a/src/lxc/storage/dir.c +++ b/src/lxc/storage/dir.c @@ -136,10 +136,19 @@ int dir_destroy(struct lxc_storage *orig) bool dir_detect(const char *path) { + struct stat statbuf; + int ret; + if (!strncmp(path, "dir:", 4)) return true; - if (is_dir(path)) + ret = stat(path, &statbuf); + if (ret == -1 && errno == EPERM) { + SYSERROR("dir_detect: failed to look at \"%s\"", path); + return false; + } + + if (ret == 0 && S_ISDIR(statbuf.st_mode)) return true; return false;