mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 10:16:41 +00:00
tiny fix on function dump_empty_fs
return value of is_empty_dir: * < 0 : open directory stream failed * 0 : directory is not empty * 1 : directory is empty Signed-off-by: Liu Hua <weldonliu@tencent.com>
This commit is contained in:
parent
cdb0d42702
commit
264b4a8d24
2 changed files with 9 additions and 2 deletions
|
|
@ -656,12 +656,12 @@ static int dump_empty_fs(struct mount_info *pm)
|
|||
return fd;
|
||||
|
||||
ret = is_empty_dir(fd);
|
||||
if (ret < 0) {
|
||||
if (ret == 0) {
|
||||
pr_err("%s isn't empty\n", pm->fstype->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret ? 0 : -1;
|
||||
return ret == 1 ? 0 : -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -731,7 +731,13 @@ int is_root_user(void)
|
|||
/*
|
||||
* is_empty_dir will always close the FD dirfd: either implicitly
|
||||
* via closedir or explicitly in case fdopendir had failed
|
||||
*
|
||||
* return values:
|
||||
* < 0 : open directory stream failed
|
||||
* 0 : directory is not empty
|
||||
* 1 : directory is empty
|
||||
*/
|
||||
|
||||
int is_empty_dir(int dirfd)
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
@ -740,6 +746,7 @@ int is_empty_dir(int dirfd)
|
|||
|
||||
fdir = fdopendir(dirfd);
|
||||
if (!fdir) {
|
||||
pr_perror("open directory stream by fd %d failed", dirfd);
|
||||
close_safe(&dirfd);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue