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

Commitbd5a9a5

Browse files
committed
pg_upgrade: Report full disk better
Previously, pg_upgrade would abort copy_file() on a short write withoutsetting errno, which the caller would report as an error with themessage "Success". We assume ENOSPC in that case, as we do elsewhere inthe code. Also set errno in some other error cases in copy_file() toavoid bogus "Success" error messages.This was broken in6b711cf, so 9.2 andbefore are OK.
1 parent0dbf9a6 commitbd5a9a5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎contrib/pg_upgrade/file.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,22 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
136136
intsave_errno=0;
137137

138138
if ((srcfile==NULL)|| (dstfile==NULL))
139+
{
140+
errno=EINVAL;
139141
return-1;
142+
}
140143

141144
if ((src_fd=open(srcfile,O_RDONLY,0))<0)
142145
return-1;
143146

144147
if ((dest_fd=open(dstfile,O_RDWR |O_CREAT | (force ?0 :O_EXCL),S_IRUSR |S_IWUSR))<0)
145148
{
149+
save_errno=errno;
150+
146151
if (src_fd!=0)
147152
close(src_fd);
148153

154+
errno=save_errno;
149155
return-1;
150156
}
151157

@@ -170,6 +176,9 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
170176

171177
if (write(dest_fd,buffer,nbytes)!=nbytes)
172178
{
179+
/* if write didn't set errno, assume problem is no disk space */
180+
if (errno==0)
181+
errno=ENOSPC;
173182
save_errno=errno;
174183
ret=-1;
175184
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp