Commit Graph

10 Commits

Author SHA1 Message Date
Eric Curtin
9d7600df51 Use scope-based memory management for malloc, free, open, close, etc.
If we are using C++, we might as well use scope-based memory management
for these things, cleaner and less error prone. Also removed
unnecessary gotos.
2023-05-29 01:26:29 +00:00
Eric Curtin
843aa92266 Change hdr_offset to signed value, so lseek64 return can be checked
The lines:

	if (instance == PRIMARY_GPT)
		hdr_offset = block_size;
	else {
		hdr_offset = lseek64(fd, 0, SEEK_END) - block_size;
	}
	if (hdr_offset < 0) {
		fprintf(stderr, "%s: Failed to get gpt header offset\n",
			__func__);
		goto error;
	}

are error checked. But previously hdr_offset could never be less than
zero because it was unsigned.
2023-05-15 20:28:54 +01:00
Richard Acayan
17ee1b8e65 detect and handle emmc-backed xbl partitions when switching slots 2022-08-31 17:49:18 -04:00
Richard Acayan
c1f24adfb6 properly remove the partition number and separator 2022-08-31 17:10:31 -04:00
Caleb Connolly
50ef0328af minor cleanups, improve error handling
gracefully handle UFS_BSG not being enabled in the kernel, rather than
putting the device into a semi-bricked state (oops).
2022-06-10 19:18:13 +01:00
Caleb Connolly
487a96f663 gpt-utils: drop unused function
it also called strlcpy which only exists on musl and bionic, dropping it
lets this build on glibc too.
2022-06-05 22:30:34 +01:00
Caleb Connolly
4c49647382 cleanup, stub out tests
not sure how best to write tests, probably a larger test framework on
a board farm to test on real devices will be more sensible.
2022-06-04 15:51:22 +01:00
Caleb Connolly
55612452e0 its ALIIIIIIVE
not yet properly tested, but it seems to mostly work just fine. Slot
switching and marking boot as successful at least just work!
2022-06-04 04:42:40 +01:00
Caleb Connolly
b28a87499c cleanup, still doesn't seem to work
getting attributes work, setting them (e.g. with mark_boot_successful)
doesn't seem to work properly.

The IOCTL required to set the boot LUN doesn't work, some kernel driver
is missing for it.
2021-10-10 02:30:13 +01:00
Caleb Connolly
2f5bf10269 initial commit
This is a port of the Android bootctrl HAL and Qualcomms GPT based
implementation for musl/glibc based systems running mainline linux

Currently it doesn't work because the gpt hdr which is read doesn't
seem to have valid data.
2021-10-09 23:16:20 +01:00