summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2010-07-19 10:31:34 -0700
committerKenny Root <kroot@google.com>2010-08-11 11:24:41 -0700
commit6e7ac5f0bceddf51947fbf3b376e278df0735603 (patch)
tree36772b5b1e134baddbc24b73bb59ee701c3acc58 /libs
parenta02b8b05dd1e8b8cf169e1f89542ef835b11fc13 (diff)
downloadframeworks_base-6e7ac5f0bceddf51947fbf3b376e278df0735603.zip
frameworks_base-6e7ac5f0bceddf51947fbf3b376e278df0735603.tar.gz
frameworks_base-6e7ac5f0bceddf51947fbf3b376e278df0735603.tar.bz2
Initial tool for OBB manipulation
Add "obbtool" host command for adding, removing, and querying Opaque Binary Blob (OBB) information from a file. Change-Id: Id2ac41e687ad2a500c362616d6738a8ae7e8f5c3
Diffstat (limited to 'libs')
-rw-r--r--libs/utils/ObbFile.cpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/libs/utils/ObbFile.cpp b/libs/utils/ObbFile.cpp
index fe49300..adedf0c 100644
--- a/libs/utils/ObbFile.cpp
+++ b/libs/utils/ObbFile.cpp
@@ -156,9 +156,9 @@ bool ObbFile::parseObbFile(int fd)
return false;
}
- if (footerSize < kFooterMinSize) {
- LOGW("claimed footer size is too small (%08zx; minimum size is 0x%x)\n",
- footerSize, kFooterMinSize);
+ if (footerSize < (kFooterMinSize - kFooterTagSize)) {
+ LOGW("claimed footer size is too small (0x%zx; minimum size is 0x%x)\n",
+ footerSize, kFooterMinSize - kFooterTagSize);
return false;
}
}
@@ -169,6 +169,8 @@ bool ObbFile::parseObbFile(int fd)
return false;
}
+ mFooterStart = fileOffset;
+
char* scanBuf = (char*)malloc(footerSize);
if (scanBuf == NULL) {
LOGW("couldn't allocate scanBuf: %s\n", strerror(errno));
@@ -293,4 +295,38 @@ bool ObbFile::writeTo(int fd)
return true;
}
+bool ObbFile::removeFrom(const char* filename)
+{
+ int fd;
+ bool success = false;
+
+ fd = ::open(filename, O_RDWR);
+ if (fd < 0) {
+ goto out;
+ }
+ success = removeFrom(fd);
+ close(fd);
+
+out:
+ if (!success) {
+ LOGW("failed to remove signature from %s: %s\n", filename, strerror(errno));
+ }
+ return success;
+}
+
+bool ObbFile::removeFrom(int fd)
+{
+ if (fd < 0) {
+ return false;
+ }
+
+ if (!readFrom(fd)) {
+ return false;
+ }
+
+ ftruncate(fd, mFooterStart);
+
+ return true;
+}
+
}