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

Commitf023fc6

Browse files
committed
Use ReadDir() not readdir() so as to have some modicum of error checking.
1 parent74888b9 commitf023fc6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

‎src/backend/utils/adt/dbsize.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
22
* dbsize.c
3-
*object size functions
3+
*object size functions
44
*
55
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
66
*
77
* IDENTIFICATION
8-
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.2 2005/08/0214:07:27 tgl Exp $
8+
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.3 2005/08/0215:17:24 tgl Exp $
99
*
1010
*/
1111

@@ -40,7 +40,7 @@ db_dir_size(const char *path)
4040
if (!dirdesc)
4141
return0;
4242

43-
while ((direntry=readdir(dirdesc))!=NULL)
43+
while ((direntry=ReadDir(dirdesc,path))!=NULL)
4444
{
4545
structstatfst;
4646

@@ -71,6 +71,7 @@ calculate_database_size(Oid dbOid)
7171
int64totalsize=0;
7272
DIR*dirdesc;
7373
structdirent*direntry;
74+
chardirpath[MAXPGPATH];
7475
charpathname[MAXPGPATH];
7576

7677
/* Shared storage in pg_global is not counted */
@@ -80,15 +81,15 @@ calculate_database_size(Oid dbOid)
8081
totalsize+=db_dir_size(pathname);
8182

8283
/* Scan the non-default tablespaces */
83-
snprintf(pathname,MAXPGPATH,"%s/pg_tblspc",DataDir);
84-
dirdesc=AllocateDir(pathname);
84+
snprintf(dirpath,MAXPGPATH,"%s/pg_tblspc",DataDir);
85+
dirdesc=AllocateDir(dirpath);
8586
if (!dirdesc)
8687
ereport(ERROR,
8788
(errcode_for_file_access(),
8889
errmsg("could not open tablespace directory \"%s\": %m",
89-
pathname)));
90+
dirpath)));
9091

91-
while ((direntry=readdir(dirdesc))!=NULL)
92+
while ((direntry=ReadDir(dirdesc,dirpath))!=NULL)
9293
{
9394
if (strcmp(direntry->d_name,".")==0||
9495
strcmp(direntry->d_name,"..")==0)
@@ -161,7 +162,7 @@ calculate_tablespace_size(Oid tblspcOid)
161162
errmsg("could not open tablespace directory \"%s\": %m",
162163
tblspcPath)));
163164

164-
while ((direntry=readdir(dirdesc))!=NULL)
165+
while ((direntry=ReadDir(dirdesc,tblspcPath))!=NULL)
165166
{
166167
structstatfst;
167168

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp