rbd: check for all-zero buf in export, seek output if so

Use buf_is_zero in common/util.cc

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
This commit is contained in:
Dan Mick 2012-12-20 14:00:12 -08:00
parent 4a558048cf
commit 410903fe7a
2 changed files with 5 additions and 2 deletions

View File

@ -440,7 +440,7 @@ radosacl_SOURCES = radosacl.cc
radosacl_LDADD = librados.la $(PTHREAD_LIBS) -lm $(CRYPTO_LIBS) $(EXTRALIBS)
bin_DEBUGPROGRAMS += scratchtool scratchtoolpp radosacl
rbd_SOURCES = rbd.cc common/fiemap.cc common/secret.c common/TextTable.cc
rbd_SOURCES = rbd.cc common/fiemap.cc common/secret.c common/TextTable.cc common/util.cc
rbd_CXXFLAGS = ${AM_CXXFLAGS}
rbd_LDADD = libglobal.la librbd.la librados.la $(PTHREAD_LIBS) -lm -lkeyutils $(CRYPTO_LIBS) $(EXTRALIBS)
if LINUX

View File

@ -46,6 +46,7 @@
#include "include/rbd_types.h"
#include "common/TextTable.h"
#include "include/util.h"
#if defined(__linux__)
#include <linux/fs.h>
@ -721,8 +722,10 @@ static int export_read_cb(uint64_t ofs, size_t len, const char *buf, void *arg)
ret = write(fd, buf, len);
}
} else { // not stdout
if (!buf) /* a hole */
if (!buf || buf_is_zero(buf, len)) {
/* a hole */
return 0;
}
ret = lseek64(fd, ofs, SEEK_SET);
if (ret < 0)