mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 22:35:33 +00:00
fd: Consolidate . and .. checks in various readdir callers
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
@@ -168,9 +168,7 @@ static int collect_fds(pid_t pid, struct parasite_drain_fd *dfds)
|
|||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
while ((de = readdir(fd_dir))) {
|
while ((de = readdir(fd_dir))) {
|
||||||
if (!strcmp(de->d_name, "."))
|
if (dir_dots(de))
|
||||||
continue;
|
|
||||||
if (!strcmp(de->d_name, ".."))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (n > PARASITE_MAX_FDS - 1)
|
if (n > PARASITE_MAX_FDS - 1)
|
||||||
@@ -1029,9 +1027,7 @@ static int parse_children(pid_t pid, pid_t **_c, int *_n)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while ((de = readdir(dir))) {
|
while ((de = readdir(dir))) {
|
||||||
if (!strcmp(de->d_name, "."))
|
if (dir_dots(de))
|
||||||
continue;
|
|
||||||
if (!strcmp(de->d_name, ".."))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
file = fopen_proc(pid, "task/%s/children", de->d_name);
|
file = fopen_proc(pid, "task/%s/children", de->d_name);
|
||||||
|
4
files.c
4
files.c
@@ -507,9 +507,7 @@ static int close_old_fds(struct pstree_item *me)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while ((de = readdir(dir))) {
|
while ((de = readdir(dir))) {
|
||||||
if (!strcmp(de->d_name, "."))
|
if (dir_dots(de))
|
||||||
continue;
|
|
||||||
if (!strcmp(de->d_name, ".."))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = sscanf(de->d_name, "%d", &fd);
|
ret = sscanf(de->d_name, "%d", &fd);
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/statfs.h>
|
#include <sys/statfs.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@@ -325,4 +325,9 @@ extern int run_scripts(char *action);
|
|||||||
|
|
||||||
extern int cr_system(int in, int out, int err, char *cmd, char *const argv[]);
|
extern int cr_system(int in, int out, int err, char *cmd, char *const argv[]);
|
||||||
|
|
||||||
|
static inline bool dir_dots(struct dirent *de)
|
||||||
|
{
|
||||||
|
return !strcmp(de->d_name, ".") || !strcmp(de->d_name, "..");
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* UTIL_H_ */
|
#endif /* UTIL_H_ */
|
||||||
|
4
mount.c
4
mount.c
@@ -308,9 +308,7 @@ static int binfmt_misc_dump(struct mount_info *pm)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while ((de = readdir(fdir))) {
|
while ((de = readdir(fdir))) {
|
||||||
if (!strcmp(de->d_name, "."))
|
if (dir_dots(de))
|
||||||
continue;
|
|
||||||
if (!strcmp(de->d_name, ".."))
|
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp(de->d_name, "register"))
|
if (!strcmp(de->d_name, "register"))
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user