From 5924496e28de930f2f6fcd0c5a766719460c68c7 Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Wed, 16 Nov 2022 07:30:24 +0100 Subject: [PATCH] src/dirn.c: new function can_copy_dir() --- src/dirn.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/dirn.c b/src/dirn.c index 1964ec58..fc6dbecc 100644 --- a/src/dirn.c +++ b/src/dirn.c @@ -667,6 +667,21 @@ Returns 0: all files has been copied */ #define MAX_DIR_NBR 256 + +static int can_copy_dir(const file_info_t *current_file, const unsigned long int inode_known[MAX_DIR_NBR], const unsigned int dir_nbr) +{ + const unsigned long int new_inode=current_file->st_ino; + unsigned int i; + if(new_inode<2) + return 0; + if(strcmp(current_file->name,"..")==0 || strcmp(current_file->name,".")==0) + return 0; + for(i=0; icurrent_directory,current_file->name); if(LINUX_S_ISDIR(current_file->st_mode)!=0) { - const unsigned long int new_inode=current_file->st_ino; - unsigned int new_inode_ok=1; - unsigned int i; - if(new_inode<2) - new_inode_ok=0; - if(strcmp(current_file->name,"..")==0 || strcmp(current_file->name,".")==0) - new_inode_ok=0; - for(i=0;i0) + if(can_copy_dir(current_file, &inode_known[0], dir_nbr) > 0) { copy_stopped=copy_dir(window, disk, partition, dir_data, current_file, copy_ok, copy_bad); }