1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvm-file: remove duplication of dm_is_empty_dir

This commit is contained in:
Zdenek Kabelac 2021-03-09 11:10:47 +01:00
parent 413a114cdb
commit 88d04e9173
4 changed files with 2 additions and 27 deletions

View File

@ -110,7 +110,7 @@ int dm_is_empty_dir(const char *dir)
DIR *d;
if (!(d = opendir(dir))) {
log_sys_error("opendir", dir);
log_sys_debug("opendir", dir);
return 0;
}

View File

@ -76,7 +76,7 @@ static int _rm_dir(const char *dev_dir, const char *vg_name)
return 0;
}
if (dir_exists(vg_path) && is_empty_dir(vg_path)) {
if (dir_exists(vg_path) && dm_is_empty_dir(vg_path)) {
log_very_verbose("Removing directory %s", vg_path);
rmdir(vg_path);
}

View File

@ -141,26 +141,6 @@ int dir_exists(const char *path)
return 1;
}
int is_empty_dir(const char *dir)
{
struct dirent *dirent;
DIR *d;
if (!(d = opendir(dir))) {
log_sys_error("opendir", dir);
return 0;
}
while ((dirent = readdir(d)))
if (strcmp(dirent->d_name, ".") && strcmp(dirent->d_name, ".."))
break;
if (closedir(d))
log_sys_error("closedir", dir);
return dirent ? 0 : 1;
}
void sync_dir(const char *file)
{
int fd;

View File

@ -41,11 +41,6 @@ int lvm_rename(const char *old, const char *new);
int path_exists(const char *path);
int dir_exists(const char *path);
/*
* Return 1 if dir is empty
*/
int is_empty_dir(const char *dir);
/* Sync directory changes */
void sync_dir(const char *file);