Set permissions when creating .bak file
When opening the .bak file, truncate to 0 length if it already exists,
or create with the following permissions if it doesn't exist:
* reading and writing by the owner
* reading only by group members and others
Fixes compiler error on x86.
BUG=chrome-os-partner:7054
TEST=builds clean for x86-generic, arm & x86_64
Change-Id: Iaface75c8f78d4b7e36c50d677fc452297eebeb0
diff --git a/cyapa_fw_update.c b/cyapa_fw_update.c
index 6a46358..3a7a92b 100644
--- a/cyapa_fw_update.c
+++ b/cyapa_fw_update.c
@@ -596,7 +596,9 @@
int open_bak_fw_image(struct args *args)
{
- args->fd_bak_fw = open(args->bak_fw_image, O_RDWR | O_CREAT | O_TRUNC);
+ args->fd_bak_fw = open(args->bak_fw_image,
+ O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (args->fd_bak_fw < 0) {
prt_err("Cannot open backup file %s\n", args->bak_fw_image);
perror(NULL);