summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4628484)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
/*
* Try to remove a hierarchy of empty directories, recursively. Don't unlink
/*
* Try to remove a hierarchy of empty directories, recursively. Don't unlink
+ * any file. Try to rmdir any empty directory within the hierarchy.
*/
LTTNG_HIDDEN
int utils_recursive_rmdir(const char *path)
{
DIR *dir;
*/
LTTNG_HIDDEN
int utils_recursive_rmdir(const char *path)
{
DIR *dir;
- int dir_fd, ret = 0, closeret;
+ int dir_fd, ret = 0, closeret, is_empty = 1;
struct dirent *entry;
/* Open directory */
struct dirent *entry;
/* Open directory */
PATH_MAX - strlen(subpath) - 1);
strncat(subpath, entry->d_name,
PATH_MAX - strlen(subpath) - 1);
PATH_MAX - strlen(subpath) - 1);
strncat(subpath, entry->d_name,
PATH_MAX - strlen(subpath) - 1);
- ret = utils_recursive_rmdir(subpath);
- if (ret) {
- goto end;
+ if (utils_recursive_rmdir(subpath)) {
+ is_empty = 0;
- ret = -EBUSY;
- goto end;
default:
ret = -EINVAL;
goto end;
default:
ret = -EINVAL;
goto end;
if (closeret) {
PERROR("closedir");
}
if (closeret) {
PERROR("closedir");
}
DBG3("Attempting rmdir %s", path);
ret = rmdir(path);
}
DBG3("Attempting rmdir %s", path);
ret = rmdir(path);
}