From: Alain Spineux Date: Wed, 29 Nov 2017 23:20:24 +0000 (+0100) Subject: file_dev.c: replace readdir_r() wit new breaddir() X-Git-Tag: Release-9.2.0~149 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32f7fd4585efb6c095a00bc0a0eb69978e1320fb;p=thirdparty%2Fbacula.git file_dev.c: replace readdir_r() wit new breaddir() --- diff --git a/bacula/src/stored/file_dev.c b/bacula/src/stored/file_dev.c index 365e148f80..c3d536ec22 100644 --- a/bacula/src/stored/file_dev.c +++ b/bacula/src/stored/file_dev.c @@ -307,7 +307,7 @@ bool DEVICE::mount_file(int mount, int dotimeout) POOLMEM *results; DIR* dp; char *icmd; - struct dirent *entry, *result; + POOL_MEM dname(PM_FNAME); int status, tries, name_max, count; berrno be; @@ -372,23 +372,21 @@ bool DEVICE::mount_file(int mount, int dotimeout) goto get_out; } - entry = (struct dirent *)malloc(sizeof(struct dirent) + name_max + 1000); count = 0; while (1) { - if ((readdir_r(dp, entry, &result) != 0) || (result == NULL)) { + if (breaddir(dp, dname.addr()) != 0) { dev_errno = EIO; Dmsg2(129, "mount_file: failed to find suitable file in dir %s (dev=%s)\n", device->mount_point, print_name()); break; } - if ((strcmp(result->d_name, ".")) && (strcmp(result->d_name, "..")) && (strcmp(result->d_name, ".keep"))) { - count++; /* result->d_name != ., .. or .keep (Gentoo-specific) */ + if ((strcmp(dname.c_str(), ".")) && (strcmp(dname.c_str(), "..")) && (strcmp(dname.c_str(), ".keep"))) { + count++; /* dname.c_str() != ., .. or .keep (Gentoo-specific) */ break; } else { - Dmsg2(129, "mount_file: ignoring %s in %s\n", result->d_name, device->mount_point); + Dmsg2(129, "mount_file: ignoring %s in %s\n", dname.c_str(), device->mount_point); } } - free(entry); closedir(dp); Dmsg1(100, "mount_file: got %d files in the mount point (not counting ., .. and .keep)\n", count);