From: Eric Bollengier Date: Wed, 23 Jan 2008 20:47:28 +0000 (+0000) Subject: ebl Fix bextract to be able to extract non-portable Win32 data to X-Git-Tag: Release-7.0.0~5114 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b8075fffca1d51f9454daf2fc6435a4f17f6c4a2;p=bacula%2Fbacula ebl Fix bextract to be able to extract non-portable Win32 data to Unix/Linux clients git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6303 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index 70508df1f4..3737551d75 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -271,6 +271,26 @@ static void do_extract(char *devname) return; } +static bool store_data(BFILE *bfd, char *data, const int32_t length) +{ + if (is_win32_stream(attr->data_stream) && !have_win32_api()) { + set_portable_backup(bfd); + if (!processWin32BackupAPIBlock(bfd, data, length)) { + berrno be; + Emsg2(M_ERROR_TERM, 0, _("Write error on %s: %s\n"), + attr->ofname, be.bstrerror()); + return false; + } + } else if (bwrite(bfd, data, length) != (ssize_t)length) { + berrno be; + Emsg2(M_ERROR_TERM, 0, _("Write error on %s: %s\n"), + attr->ofname, be.bstrerror()); + return false; + } + + return true; +} + /* * Called here for each record from read_records() */ @@ -321,7 +341,6 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) return true; } - build_attr_output_fnames(jcr, attr); extract = false; @@ -373,11 +392,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) } total += wsize; Dmsg2(8, "Write %u bytes, total=%u\n", wsize, total); - if ((uint32_t)bwrite(&bfd, wbuf, wsize) != wsize) { - berrno be; - Emsg2(M_ERROR_TERM, 0, _("Write error on %s: %s\n"), - attr->ofname, be.bstrerror()); - } + store_data(&bfd, wbuf, wsize); fileAddr += wsize; } break; @@ -422,14 +437,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) } Dmsg2(100, "Write uncompressed %d bytes, total before write=%d\n", compress_len, total); - if ((uLongf)bwrite(&bfd, compress_buf, (size_t)compress_len) != compress_len) { - berrno be; - Pmsg0(0, _("===Write error===\n")); - Emsg2(M_ERROR, 0, _("Write error on %s: %s\n"), - attr->ofname, be.bstrerror()); - extract = false; - return true; - } + store_data(&bfd, compress_buf, compress_len); total += compress_len; fileAddr += compress_len; Dmsg2(100, "Compress len=%d uncompressed=%d\n", rec->data_len, diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 8f68eccbc8..0b775c2e18 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -2,6 +2,8 @@ General: 23Jan08 +ebl Fix bextract to be able to extract non-portable Win32 data to + Unix/Linux clients kes Move initialization of read/write res lock earlier in the code. This fixes the crash with a null conf file. This fixes bug #1030.