Skip to content
Snippets Groups Projects

Resolve "Segmentation fault in sfind"

Closed Ramon Nou requested to merge 138-segmentation-fault-in-sfind into master
1 unresolved thread
Compare and Show latest version
1 file
+ 8
5
Compare changes
  • Side-by-side
  • Inline
+ 8
5
@@ -113,7 +113,7 @@ pfind_options_t *pfind_parse_args(int argc, char **argv, int force_print_help){
pfind_size = 1;
pfind_options_t *res = (pfind_options_t *)malloc(sizeof(pfind_options_t));
memset(res, 0, sizeof(pfind_options_t));
*res = {};
auto print_help = force_print_help;
res->workdir = "./";
@@ -280,8 +280,7 @@ void dirProcess(const string path, unsigned long long &checked,
struct dirent_extended *getdir = (struct dirent_extended *)malloc(
(sizeof(struct dirent_extended) + 255) * 1024 * 100);
memset(getdir, 0, (sizeof(struct dirent_extended) + 255) * 1024 * 100);
// cout << "PROCESSING " << world_rank << "/"<< world_size << " = " << path <<
// endl;
for (auto server = 0; server < opt->num_servers; server++) {
unsigned long long total_size = 0;
@@ -289,7 +288,7 @@ void dirProcess(const string path, unsigned long long &checked,
path.c_str(), getdir,
(sizeof(struct dirent_extended) + 255) * 1024 * 100, server);
struct dirent_extended *temp = getdir;
if (opt->verbosity) cout << "[" << n << "] " << path.c_str() << endl;
while (total_size < n) {
if (strlen(temp->d_name) == 0)
break;
@@ -311,11 +310,14 @@ void dirProcess(const string path, unsigned long long &checked,
if ((uint64_t)temp->ctime < runtime.ctime_min)
timeOK = false;
}
if (timeOK and (temp->size == opt->size or opt->size == std::numeric_limits<uint64_t>::max()))
if (!(opt->name_pattern &&
regexec(&opt->name_regex, temp->d_name, 0, nullptr, 0)))
found++;
checked++;
if (opt->verbosity) cout << temp->d_name << endl;
temp = reinterpret_cast<dirent_extended *>(reinterpret_cast<char *>(temp) + temp->d_reclen);
}
}
@@ -346,12 +348,13 @@ int process(pfind_options_t *opt) {
workdir = workdir.substr(strlen(opt->mountdir), workdir.size());
if (workdir.size() == 0)
workdir = "/";
dirs.push(workdir);
do {
string processpath = dirs.front();
dirs.pop();
if (opt->verbosity) cout << processpath << endl;
dirProcess(processpath, checked, found, dirs, 0, 1, opt);
// cout << "NO more paths " << dirs.size() << endl;
} while (!dirs.empty());
Loading