diff options
Diffstat (limited to 'ext4_utils/make_ext4fs_main.c')
-rw-r--r-- | ext4_utils/make_ext4fs_main.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c index d616c6d4..b83f57ee 100644 --- a/ext4_utils/make_ext4fs_main.c +++ b/ext4_utils/make_ext4fs_main.c @@ -14,8 +14,9 @@ * limitations under the License. */ -#include <unistd.h> +#include <fcntl.h> #include <libgen.h> +#include <unistd.h> #if defined(__linux__) #include <linux/fs.h> @@ -49,6 +50,8 @@ int main(int argc, char **argv) int crc = 0; int wipe = 0; int init_itabs = 0; + int fd; + int exitcode; while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:fwzJsct")) != -1) { switch (opt) { @@ -139,6 +142,19 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } - return make_ext4fs_internal(filename, directory, mountpoint, android, gzip, + if (strcmp(filename, "-")) { + fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd < 0) { + error_errno("open"); + return EXIT_FAILURE; + } + } else { + fd = STDOUT_FILENO; + } + + exitcode = make_ext4fs_internal(fd, directory, mountpoint, android, gzip, sparse, crc, wipe, init_itabs); + close(fd); + + return exitcode; } |