|
16 | 16 | * |
17 | 17 | * |
18 | 18 | * IDENTIFICATION |
19 | | - *$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.59 2007/08/06 01:38:15 tgl Exp $ |
| 19 | + *$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.60 2007/08/29 16:31:36 tgl Exp $ |
20 | 20 | * |
21 | 21 | *------------------------------------------------------------------------- |
22 | 22 | */ |
@@ -1059,36 +1059,38 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th) |
1059 | 1059 | */ |
1060 | 1060 | fseeko(tmp,0,SEEK_END); |
1061 | 1061 | th->fileLen=ftello(tmp); |
| 1062 | +fseeko(tmp,0,SEEK_SET); |
1062 | 1063 |
|
1063 | 1064 | /* |
1064 | | - * Some compilerswith throw a warning knowing this test can never be true |
1065 | | - * because pgoff_t can't exceed the compared maximum. |
| 1065 | + * Some compilerswill throw a warning knowing this test can never be true |
| 1066 | + * because pgoff_t can't exceed the compared maximum on their platform. |
1066 | 1067 | */ |
1067 | 1068 | if (th->fileLen>MAX_TAR_MEMBER_FILELEN) |
1068 | 1069 | die_horribly(AH,modulename,"archive member too large for tar format\n"); |
1069 | | -fseeko(tmp,0,SEEK_SET); |
1070 | 1070 |
|
1071 | 1071 | _tarWriteHeader(th); |
1072 | 1072 |
|
1073 | | -while ((cnt=fread(&buf[0],1,32767,tmp))>0) |
| 1073 | +while ((cnt=fread(buf,1,sizeof(buf),tmp))>0) |
1074 | 1074 | { |
1075 | | -res=fwrite(&buf[0],1,cnt,th->tarFH); |
| 1075 | +res=fwrite(buf,1,cnt,th->tarFH); |
1076 | 1076 | if (res!=cnt) |
1077 | 1077 | die_horribly(AH,modulename, |
1078 | | -"could not write to output file: %s\n",strerror(errno)); |
| 1078 | +"could not write to output file: %s\n", |
| 1079 | +strerror(errno)); |
1079 | 1080 | len+=res; |
1080 | 1081 | } |
1081 | 1082 |
|
1082 | 1083 | if (fclose(tmp)!=0)/* This *should* delete it... */ |
1083 | | -die_horribly(AH,modulename,"could not close temporary file: %s\n",strerror(errno)); |
| 1084 | +die_horribly(AH,modulename,"could not close temporary file: %s\n", |
| 1085 | +strerror(errno)); |
1084 | 1086 |
|
1085 | 1087 | if (len!=th->fileLen) |
1086 | 1088 | { |
1087 | | -charbuf1[100], |
1088 | | -buf2[100]; |
| 1089 | +charbuf1[32], |
| 1090 | +buf2[32]; |
1089 | 1091 |
|
1090 | 1092 | snprintf(buf1,sizeof(buf1),INT64_FORMAT, (int64)len); |
1091 | | -snprintf(buf2,sizeof(buf2),INT64_FORMAT, (int64)th->pos); |
| 1093 | +snprintf(buf2,sizeof(buf2),INT64_FORMAT, (int64)th->fileLen); |
1092 | 1094 | die_horribly(AH,modulename,"actual file length (%s) does not match expected (%s)\n", |
1093 | 1095 | buf1,buf2); |
1094 | 1096 | } |
|