nftw: rename dirstreamlist to dirlist
This was a fatfinger mistake - please ignore. Sorry for the spam.
Quoted 182 lines · Gyorgy Sarvari via lists.openembedded.org
--- ports/unix/guts/nftw.c | 59 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 30 deletions(-)ports/unix/guts/nftw.c +29
-31@@ -152,9 +152,9 @@struct stat st;// stat to send to "fn" dev_t orig_dev;// the device of the top "path" -struct dirstream_path * dirstreamlist =NULL ;// list of currently processed folders, +struct dirstream_path * dirlist =NULL ;// list of currently processed folders, // used along with FTW_DEPTH flag -size_t dirstreamlist_size =0 ; +size_t dirlist_size =0 ;ino_t *inode_list =NULL ;size_t inode_list_size =0 , inode_list_capacity =0 ;@@ -210,9 +210,9 @@/* NO FTW_DEPTH walking code section starts here */ /* ******************************************************************/ - dirstreamlist =malloc (sizeof (struct dirstream_path )); + dirlist =malloc (sizeof (struct dirstream_path ));// kickstart the first element with the top folder path -NFTW_APPEND_DIRSTREAMPATH_TO_ARRAY (path, dirstreamlist, dirstreamlist_size,NFTW_DONT_OPEN_DIRSTREAM ); +NFTW_APPEND_DIRSTREAMPATH_TO_ARRAY (path, dirlist, dirlist_size,NFTW_DONT_OPEN_DIRSTREAM );/* * Walk the tree, without FTW_DEPTH flag. @@ -222,13 +222,13 @@* 4. Collect all folders from the folder, and add them to the end of the list * 5. Repeat until the list if empty */ -while (dirstreamlist_size >0 ) { +while (dirlist_size >0 ) { ftw.level = -base_level; ftw.base =0 ;// 1. take the last folder from the list -strcpy (folder_pathbuf, dirstreamlist[dirstreamlist_size -1 ].path); -NFTW_REMOVE_LAST_DIRSTREAM_FROM_LIST (dirstreamlist, dirstreamlist_size); +strcpy (folder_pathbuf, dirlist[dirlist_size -1 ].path); +NFTW_REMOVE_LAST_DIRSTREAM_FROM_LIST (dirlist, dirlist_size);NFTW_CALCULATE_FTW_BASE_AND_LEVEL (folder_pathbuf, ftw);if (flag &FTW_ACTIONRETVAL ){@@ -313,7 +313,7 @@// 4. Collect all folders from the folder, and add them to the list // (in the same loop with step 3) if (d->d_type ==DT_DIR ) { -NFTW_APPEND_DIRSTREAMPATH_TO_ARRAY (file_pathbuf, dirstreamlist, dirstreamlist_size,NFTW_DONT_OPEN_DIRSTREAM ); +NFTW_APPEND_DIRSTREAMPATH_TO_ARRAY (file_pathbuf, dirlist, dirlist_size,NFTW_DONT_OPEN_DIRSTREAM );continue ; }@@ -392,8 +392,8 @@ nftw_ftw_depth: ;stat (path, &st);if (S_ISDIR (st.st_mode)){ - dirstreamlist =malloc (sizeof (struct dirstream_path )); -NFTW_APPEND_DIRSTREAMPATH_TO_ARRAY (path, dirstreamlist, dirstreamlist_size,NFTW_OPEN_DIRSTREAM ); + dirlist =malloc (sizeof (struct dirstream_path )); +NFTW_APPEND_DIRSTREAMPATH_TO_ARRAY (path, dirlist, dirlist_size,NFTW_OPEN_DIRSTREAM ); }else {// otherwise it's a single file, just send it off, and we are done ftw.level = -base_level;@@ -423,23 +423,23 @@ nftw_ftw_depth: ;* send it to fn, and remove it from dirstreamlist. * 4. Repeat until the list is empty. */ -while (dirstreamlist_size >0 ){ +while (dirlist_size >0 ){// 1. Get the last dirstream from dirstreamlist // and // 2. Read the next entry from it -if ((d =readdir (dirstreamlist[dirstreamlist_size -1 ].dirstream)) !=NULL ){ +if ((d =readdir (dirlist[dirlist_size -1 ].dirstream)) !=NULL ){if ((strcmp (d->d_name,"." ) ==0 ) ||strcmp (d->d_name,".." ) ==0 ){continue ; }NFTW_CONCAT_PATH_WITH_SEPARATOR (file_pathbuf, - dirstreamlist[dirstreamlist_size -1 ].path, + dirlist[dirlist_size -1 ].path,"/" , d->d_name);// 3b. If the entry is a folder, open a directort stream with it, and append // it to dirstreamlist if (d->d_type ==DT_DIR ){ -NFTW_APPEND_DIRSTREAMPATH_TO_ARRAY (file_pathbuf, dirstreamlist, dirstreamlist_size,NFTW_OPEN_DIRSTREAM ); +NFTW_APPEND_DIRSTREAMPATH_TO_ARRAY (file_pathbuf, dirlist, dirlist_size,NFTW_OPEN_DIRSTREAM );continue ; }@@ -491,25 +491,25 @@ nftw_ftw_depth: ; ftw.level = -base_level; ftw.base =0 ; -NFTW_CALCULATE_FTW_BASE_AND_LEVEL (dirstreamlist[dirstreamlist_size -1 ].path, ftw); +NFTW_CALCULATE_FTW_BASE_AND_LEVEL (dirlist[dirlist_size -1 ].path, ftw);if (flag &FTW_ACTIONRETVAL ){ -if (NFTW_SHOULD_SKIP_PATH (dirstreamlist[dirstreamlist_size -1 ].path, skiplist, skiplist_size)) { -NFTW_REMOVE_LAST_DIRSTREAM_FROM_LIST (dirstreamlist, dirstreamlist_size); +if (NFTW_SHOULD_SKIP_PATH (dirlist[dirlist_size -1 ].path, skiplist, skiplist_size)) { +NFTW_REMOVE_LAST_DIRSTREAM_FROM_LIST (dirlist, dirlist_size);continue ; } }if (flag &FTW_CHDIR ){ -chdir (dirstreamlist[dirstreamlist_size -1 ].path); +chdir (dirlist[dirlist_size -1 ].path);chdir (".." ); }// stat it, and send it to fn if (((flag &FTW_PHYS ) - ?lstat (dirstreamlist[dirstreamlist_size -1 ].path, &st) - :stat (dirstreamlist[dirstreamlist_size -1 ].path, &st)) <0 ) { -NFTW_HANDLE_BROKEN_SYMLINK (dirstreamlist[dirstreamlist_size -1 ].path); + ?lstat (dirlist[dirlist_size -1 ].path, &st) + :stat (dirlist[dirlist_size -1 ].path, &st)) <0 ) { +NFTW_HANDLE_BROKEN_SYMLINK (dirlist[dirlist_size -1 ].path); }else {if ((flag &FTW_MOUNT ) && orig_dev != st.st_dev)continue ;@@ -531,21 +531,21 @@ nftw_ftw_depth: ; }else { ent_flag =S_ISDIR (st.st_mode) ?FTW_DP :FTW_F ; } - rc =fn (dirstreamlist[dirstreamlist_size -1 ].path, &st, ent_flag, &ftw); + rc =fn (dirlist[dirlist_size -1 ].path, &st, ent_flag, &ftw); } -NFTW_REMOVE_LAST_DIRSTREAM_FROM_LIST (dirstreamlist, dirstreamlist_size); +NFTW_REMOVE_LAST_DIRSTREAM_FROM_LIST (dirlist, dirlist_size); }if (flag &FTW_ACTIONRETVAL ){if (rc ==FTW_SKIP_SIBLINGS ){ -NFTW_APPEND_STRING_TO_ARRAY (dirstreamlist[dirstreamlist_size -1 ].path, -strlen (dirstreamlist[dirstreamlist_size -1 ].path) +1 , +NFTW_APPEND_STRING_TO_ARRAY (dirlist[dirlist_size -1 ].path, +strlen (dirlist[dirlist_size -1 ].path) +1 , skiplist, skiplist_size); - skiplist[skiplist_size -1 ][strlen (dirstreamlist[dirstreamlist_size -1 ].path)] ='/' ; + skiplist[skiplist_size -1 ][strlen (dirlist[dirlist_size -1 ].path)] ='/' ; rc =0 ; }else if (rc ==FTW_STOP ) { goto nftw_out;@@ -579,12 +579,11 @@ nftw_out: ;free (skiplist); -for (size_t i =0 ; i < dirstreamlist_size; ++i){ -closedir (dirstreamlist[i].dirstream); -free (dirstreamlist[i].path); +for (size_t i =0 ; i < dirlist_size; ++i){ +NFTW_REMOVE_LAST_DIRSTREAM_FROM_LIST (dirlist, dirlist_size); } -free (dirstreamlist); +free (dirlist);free (inode_list); errno = save_errno; -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#115995): https://lists.openembedded.org/g/openembedded-devel/message/115995
Mute This Topic: https://lists.openembedded.org/mt/111718780/6084445
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-