Ignore wipe operation on non-block devices.
The implementation of make_ext4fs() calls make_ext4fs_internal() by
forcing the |wipe| parameter to true, which is problematic when the
library is used within the emulator (the wipe operation will always
fail on non-Linux platforms).
This patch does the following:
- Add a 'is_block_device_fd()' function to check that a file descriptor
points to a real block device.
- Modify the implementation of wipe_block_device() uses it to return
silently when trying to wipe a non-block-device file.
- Add a WIPE_IS_SUPPORTED flag in wipe.h that indicates whether
block device wiping is supported on the current platform
(for now, this is only the case on Linux).
BUG=NONE
Change-Id: I62b62b7c3e99b465c3b876154231e7c2fe541b23
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index f164883..6a0f875 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -623,8 +623,9 @@
aux_info.sb->s_blocks_count_lo - aux_info.sb->s_free_blocks_count_lo,
aux_info.sb->s_blocks_count_lo);
- if (wipe)
+ if (wipe && WIPE_IS_SUPPORTED) {
wipe_block_device(fd, info.len);
+ }
write_ext4_image(fd, gzip, sparse, crc);