Skip to content

storage: Try opening the slot-suffixed partition #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

quic-kdybcio
Copy link
Contributor

@quic-kdybcio quic-kdybcio commented Jul 2, 2025

Some devices ship 2 copies of remote partitions (see e.g. #22), which the current code can't cope with.

Add parsing of a slot suffix (via '-S', single character) and if passed, retry opening partition (via a partlabel) with it.

@quic-kdybcio quic-kdybcio marked this pull request as draft July 2, 2025 09:24
Some devices ship 2 copies of remote partitions (see e.g. linux-msm#22), which
the current code can't cope with.

Add parsing of a slot suffix (via '-S', single character) and if
passed, retry opening partition (via a partlabel) with it.

Signed-off-by: Konrad Dybcio <[email protected]>
@quic-kdybcio quic-kdybcio marked this pull request as ready for review July 2, 2025 11:00
@@ -26,7 +26,8 @@ ssize_t rmtfs_mem_write(struct rmtfs_mem *rmem, unsigned long phys_address, cons
struct rmtfd;

int storage_init(const char *storage_root, bool read_only, bool use_partitions);
struct rmtfd *storage_open(unsigned node, const char *path);
#define SLOT_SUFFIX_LEN (2 + 1) /* "_a" or "_b", null-terminated */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be necessary.

@@ -535,6 +536,20 @@ int main(int argc, char **argv)

break;

/* Partlabel slot suffix on A/B devices */
case 'S':
if (strnlen(optarg, 1 + 1) != 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say, let users pass the complete suffix, like '_a', '_b', '_some_user_idea', etc. There is no need to limit it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to limit it to what Android expects.. otherwise we'll have to make up for it in all of our other software as well

return -1;
}

ret = snprintf(slot_suffix, SLOT_SUFFIX_LEN, "_%s", optarg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asnprintf is your friend if you insist

@@ -27,6 +27,7 @@

static struct rmtfs_mem *rmem;
static sig_atomic_t sig_int_count;
static char slot_suffix[SLOT_SUFFIX_LEN];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

char * would be a better fit. Not need to be len-picky.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it neater not to sprinkle free/gotos all over the program

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants