From: Carlos Alberto Lopez Perez Date: Fri, 29 Jan 2016 14:39:22 +0000 (+0100) Subject: Ignore any container with a name starting by '.' X-Git-Tag: lxc-1.0.9~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f907acd4d7a7b1b1d0cd854f848fd0f6cadbf69;p=thirdparty%2Flxc.git Ignore any container with a name starting by '.' * This are either '.', '..' or a hidden directory. And this names should not be used for a container in any case. * Before this patch, if you created a git repository under lxc.lxcpath (it can be useful to keep track of the configurations of your containers) Then, when you run lxc-ls you will get the following output: # lxc-ls .git container1 container2 .... This is because there is a 'config' file inside the '.git' directory. It is where git stores the configuration of the repository. And the test lxc-ls does to check if a directory contains a container is just to check if the 'directory/config' file exists. Signed-off-by: Carlos Alberto Lopez Perez --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index f9174b4cb..ecb2aeb2f 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -3459,9 +3459,9 @@ int list_defined_containers(const char *lxcpath, char ***names, struct lxc_conta while (!readdir_r(dir, &dirent, &direntp)) { if (!direntp) break; - if (!strcmp(direntp->d_name, ".")) - continue; - if (!strcmp(direntp->d_name, "..")) + + // Ignore '.', '..' and any hidden directory + if (!strncmp(direntp->d_name, ".", 1)) continue; if (!config_file_exists(lxcpath, direntp->d_name))