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: 's avatarCarlos Alberto Lopez Perez <clopez@igalia.com>
parent 5c698360
...@@ -4188,9 +4188,9 @@ int list_defined_containers(const char *lxcpath, char ***names, struct lxc_conta ...@@ -4188,9 +4188,9 @@ int list_defined_containers(const char *lxcpath, char ***names, struct lxc_conta
while (!readdir_r(dir, &dirent, &direntp)) { while (!readdir_r(dir, &dirent, &direntp)) {
if (!direntp) if (!direntp)
break; break;
if (!strcmp(direntp->d_name, "."))
continue; // Ignore '.', '..' and any hidden directory
if (!strcmp(direntp->d_name, "..")) if (!strncmp(direntp->d_name, ".", 1))
continue; continue;
if (!config_file_exists(lxcpath, direntp->d_name)) if (!config_file_exists(lxcpath, direntp->d_name))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment