#At file:///home/msvensson/mysql/7.0-ndbzio/ based on revid:magnus.blaudd@strippedph
4275 Magnus Blåudd 2011-04-04
ndbzio
- add ndbz_file_size function to be used to ask about a ndbzio_stream's size,
this is to avoid haveing to use ndbzio_stream::file member which is to be
considered internal since ndbzio uses mysys functions internally when working
with files
modified:
storage/ndb/include/util/ndbzio.h
storage/ndb/src/common/util/ndbzio.c
storage/ndb/tools/restore/Restore.cpp
=== modified file 'storage/ndb/include/util/ndbzio.h'
--- a/storage/ndb/include/util/ndbzio.h 2011-04-01 13:03:45 +0000
+++ b/storage/ndb/include/util/ndbzio.h 2011-04-04 09:37:59 +0000
@@ -209,6 +209,11 @@ extern int ndbzclose(ndbzio_stream *file
error number (see function gzerror below).
*/
+/*
+ Return file size of the open ndbzio_stream
+*/
+extern int ndbz_file_size(ndbzio_stream *file, size_t *size);
+
#ifdef __cplusplus
}
#endif
=== modified file 'storage/ndb/src/common/util/ndbzio.c'
--- a/storage/ndb/src/common/util/ndbzio.c 2011-04-01 13:03:45 +0000
+++ b/storage/ndb/src/common/util/ndbzio.c 2011-04-04 09:37:59 +0000
@@ -1056,3 +1056,18 @@ int ndbzclose (ndbzio_stream *s)
return destroy(s);
}
+#include <my_dir.h> // MY_STAT, my_fstat
+
+int ndbz_file_size(ndbzio_stream *s, size_t *size)
+{
+ MY_STAT stat_buf;
+
+ if (s == NULL || size == NULL)
+ return -1;
+
+ if (my_fstat(s->file, &stat_buf, 0) != 0)
+ return -1;
+
+ *size = stat_buf.st_size;
+ return 0; // OK
+}
=== modified file 'storage/ndb/tools/restore/Restore.cpp'
--- a/storage/ndb/tools/restore/Restore.cpp 2011-04-01 12:30:27 +0000
+++ b/storage/ndb/tools/restore/Restore.cpp 2011-04-04 09:37:59 +0000
@@ -1335,25 +1335,22 @@ BackupFile::openFile(){
int r= ndbzopen(&m_file, m_fileName, O_RDONLY);
if(m_file.file < 0)
- r= -1;
+ return false;
- if (r==0)
+ size_t size;
+ if (ndbz_file_size(&m_file, &size) == 0)
{
- struct stat buf;
- if (fstat(m_file.file, &buf) == 0)
- {
- m_file_size = (Uint64)buf.st_size;
- info << "File size " << m_file_size << " bytes\n";
- }
- else
- {
- info << "Progress reporting degraded output since fstat failed,"
- << "errno: " << errno << endl;
- m_file_size = 0;
- }
+ m_file_size = (Uint64)size;
+ info << "File size " << m_file_size << " bytes\n";
+ }
+ else
+ {
+ info << "Progress reporting degraded output since fstat failed,"
+ << "errno: " << errno << endl;
+ m_file_size = 0;
}
- return r != 0;
+ return true;
}
Uint32 BackupFile::buffer_get_ptr_ahead(void **p_buf_ptr, Uint32 size, Uint32 nmemb)
@@ -1634,9 +1631,9 @@ BackupFile::readHeader(){
because footer contain 4 bytes 0 at the end of file.
we discard the remain data stored in m_buffer.
*/
- struct stat buf;
- if (fstat(m_file.file, &buf) == 0)
- m_file_size = (Uint64)buf.st_size;
+ size_t size;
+ if (ndbz_file_size(&m_file, &size) == 0)
+ m_file_size = (Uint64)size;
ndbzseek(&m_file, 4, SEEK_END);
m_file_pos = m_file_size - 4;
m_buffer_data_left = 0;
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@oracle.com-20110404093759-5bzpytpwq1aniefy.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:4275) | Magnus Blåudd | 4 Apr |