From: root Date: Thu, 21 Jun 2012 18:21:40 +0000 (-0400) Subject: noisy logging turned on to help look for bug in directory tree. X-Git-Tag: 2.140.90~1309 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=7a381305a6cd14cf4254b6259a3ffb0e1912b390;p=feisty_meow.git noisy logging turned on to help look for bug in directory tree. --- diff --git a/nucleus/library/filesystem/directory.cpp b/nucleus/library/filesystem/directory.cpp index e4e3adcd..a122d577 100644 --- a/nucleus/library/filesystem/directory.cpp +++ b/nucleus/library/filesystem/directory.cpp @@ -161,15 +161,20 @@ bool directory::rescan() if (!strcmp(filename_transcoded.s(), par_dir.s())) continue; #ifdef UNICODE -//temp +/*temp to_unicode_persist(fudgemart, filename_transcoded); if (memcmp((wchar_t*)fudgemart, wfd.cFileName, wcslen(wfd.cFileName)*2)) printf("failed to compare the string before and after transcoding\n"); +*/ #endif //wprintf(to_unicode_temp("file is %ls\n"), (wchar_t*)to_unicode_temp(filename_transcoded)); filename temp_name(*_path, filename_transcoded.s()); + if (!temp_name.is_normal()) { + LOG(astring("skipping abnormal file: ") + temp_name); + continue; // cannot be adding goofy named pipes etc; cannot manage those. + } // add this to the appropriate list. if (temp_name.is_directory()) { diff --git a/nucleus/library/filesystem/directory_tree.cpp b/nucleus/library/filesystem/directory_tree.cpp index 77ea9472..2f267f9b 100644 --- a/nucleus/library/filesystem/directory_tree.cpp +++ b/nucleus/library/filesystem/directory_tree.cpp @@ -32,7 +32,7 @@ using namespace structures; using namespace nodes; using namespace textual; -//#define DEBUG_DIRECTORY_TREE +#define DEBUG_DIRECTORY_TREE // uncomment for noisier version. #undef LOG @@ -187,6 +187,10 @@ void directory_tree::traverse(const astring &path, const char *pattern, #ifdef DEBUG_DIRECTORY_TREE LOG(astring("seeking path: ") + new_path); #endif + if (!filename(new_path).is_normal()) { +LOG(astring("bailing on weird dir: ") + new_path); + continue; // only regular directories please. + } for (int q = 0; q < add_to.branches(); q++) { filename_tree *curr_kid = (filename_tree *)add_to.branch(q); #ifdef DEBUG_DIRECTORY_TREE @@ -610,7 +614,13 @@ bool directory_tree::compare_trees(const directory_tree &source, if (!target_now // there was no node, so we're adding everything... || !target_now->_files.member_with_state(*files[i], how_compare) ) { // ... or we need to add this file since it's missing. - +/* +//hmmm: this one might be redundant. we shouldn't add it in the first place. + if (!files[i]->is_normal()) { + LOG(astring("skipping abnormal file: ") + *files[i]); + continue; // wasn't useful to do this one. + } +*/ #ifdef DEBUG_DIRECTORY_TREE LOG(astring("adding record: ") + files[i]->text_form()); #endif @@ -778,12 +788,16 @@ outcome directory_tree::add_path(const astring &new_item, bool just_size) filename adding(new_item); if (!adding.good()) { LOG(astring("non-existent new item! ") + new_item); + return common::NOT_FOUND; // not an existing path. + } + if (!adding.is_normal()) { + LOG(astring("abnormal new item: ") + new_item); return common::BAD_INPUT; // not a good path. } int file_subtract = 0; // if it's a file, then we remove last component. if (!adding.is_directory()) file_subtract = 1; #ifdef DEBUG_DIRECTORY_TREE - if (file_subtract) LOG(astring("adding a file ") + new_item) + if (file_subtract) LOG(astring("adding a file ") + new_item); else LOG(astring("adding a directory ") + new_item); #endif diff --git a/nucleus/library/filesystem/filename.cpp b/nucleus/library/filesystem/filename.cpp index 1ab0c0d4..2a97d3a4 100644 --- a/nucleus/library/filesystem/filename.cpp +++ b/nucleus/library/filesystem/filename.cpp @@ -304,6 +304,18 @@ bool filename::is_executable() const return !!(fill.st_mode & S_IEXEC); } +bool filename::is_normal() const +{ + status_info fill; + if (!get_info(&fill)) + return false; + bool weird = S_ISCHR(fill.st_mode) + || S_ISBLK(fill.st_mode) + || S_ISFIFO(fill.st_mode) + || S_ISSOCK(fill.st_mode); + return !weird; +} + int filename::find_last_separator(const astring &look_at) const { int last_sep = -1; diff --git a/nucleus/library/filesystem/filename.h b/nucleus/library/filesystem/filename.h index 1f2c7d3b..8e257358 100644 --- a/nucleus/library/filesystem/filename.h +++ b/nucleus/library/filesystem/filename.h @@ -141,6 +141,10 @@ public: bool is_readable() const; bool is_executable() const; + // is_normal makes sure that the file or directory is not a named pipe or other + // special type of file. symbolic links are considered normal. + bool is_normal() const; + enum write_modes { ALLOW_NEITHER = 0x0, ALLOW_READ = 0x1, ALLOW_WRITE = 0x2, diff --git a/octopi/library/tentacles/file_transfer_tentacle.cpp b/octopi/library/tentacles/file_transfer_tentacle.cpp index fa082b99..c4abe989 100644 --- a/octopi/library/tentacles/file_transfer_tentacle.cpp +++ b/octopi/library/tentacles/file_transfer_tentacle.cpp @@ -46,7 +46,7 @@ const int FTT_CLEANING_INTERVAL = 30 * SECOND_ms; const int TRANSFER_TIMEOUT = 10 * MINUTE_ms; // if it hasn't been touched in this long, it's out of there. -//#define DEBUG_FILE_TRANSFER_TENTACLE +#define DEBUG_FILE_TRANSFER_TENTACLE // uncomment for noisier version. #undef LOG diff --git a/octopi/library/tentacles/recursive_file_copy.cpp b/octopi/library/tentacles/recursive_file_copy.cpp index 8464ed4e..657bc80c 100644 --- a/octopi/library/tentacles/recursive_file_copy.cpp +++ b/octopi/library/tentacles/recursive_file_copy.cpp @@ -141,7 +141,7 @@ outcome recursive_file_copy::copy_hierarchy(int transfer_mode, int iter = 0; while (true) { -//LOG(a_sprintf("ongoing chunk %d", ++iter)); +LOG(a_sprintf("ongoing chunk %d", ++iter)); // keep going until we find a broken reply. file_transfer_infoton *ongoing = new file_transfer_infoton;