Skip to content

Commit 9dfca08

Browse files
committed
Revert "Update external partitions mount strategy"
This reverts commit 4ea83ca.
1 parent b711f5e commit 9dfca08

File tree

2 files changed

+24
-87
lines changed

2 files changed

+24
-87
lines changed

multirom.c

Lines changed: 23 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ int multirom(const char *rom_to_boot)
275275
{
276276
ERROR(NO_KEXEC_LOG_TEXT ": Something went wrong in mounting the needed partition, so falling back...");
277277
nokexec()->selected_method = NO_KEXEC_BOOT_NORMAL;
278-
s.is_second_boot = 0;
278+
s.is_second_boot = 0;
279279
//ERROR(NO_KEXEC_LOG_TEXT ": to Internal\n"); s.auto_boot_type = AUTOBOOT_FORCE_CURRENT; // force reboot to Internal (this would be mrom default behaviour)
280280
//ERROR(NO_KEXEC_LOG_TEXT ": to MultiROM GUI\n"); s.auto_boot_type = AUTOBOOT_NAME; // bring up the gui instead
281281
ERROR(NO_KEXEC_LOG_TEXT ": to Recovery\n"); exit = (EXIT_REBOOT_RECOVERY | EXIT_UMOUNT); goto finish; // reboot to recovery
@@ -757,15 +757,30 @@ int multirom_load_status(struct multirom_status *s)
757757
// find USB drive if we're booting from it
758758
if(s->curr_rom_part) // && s->is_second_boot)
759759
{
760-
multirom_update_and_scan_for_external_roms(s, s->curr_rom_part);
760+
struct usb_partition *p = NULL;
761+
int tries = 0;
762+
while(!p && tries < 10)
763+
{
764+
multirom_update_partitions(s);
765+
p = multirom_get_partition(s, s->curr_rom_part);
766+
767+
if(p)
768+
{
769+
multirom_scan_partition_for_roms(s, p);
770+
break;
771+
}
772+
773+
++tries;
774+
ERROR("part %s not found, waiting 1s (%d)\n", s->curr_rom_part, tries);
775+
sleep(1);
776+
}
761777
}
762778

763779
s->current_rom = multirom_get_rom(s, current_rom, s->curr_rom_part);
764780
if(!s->current_rom)
765781
{
766782
ERROR("Failed to select current rom (%s, part %s), using Internal!\n", current_rom, s->curr_rom_part);
767783
s->current_rom = multirom_get_internal(s);
768-
free(s->curr_rom_part);
769784
s->curr_rom_part = NULL;
770785
if(!s->current_rom)
771786
{
@@ -2522,12 +2537,6 @@ int multirom_update_partitions(struct multirom_status *s)
25222537
goto next_itr;
25232538
}
25242539

2525-
if(strncmp(name, "loop", 4) == 0) // ignore loop devices
2526-
{
2527-
free(name);
2528-
goto next_itr;
2529-
}
2530-
25312540
part = mzalloc(sizeof(struct usb_partition));
25322541
part->name = name;
25332542

@@ -2571,48 +2580,8 @@ int multirom_update_partitions(struct multirom_status *s)
25712580
return 0;
25722581
}
25732582

2574-
int is_mounted_properly(const char *src, const char *mnt_path)
2575-
{
2576-
int res = 0;
2577-
2578-
FILE *f;
2579-
2580-
f = fopen("/proc/mounts", "re");
2581-
if (f)
2582-
{
2583-
char mount_dev[256];
2584-
char mount_dir[256];
2585-
char mount_type[256];
2586-
char mount_opts[256];
2587-
int mount_freq;
2588-
int mount_passno;
2589-
int match;
2590-
2591-
do {
2592-
match = fscanf(f, "%255s %255s %255s %255s %d %d\n",
2593-
mount_dev, mount_dir, mount_type,
2594-
mount_opts, &mount_freq, &mount_passno);
2595-
mount_dev[255] = 0;
2596-
mount_dir[255] = 0;
2597-
mount_type[255] = 0;
2598-
mount_opts[255] = 0;
2599-
if ((match == 6) && (strcmp(src, mount_dev) == 0) && (strcmp(mnt_path, mount_dir) == 0)) {
2600-
res = 1;
2601-
break;
2602-
}
2603-
} while (match != EOF);
2604-
2605-
fclose(f);
2606-
}
2607-
2608-
return res;
2609-
}
2610-
26112583
int multirom_mount_usb(struct usb_partition *part)
26122584
{
2613-
int res = 0;
2614-
part->mount_path = NULL;
2615-
26162585
mkdir("/mnt", 0777);
26172586
mkdir("/mnt/mrom", 0777);
26182587

@@ -2627,18 +2596,13 @@ int multirom_mount_usb(struct usb_partition *part)
26272596
char src[256];
26282597
snprintf(src, sizeof(src), "/dev/block/%s", part->name);
26292598

2630-
if(is_mounted_properly(src, path))
2631-
{
2632-
INFO("Partition %s already mounted on %s\n", src, path);
2633-
res = 0;
2634-
}
2635-
else if(strncmp(part->fs, "ntfs", 4) == 0)
2599+
if(strncmp(part->fs, "ntfs", 4) == 0)
26362600
{
26372601
char *cmd[] = { ntfs_path, src, path, NULL };
26382602
if(run_cmd(cmd) != 0)
26392603
{
26402604
ERROR("Failed to mount %s with ntfs-3g\n", src);
2641-
res = -1;
2605+
return -1;
26422606
}
26432607
}
26442608
else if(strcmp(part->fs, "exfat") == 0)
@@ -2647,41 +2611,17 @@ int multirom_mount_usb(struct usb_partition *part)
26472611
if(run_cmd(cmd) != 0)
26482612
{
26492613
ERROR("Failed to mount %s with exfat\n", src);
2650-
res = -1;
2614+
return -1;
26512615
}
26522616
}
26532617
else if(mount(src, path, part->fs, MS_NOATIME, "") < 0)
26542618
{
26552619
ERROR("Failed to mount %s (%d: %s)\n", src, errno, strerror(errno));
2656-
res = -1;
2620+
return -1;
26572621
}
26582622

26592623
part->mount_path = strdup(path);
2660-
return res;
2661-
}
2662-
2663-
void multirom_update_and_scan_for_external_roms(struct multirom_status *s, char *part_uuid)
2664-
{
2665-
struct usb_partition *p = NULL;
2666-
int tries = 0;
2667-
while(!p && tries < 10) // is 10seconds enough for USB-OTG
2668-
{
2669-
multirom_update_partitions(s);
2670-
p = multirom_get_partition(s, part_uuid);
2671-
2672-
if(p)
2673-
{
2674-
multirom_scan_partition_for_roms(s, p);
2675-
break;
2676-
}
2677-
2678-
++tries;
2679-
ERROR("part %s not found, waiting 1s (%d)\n", s->curr_rom_part, tries);
2680-
sleep(1);
2681-
}
2682-
2683-
if(p)
2684-
multirom_dump_status(s);
2624+
return 0;
26852625
}
26862626

26872627
void *multirom_usb_refresh_thread_work(void *status)
@@ -2792,9 +2732,6 @@ int multirom_copy_log(char *klog, const char *dest_path_relative)
27922732

27932733
struct usb_partition *multirom_get_partition(struct multirom_status *s, char *uuid)
27942734
{
2795-
// FIXME: This may need to be reconsidered, it is possible for 2 different partitions
2796-
// to have the same uuid which will lead to a false positive.
2797-
// Probably a good idea, to add mount point and uuid
27982735
int i;
27992736
for(i = 0; s->partitions && s->partitions[i]; ++i)
28002737
if(strcmp(s->partitions[i]->uuid, uuid) == 0)

multirom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,5 @@ int multirom_run_scripts(const char *type, struct multirom_rom *rom);
173173
int multirom_update_rd_trampoline(const char *path);
174174
char *multirom_find_fstab_in_rc(const char *rcfile);
175175
void multirom_find_rom_icon(struct multirom_rom *rom);
176-
void multirom_update_and_scan_for_external_roms(struct multirom_status *s, char *part_uuid);
176+
177177
#endif

0 commit comments

Comments
 (0)