OSDN Git Service

Fix handling of directory entries
authorChristopher Tate <ctate@google.com>
Thu, 9 Jun 2011 03:09:31 +0000 (20:09 -0700)
committerChristopher Tate <ctate@google.com>
Thu, 9 Jun 2011 03:11:49 +0000 (20:11 -0700)
Don't emit tar blocks for directories with an invalid nonzero size.  Also, if
such an entry is encountered during restore, don't actually attempt to treat
it as valid and thus skip over the next actual tar entry.

This patch also adds tracking of the data actually consumed during restore,
and reports a total at the end of stream.

Change-Id: I625173f76df3c007e899209101ff2b587841f184

libs/utils/BackupHelpers.cpp

index f933199..87549fe 100644 (file)
@@ -525,6 +525,7 @@ int write_tarfile(const String8& packageName, const String8& domain,
     String8 prefix;
 
     const int isdir = S_ISDIR(s.st_mode);
+    if (isdir) s.st_size = 0;   // directories get no actual data in the tar stream
 
     // !!! TODO: use mmap when possible to avoid churning the buffer cache
     // !!! TODO: this will break with symlinks; need to use readlink(2)