smbtar - can4t recover
Jeremy Allison
jeremy at netcom.com
Thu Feb 18 18:32:02 GMT 1999
Alex Oesterle wrote:
> my smbtar (2.0.0) has done perfekt backup tar of Win NT archives ( both fat
> and ntfs)
>
> but , by recovering the data i get a strong fault.
>
> <<< abonding , reading -1 tar header
>
> whats wrong , please help me
>
>its urgent
Alex,
Try the following patch (generously provided by
Bob Boehmer - *great* work Bob !). It fixes 3 problems
with smbtar in 2.0.2 and will be in 2.0.3.
Hope this helps your urgent problem
Regards,
Jeremy Allison,
Samba Team.
------------------cut here------------------------------------
Index: clitar.c
===================================================================
RCS file: /data/cvs/samba/source/client/clitar.c,v
retrieving revision 1.61.2.4
retrieving revision 1.61.2.5
diff -u -r1.61.2.4 -r1.61.2.5
--- clitar.c 1999/02/06 22:42:45 1.61.2.4
+++ clitar.c 1999/02/17 23:27:29 1.61.2.5
@@ -922,14 +922,27 @@
DEBUG(5, ("Reading more data into ltarbuf ...\n"));
- total = 0;
-
- for (bufread = read(tarhandle, ltarbuf, bufsiz); total < bufsiz; total += bufread) {
-
- if (bufread <= 0) { /* An error, return false */
- return (total > 0 ? -2 : bufread);
+ /*
+ * Bugfix from Bob Boehmer <boehmer at worldnet.att.net>
+ * Fixes bug where read can return short if coming from
+ * a pipe.
+ */
+
+ bufread = read(tarhandle, ltarbuf, bufsiz);
+ total = bufread;
+
+ while (total < bufsiz) {
+ if (bufread < 0) { /* An error, return false */
+ return (total > 0 ? -2 : bufread);
}
-
+ if (bufread == 0) {
+ if (total <= 0) {
+ return -2;
+ }
+ break;
+ }
+ bufread = read(tarhandle, <arbuf[total], bufsiz - total);
+ total += bufread;
}
DEBUG(5, ("Total bytes read ... %i\n", total));
@@ -966,25 +979,28 @@
return(True);
}
+
+/*************************************************************
+ Get a file from the tar file and store it.
+ When this is called, tarbuf already contains the first
+ file block. This is a bit broken & needs fixing.
+**************************************************************/
-/* We get a file from the tar file and store it */
static int get_file(file_info2 finfo)
{
- int fsize = finfo.size;
int fnum = -1, pos = 0, dsize = 0, rsize = 0, bpos = 0;
- DEBUG(5, ("get_file: file: %s, size %i\n", finfo.name, fsize));
+ DEBUG(5, ("get_file: file: %s, size %i\n", finfo.name, finfo.size));
if (ensurepath(finfo.name) &&
- (fnum=cli_open(cli, finfo.name, O_WRONLY|O_CREAT|O_TRUNC, DENY_NONE)) == -1)
- {
+ (fnum=cli_open(cli, finfo.name, O_WRONLY|O_CREAT|O_TRUNC, DENY_NONE)) == -1) {
DEBUG(0, ("abandoning restore\n"));
return(False);
- }
+ }
/* read the blocks from the tar file and write to the remote file */
- rsize = fsize; /* This is how much to write */
+ rsize = finfo.size; /* This is how much to write */
while (rsize > 0) {
@@ -1022,17 +1038,23 @@
}
- while (dsize >= TBLOCK) {
+ /*
+ * Bugfix from Bob Boehmer <boehmer at worldnet.att.net>.
+ * If the file being extracted is an exact multiple of
+ * TBLOCK bytes then we don't want to extract the next
+ * block from the tarfile here, as it will be done in
+ * the caller of get_file().
+ */
- if (next_block(tarbuf, &buffer_p, tbufsiz) <=0) {
+ while (((rsize != 0) && (dsize >= TBLOCK)) ||
+ ((rsize == 0) && (dsize > TBLOCK))) {
+ if (next_block(tarbuf, &buffer_p, tbufsiz) <=0) {
DEBUG(0, ("Empty file, short tar file, or read error: %s\n", strerror(errno)));
return False;
-
}
dsize -= TBLOCK;
-
}
bpos = dsize;
@@ -1228,10 +1250,14 @@
case '0': /* Should use symbolic names--FIXME */
- /* Skip to the next block first, so we can get the file, FIXME, should
- be in get_file ... */
+ /*
+ * Skip to the next block first, so we can get the file, FIXME, should
+ * be in get_file ...
+ * The 'finfo.size != 0' fix is from Bob Boehmer <boehmer at worldnet.att.net>
+ * Fixes bug where file size in tarfile is zero.
+ */
- if (next_block(tarbuf, &buffer_p, tbufsiz) <=0) {
+ if ((finfo.size != 0) && next_block(tarbuf, &buffer_p, tbufsiz) <=0) {
DEBUG(0, ("Short file, bailing out...\n"));
return;
}
---------------------------end patch-------------------------------
More information about the samba
mailing list