diff options
author | Vladimir Chtchetkine <vchtchetkine@google.com> | 2011-10-13 09:49:01 -0700 |
---|---|---|
committer | Vladimir Chtchetkine <vchtchetkine@google.com> | 2011-10-13 09:49:01 -0700 |
commit | 90a3681c1b2332093821a24c244bc3a86dbb1967 (patch) | |
tree | 66db2e0a068838b043b142d168a21f64e9d1fb8b /hw | |
parent | 3cfc387ae5c0dfea3482771b27e84802c07d33f9 (diff) | |
download | external_qemu-90a3681c1b2332093821a24c244bc3a86dbb1967.zip external_qemu-90a3681c1b2332093821a24c244bc3a86dbb1967.tar.gz external_qemu-90a3681c1b2332093821a24c244bc3a86dbb1967.tar.bz2 |
Fix -wipe-data option
Forces overwriting (truncating) of the userimage-qemu.img file on condition that
it is being initialized from userimage.img file. If *-qemu file is not truncated
the system will pick up on artifacts located behind the overwritten area of
the *-qemu.img file.
Change-Id: I091dff0069d7049588b11c4654fe134947db101b
Diffstat (limited to 'hw')
-rw-r--r-- | hw/goldfish_nand.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/hw/goldfish_nand.c b/hw/goldfish_nand.c index 49d575a..31e814b 100644 --- a/hw/goldfish_nand.c +++ b/hw/goldfish_nand.c @@ -795,7 +795,18 @@ void nand_add_dev(const char *arg) } if(rwfilename) { - rwfd = open(rwfilename, O_BINARY | (read_only ? O_RDONLY : O_RDWR)); + if (initfilename) { + /* Overwrite with content of the 'initfilename'. */ + if (read_only) { + /* Cannot be readonly when initializing the device from another file. */ + XLOG("incompatible read only option is requested while initializing %.*s from %s\n", + devname_len, devname, initfilename); + exit(1); + } + rwfd = open(rwfilename, O_BINARY | O_TRUNC | O_RDWR); + } else { + rwfd = open(rwfilename, O_BINARY | (read_only ? O_RDONLY : O_RDWR)); + } if(rwfd < 0) { XLOG("could not open file %s, %s\n", rwfilename, strerror(errno)); exit(1); |