mkbootfs: Fix the default st_mode for root directory.
CL in [1] fixed the wrong mode for the root directory from 0644 to 0755.
However it only handles the path by calling mkbootfs with canned
fs_config (i.e. with -f flag). When calling mkbootfs without -f flag, it
still treats the root directory as a file. This renders the generated
boot/recovery images w/ and w/o -f being different, and leads to the
incorrect checksums in /system/bin/install-recovery.sh.
[1] commit aa8f2f65a030f71506277e2a8d64d83a099e9feb.
Bug: 31988535
Test: `make dist` and verify the checksums in /system/bin/install-recovery.sh.
Change-Id: Ib50fadb23367da0b46944ae0579093da21412593
diff --git a/cpio/mkbootfs.c b/cpio/mkbootfs.c
index 0e35323..b89c395 100644
--- a/cpio/mkbootfs.c
+++ b/cpio/mkbootfs.c
@@ -51,6 +51,8 @@
#define CANNED_LINE_LENGTH (1024)
#endif
+#define TRAILER "TRAILER!!!"
+
static int verbose = 0;
static int total_size = 0;
@@ -80,8 +82,8 @@
} else {
// Use the compiled-in fs_config() function.
unsigned st_mode = s->st_mode;
- fs_config(path, S_ISDIR(s->st_mode), target_out_path,
- &s->st_uid, &s->st_gid, &st_mode, &capabilities);
+ int is_dir = S_ISDIR(s->st_mode) || strcmp(path, TRAILER) == 0;
+ fs_config(path, is_dir, target_out_path, &s->st_uid, &s->st_gid, &st_mode, &capabilities);
s->st_mode = (typeof(s->st_mode)) st_mode;
}
}
@@ -140,7 +142,7 @@
{
struct stat s;
memset(&s, 0, sizeof(s));
- _eject(&s, "TRAILER!!!", 10, 0, 0);
+ _eject(&s, TRAILER, 10, 0, 0);
while(total_size & 0xff) {
total_size++;