mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
Remove scandir() requirement in pg_upgrade; instead just use readdir()
--- we were not using the scandir pattern filtering anyway. This also removes the scandir requirement in configure.
This commit is contained in:
parent
fc6d1006bd
commit
7012b5edb7
3
configure
vendored
3
configure
vendored
@ -18987,8 +18987,7 @@ fi
|
||||
|
||||
|
||||
|
||||
|
||||
for ac_func in cbrt dlopen fcvt fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink scandir setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs wcstombs_l
|
||||
for ac_func in cbrt dlopen fcvt fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs wcstombs_l
|
||||
do
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
|
@ -1193,7 +1193,7 @@ PGAC_VAR_INT_TIMEZONE
|
||||
AC_FUNC_ACCEPT_ARGTYPES
|
||||
PGAC_FUNC_GETTIMEOFDAY_1ARG
|
||||
|
||||
AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink scandir setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs wcstombs_l])
|
||||
AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs wcstombs_l])
|
||||
|
||||
AC_REPLACE_FUNCS(fseeko)
|
||||
case $host_os in
|
||||
|
@ -21,12 +21,6 @@ static int copy_file(const char *fromfile, const char *tofile, bool force);
|
||||
static int win32_pghardlink(const char *src, const char *dst);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SCANDIR
|
||||
static int pg_scandir_internal(const char *dirname,
|
||||
struct dirent *** namelist,
|
||||
int (*selector) (const struct dirent *));
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* copyAndUpdateFile()
|
||||
@ -228,45 +222,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
|
||||
|
||||
|
||||
/*
|
||||
* pg_scandir()
|
||||
*
|
||||
* Wrapper for portable scandir functionality
|
||||
*/
|
||||
int
|
||||
pg_scandir(const char *dirname,
|
||||
struct dirent *** namelist,
|
||||
int (*selector) (const struct dirent *))
|
||||
{
|
||||
#ifndef HAVE_SCANDIR
|
||||
return pg_scandir_internal(dirname, namelist, selector);
|
||||
|
||||
/*
|
||||
* scandir() is originally from BSD 4.3, which had the third argument as
|
||||
* non-const. Linux and other C libraries have updated it to use a const.
|
||||
* http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-12/msg002
|
||||
* 14.html
|
||||
*
|
||||
* Here we try to guess which libc's need const, and which don't. The net
|
||||
* goal here is to try to suppress a compiler warning due to a prototype
|
||||
* mismatch of const usage. Ideally we would do this via autoconf, but
|
||||
* autoconf doesn't have a suitable builtin test and it seems overkill to
|
||||
* add one just to avoid a warning.
|
||||
*/
|
||||
#elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__darwin__) || defined(__OpenBSD__)
|
||||
/* no const */
|
||||
return scandir(dirname, namelist, (int (*) (struct dirent *)) selector, NULL);
|
||||
#else
|
||||
/* use const */
|
||||
return scandir(dirname, namelist, selector, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef HAVE_SCANDIR
|
||||
/*
|
||||
* pg_scandir_internal()
|
||||
*
|
||||
* Implement our own scandir() on platforms that don't have it.
|
||||
* load_directory()
|
||||
*
|
||||
* Returns count of files that meet the selection criteria coded in
|
||||
* the function pointed to by selector. Creates an array of pointers
|
||||
@ -274,13 +230,10 @@ pg_scandir(const char *dirname,
|
||||
*
|
||||
* Note that the number of dirent structures needed is dynamically
|
||||
* allocated using realloc. Realloc can be inefficient if invoked a
|
||||
* large number of times. Its use in pg_upgrade is to find filesystem
|
||||
* filenames that have extended beyond the initial segment (file.1,
|
||||
* .2, etc.) and should therefore be invoked a small number of times.
|
||||
* large number of times.
|
||||
*/
|
||||
static int
|
||||
pg_scandir_internal(const char *dirname,
|
||||
struct dirent *** namelist, int (*selector) (const struct dirent *))
|
||||
int
|
||||
load_directory(const char *dirname, struct dirent ***namelist)
|
||||
{
|
||||
DIR *dirdesc;
|
||||
struct dirent *direntry;
|
||||
@ -294,9 +247,6 @@ pg_scandir_internal(const char *dirname,
|
||||
*namelist = NULL;
|
||||
|
||||
while ((direntry = readdir(dirdesc)) != NULL)
|
||||
{
|
||||
/* Invoke the selector function to see if the direntry matches */
|
||||
if (!selector || (*selector) (direntry))
|
||||
{
|
||||
count++;
|
||||
|
||||
@ -324,13 +274,11 @@ pg_scandir_internal(const char *dirname,
|
||||
|
||||
name_num++;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dirdesc);
|
||||
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
|
@ -333,8 +333,7 @@ const char *setupPageConverter(pageCnvCtx **result);
|
||||
typedef void *pageCnvCtx;
|
||||
#endif
|
||||
|
||||
int pg_scandir(const char *dirname, struct dirent *** namelist,
|
||||
int (*selector) (const struct dirent *));
|
||||
int load_directory(const char *dirname, struct dirent ***namelist);
|
||||
const char *copyAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
|
||||
const char *dst, bool force);
|
||||
const char *linkAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
|
||||
|
@ -160,7 +160,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
|
||||
}
|
||||
|
||||
snprintf(old_dir, sizeof(old_dir), "%s", maps[mapnum].old_dir);
|
||||
numFiles = pg_scandir(old_dir, &namelist, NULL);
|
||||
numFiles = load_directory(old_dir, &namelist);
|
||||
}
|
||||
|
||||
/* Copying files might take some time, so give feedback. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user