@@ -1030,7 +1030,7 @@ restore_data_file_internal(FILE *in, FILE *out, pgFile *file, uint32 backup_vers
10301030 * go to the next page.
10311031 */
10321032if (!headers && fseek (in ,read_len ,SEEK_CUR )!= 0 )
1033- elog (ERROR ,"Cannot seek block %u of\"%s\" : %s" ,
1033+ elog (ERROR ,"Cannot seek block %u of'%s' : %s" ,
10341034blknum ,from_fullpath ,strerror (errno ));
10351035continue ;
10361036}
@@ -1039,7 +1039,7 @@ restore_data_file_internal(FILE *in, FILE *out, pgFile *file, uint32 backup_vers
10391039cur_pos_in != headers [n_hdr ].pos )
10401040{
10411041if (fseek (in ,headers [n_hdr ].pos ,SEEK_SET )!= 0 )
1042- elog (ERROR ,"Cannot seek to offset %u of\"%s\" : %s" ,
1042+ elog (ERROR ,"Cannot seek to offset %u of'%s' : %s" ,
10431043headers [n_hdr ].pos ,from_fullpath ,strerror (errno ));
10441044
10451045cur_pos_in = headers [n_hdr ].pos ;
@@ -1802,7 +1802,6 @@ get_checksum_map(const char *fullpath, uint32 checksum_version,
18021802BlockNumber blknum = 0 ;
18031803char read_buffer [BLCKSZ ];
18041804char in_buf [STDIO_BUFSIZE ];
1805- off_t cur_pos = 0 ;
18061805
18071806/* open file */
18081807in = fopen (fullpath ,"r+" );
@@ -1820,32 +1819,16 @@ get_checksum_map(const char *fullpath, uint32 checksum_version,
18201819checksum_map = pgut_malloc (n_blocks * sizeof (PageState ));
18211820memset (checksum_map ,0 ,n_blocks * sizeof (PageState ));
18221821
1823- for (;; )
1822+ for (blknum = 0 ; blknum < n_blocks ; blknum ++ )
18241823{
1824+ size_t read_len = fread (read_buffer ,1 ,BLCKSZ ,in );
18251825PageState page_st ;
1826- size_t read_len = 0 ;
1827-
1828- if (blknum >=n_blocks )
1829- break ;
1830-
1831- if (cur_pos != blknum * BLCKSZ &&
1832- fseek (in ,blknum * BLCKSZ ,SEEK_SET ))
1833- {
1834- elog (ERROR ,"Cannot seek to offset %u in file \"%s\": %s" ,
1835- blknum * BLCKSZ ,fullpath ,strerror (errno ));
1836- }
1837-
1838- read_len = fread (read_buffer ,1 ,BLCKSZ ,in );
1839- cur_pos += read_len ;
18401826
18411827/* report error */
18421828if (ferror (in ))
18431829elog (ERROR ,"Cannot read block %u of \"%s\": %s" ,
18441830blknum ,fullpath ,strerror (errno ));
18451831
1846- if (read_len == 0 && feof (in ))
1847- break ;
1848-
18491832if (read_len == BLCKSZ )
18501833{
18511834int rc = validate_one_page (read_buffer ,segmentno + blknum ,
@@ -1861,11 +1844,12 @@ get_checksum_map(const char *fullpath, uint32 checksum_version,
18611844
18621845checksum_map [blknum ].lsn = page_st .lsn ;
18631846}
1864-
1865- blknum ++ ;
18661847}
18671848else
1868- elog (WARNING ,"Odd size read len %lu for blknum %u in file \"%s\"" ,read_len ,blknum ,fullpath );
1849+ elog (ERROR ,"Failed to read blknum %u from file \"%s\"" ,blknum ,fullpath );
1850+
1851+ if (feof (in ))
1852+ break ;
18691853
18701854if (interrupted )
18711855elog (ERROR ,"Interrupted during page reading" );