Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7012b5e

Browse files
committed
Remove scandir() requirement in pg_upgrade; instead just use readdir()
--- we were not using the scandir pattern filtering anyway. This alsoremoves the scandir requirement in configure.
1 parentfc6d100 commit7012b5e

File tree

5 files changed

+26
-80
lines changed

5 files changed

+26
-80
lines changed

‎configure

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18987,8 +18987,7 @@ fi
1898718987

1898818988

1898918989

18990-
18991-
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
18990+
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
1899218991
do
1899318992
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1899418993
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5

‎configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ PGAC_VAR_INT_TIMEZONE
11931193
AC_FUNC_ACCEPT_ARGTYPES
11941194
PGAC_FUNC_GETTIMEOFDAY_1ARG
11951195

1196-
AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlinkscandirsetproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs wcstombs_l])
1196+
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])
11971197

11981198
AC_REPLACE_FUNCS(fseeko)
11991199
case $host_os in

‎contrib/pg_upgrade/file.c

Lines changed: 22 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ static intcopy_file(const char *fromfile, const char *tofile, bool force);
2121
staticintwin32_pghardlink(constchar*src,constchar*dst);
2222
#endif
2323

24-
#ifndefHAVE_SCANDIR
25-
staticintpg_scandir_internal(constchar*dirname,
26-
structdirent***namelist,
27-
int (*selector) (conststructdirent*));
28-
#endif
29-
3024

3125
/*
3226
* copyAndUpdateFile()
@@ -228,59 +222,18 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
228222

229223

230224
/*
231-
* pg_scandir()
232-
*
233-
* Wrapper for portable scandir functionality
234-
*/
235-
int
236-
pg_scandir(constchar*dirname,
237-
structdirent***namelist,
238-
int (*selector) (conststructdirent*))
239-
{
240-
#ifndefHAVE_SCANDIR
241-
returnpg_scandir_internal(dirname,namelist,selector);
242-
243-
/*
244-
* scandir() is originally from BSD 4.3, which had the third argument as
245-
* non-const. Linux and other C libraries have updated it to use a const.
246-
* http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-12/msg002
247-
* 14.html
248-
*
249-
* Here we try to guess which libc's need const, and which don't. The net
250-
* goal here is to try to suppress a compiler warning due to a prototype
251-
* mismatch of const usage. Ideally we would do this via autoconf, but
252-
* autoconf doesn't have a suitable builtin test and it seems overkill to
253-
* add one just to avoid a warning.
254-
*/
255-
#elif defined(__FreeBSD__)|| defined(__bsdi__)|| defined(__darwin__)|| defined(__OpenBSD__)
256-
/* no const */
257-
returnscandir(dirname,namelist, (int (*) (structdirent*))selector,NULL);
258-
#else
259-
/* use const */
260-
returnscandir(dirname,namelist,selector,NULL);
261-
#endif
262-
}
263-
264-
265-
#ifndefHAVE_SCANDIR
266-
/*
267-
* pg_scandir_internal()
268-
*
269-
* Implement our own scandir() on platforms that don't have it.
225+
* load_directory()
270226
*
271227
* Returns count of files that meet the selection criteria coded in
272228
* the function pointed to by selector. Creates an array of pointers
273229
* to dirent structures. Address of array returned in namelist.
274230
*
275231
* Note that the number of dirent structures needed is dynamically
276232
* allocated using realloc. Realloc can be inefficient if invoked a
277-
* large number of times. Its use in pg_upgrade is to find filesystem
278-
* filenames that have extended beyond the initial segment (file.1,
279-
* .2, etc.) and should therefore be invoked a small number of times.
233+
* large number of times.
280234
*/
281-
staticint
282-
pg_scandir_internal(constchar*dirname,
283-
structdirent***namelist,int (*selector) (conststructdirent*))
235+
int
236+
load_directory(constchar*dirname,structdirent***namelist)
284237
{
285238
DIR*dirdesc;
286239
structdirent*direntry;
@@ -295,42 +248,37 @@ pg_scandir_internal(const char *dirname,
295248

296249
while ((direntry=readdir(dirdesc))!=NULL)
297250
{
298-
/* Invoke the selector function to see if the direntry matches */
299-
if (!selector|| (*selector) (direntry))
300-
{
301-
count++;
251+
count++;
302252

303-
*namelist= (structdirent**)realloc((void*) (*namelist),
304-
(size_t) ((name_num+1)*sizeof(structdirent*)));
253+
*namelist= (structdirent**)realloc((void*) (*namelist),
254+
(size_t) ((name_num+1)*sizeof(structdirent*)));
305255

306-
if (*namelist==NULL)
307-
{
308-
closedir(dirdesc);
309-
return-1;
310-
}
256+
if (*namelist==NULL)
257+
{
258+
closedir(dirdesc);
259+
return-1;
260+
}
311261

312-
entrysize=sizeof(structdirent)-sizeof(direntry->d_name)+
313-
strlen(direntry->d_name)+1;
262+
entrysize=sizeof(structdirent)-sizeof(direntry->d_name)+
263+
strlen(direntry->d_name)+1;
314264

315-
(*namelist)[name_num]= (structdirent*)malloc(entrysize);
265+
(*namelist)[name_num]= (structdirent*)malloc(entrysize);
316266

317-
if ((*namelist)[name_num]==NULL)
318-
{
319-
closedir(dirdesc);
320-
return-1;
321-
}
267+
if ((*namelist)[name_num]==NULL)
268+
{
269+
closedir(dirdesc);
270+
return-1;
271+
}
322272

323-
memcpy((*namelist)[name_num],direntry,entrysize);
273+
memcpy((*namelist)[name_num],direntry,entrysize);
324274

325-
name_num++;
326-
}
275+
name_num++;
327276
}
328277

329278
closedir(dirdesc);
330279

331280
returncount;
332281
}
333-
#endif
334282

335283

336284
void

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,7 @@ const char *setupPageConverter(pageCnvCtx **result);
333333
typedefvoid*pageCnvCtx;
334334
#endif
335335

336-
intpg_scandir(constchar*dirname,structdirent***namelist,
337-
int (*selector) (conststructdirent*));
336+
intload_directory(constchar*dirname,structdirent***namelist);
338337
constchar*copyAndUpdateFile(pageCnvCtx*pageConverter,constchar*src,
339338
constchar*dst,boolforce);
340339
constchar*linkAndUpdateFile(pageCnvCtx*pageConverter,constchar*src,

‎contrib/pg_upgrade/relfilenode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
160160
}
161161

162162
snprintf(old_dir,sizeof(old_dir),"%s",maps[mapnum].old_dir);
163-
numFiles=pg_scandir(old_dir,&namelist,NULL);
163+
numFiles=load_directory(old_dir,&namelist);
164164
}
165165

166166
/* Copying files might take some time, so give feedback. */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp