Loading fastbootd/commands.c +3 −4 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ static void cmd_boot(struct protocol_handle *phandle, const char *arg) second_ptr = (void *)((unsigned) ramdisk_ptr + ramdisk_actual); D(INFO, "preparing to boot"); // Prepares boot physical addresses from header are ignored // Prepares boot physical address. Addresses from header are ignored rv = prepare_boot_linux(hdr->kernel_addr, kernel_ptr, kernel_actual, hdr->ramdisk_addr, ramdisk_ptr, ramdisk_actual, hdr->second_addr, second_ptr, second_actual, Loading Loading @@ -294,7 +294,7 @@ static void cmd_flash(struct protocol_handle *phandle, const char *arg) return; } // TODO: Maybe its goot idea to check whether the partition is just bootable partition // TODO: Maybe its goot idea to check whether the partition is bootable if (!strcmp(arg, "boot") || !strcmp(arg, "recovery")) { if (read_data_once(data_fd, data, BOOT_MAGIC_SIZE) < BOOT_MAGIC_SIZE) { fastboot_fail(phandle, "incoming data read error, cannot read boot header"); Loading Loading @@ -329,7 +329,6 @@ static void cmd_flash(struct protocol_handle *phandle, const char *arg) flash_close(partition); close(data_fd); //TODO: check who is closing phandle->download_fd fastboot_okay(phandle, ""); } Loading Loading @@ -375,7 +374,6 @@ static void cmd_download(struct protocol_handle *phandle, const char *arg) phandle->download_fd = protocol_handle_download(phandle, len); if (phandle->download_fd < 0) { //handle->state = STATE_ERROR; fastboot_fail(phandle, "download failed"); return; } Loading @@ -386,6 +384,7 @@ static void cmd_download(struct protocol_handle *phandle, const char *arg) static void cmd_oem(struct protocol_handle *phandle, const char *arg) { const char *response = ""; //TODO: Maybe it should get download descriptor also if (trigger_oem_cmd(arg, &response)) fastboot_fail(phandle, response); else Loading fastbootd/commands/partitions.c +4 −5 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ const uint8_t partition_type_uuid[16] = { 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7, }; //TODO: If both blocks are invalid should I leave everything to vendor (through libvendor) //TODO: There is assumption that we are using little endian static void GPT_entry_clear(struct GPT_entry_raw *entry) { Loading @@ -83,6 +83,7 @@ int gpt_mmap(struct GPT_mapping *mapping, uint64_t location, int size, int fd) D(ERR, "the location of mapping area is outside of the device size %lld", sz); return 1; } location = ALIGN_DOWN(location, PAGE_SIZE); mapping->map_ptr = mmap64(NULL, mapping->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, location); Loading Loading @@ -291,7 +292,7 @@ int GPT_delete_entry(struct GPT_entry_table *table, struct GPT_entry_raw *entry) } D(DEBUG, "Deleting gpt entry '%s'\n", raw->partition_guid); // This entry can be empty in the middle // Entry in the middle of table may become empty GPT_entry_clear(raw); return 0; Loading Loading @@ -382,7 +383,6 @@ int strncmp_UTF16(const uint16_t *s1, const uint16_t *s2, size_t n) struct GPT_entry_raw *GPT_get_pointer_by_name(struct GPT_entry_table *table, const char *name) { //TODO: reverse direction int count = (int) table->header->entries_count; int current; Loading Loading @@ -560,10 +560,9 @@ int GPT_parse_entry(char *string, struct GPT_entry_raw *entry) void entry_set_guid(int n, uint8_t *guid) { guid[0] = (uint8_t) (n + 1); int fd; fd = open("/dev/urandom", O_RDONLY); read(fd, &guid[1], 15); read(fd, guid, 16); close(fd); //rfc4122 Loading Loading
fastbootd/commands.c +3 −4 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ static void cmd_boot(struct protocol_handle *phandle, const char *arg) second_ptr = (void *)((unsigned) ramdisk_ptr + ramdisk_actual); D(INFO, "preparing to boot"); // Prepares boot physical addresses from header are ignored // Prepares boot physical address. Addresses from header are ignored rv = prepare_boot_linux(hdr->kernel_addr, kernel_ptr, kernel_actual, hdr->ramdisk_addr, ramdisk_ptr, ramdisk_actual, hdr->second_addr, second_ptr, second_actual, Loading Loading @@ -294,7 +294,7 @@ static void cmd_flash(struct protocol_handle *phandle, const char *arg) return; } // TODO: Maybe its goot idea to check whether the partition is just bootable partition // TODO: Maybe its goot idea to check whether the partition is bootable if (!strcmp(arg, "boot") || !strcmp(arg, "recovery")) { if (read_data_once(data_fd, data, BOOT_MAGIC_SIZE) < BOOT_MAGIC_SIZE) { fastboot_fail(phandle, "incoming data read error, cannot read boot header"); Loading Loading @@ -329,7 +329,6 @@ static void cmd_flash(struct protocol_handle *phandle, const char *arg) flash_close(partition); close(data_fd); //TODO: check who is closing phandle->download_fd fastboot_okay(phandle, ""); } Loading Loading @@ -375,7 +374,6 @@ static void cmd_download(struct protocol_handle *phandle, const char *arg) phandle->download_fd = protocol_handle_download(phandle, len); if (phandle->download_fd < 0) { //handle->state = STATE_ERROR; fastboot_fail(phandle, "download failed"); return; } Loading @@ -386,6 +384,7 @@ static void cmd_download(struct protocol_handle *phandle, const char *arg) static void cmd_oem(struct protocol_handle *phandle, const char *arg) { const char *response = ""; //TODO: Maybe it should get download descriptor also if (trigger_oem_cmd(arg, &response)) fastboot_fail(phandle, response); else Loading
fastbootd/commands/partitions.c +4 −5 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ const uint8_t partition_type_uuid[16] = { 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7, }; //TODO: If both blocks are invalid should I leave everything to vendor (through libvendor) //TODO: There is assumption that we are using little endian static void GPT_entry_clear(struct GPT_entry_raw *entry) { Loading @@ -83,6 +83,7 @@ int gpt_mmap(struct GPT_mapping *mapping, uint64_t location, int size, int fd) D(ERR, "the location of mapping area is outside of the device size %lld", sz); return 1; } location = ALIGN_DOWN(location, PAGE_SIZE); mapping->map_ptr = mmap64(NULL, mapping->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, location); Loading Loading @@ -291,7 +292,7 @@ int GPT_delete_entry(struct GPT_entry_table *table, struct GPT_entry_raw *entry) } D(DEBUG, "Deleting gpt entry '%s'\n", raw->partition_guid); // This entry can be empty in the middle // Entry in the middle of table may become empty GPT_entry_clear(raw); return 0; Loading Loading @@ -382,7 +383,6 @@ int strncmp_UTF16(const uint16_t *s1, const uint16_t *s2, size_t n) struct GPT_entry_raw *GPT_get_pointer_by_name(struct GPT_entry_table *table, const char *name) { //TODO: reverse direction int count = (int) table->header->entries_count; int current; Loading Loading @@ -560,10 +560,9 @@ int GPT_parse_entry(char *string, struct GPT_entry_raw *entry) void entry_set_guid(int n, uint8_t *guid) { guid[0] = (uint8_t) (n + 1); int fd; fd = open("/dev/urandom", O_RDONLY); read(fd, &guid[1], 15); read(fd, guid, 16); close(fd); //rfc4122 Loading