Skip to content

Instantly share code, notes, and snippets.

@invisiblek
Created January 22, 2015 19:55
Show Gist options
  • Save invisiblek/ca1151d4c2de9333eddc to your computer and use it in GitHub Desktop.
Save invisiblek/ca1151d4c2de9333eddc to your computer and use it in GitHub Desktop.
diff --git a/roots.cpp b/roots.cpp
index caf015f..4e6fc1d 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -232,8 +232,16 @@ fstab_rec* volume_for_path(const char* path) {
strcmp(rec->fs_type, "f2fs") == 0 ||
strcmp(rec->fs_type, "vfat") == 0)) {
detected_fs_type = blkid_get_tag_value(NULL, "TYPE", rec->blk_device);
- while (rec != NULL && strcmp(rec->fs_type, detected_fs_type) != 0) {
- rec = fs_mgr_get_entry_for_mount_point_after(rec, fstab, path);
+ if (detected_fs_type != NULL) {
+ while (rec != NULL && strcmp(rec->fs_type, detected_fs_type) != 0) {
+ rec = fs_mgr_get_entry_for_mount_point_after(rec, fstab, path);
+ }
+ if (rec == NULL) {
+ /* We didn't find a better candidate, use old behavior
+ * and pick the first response from fs_mgr.
+ */
+ rec = fs_mgr_get_entry_for_mount_point(fstab, path);
+ }
}
}
return rec;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment