Пример #1
0
Volume* volume_for_path(const char* path) {
    fstab_rec *rec = fs_mgr_get_entry_for_mount_point(fstab, path);

    if (rec == NULL)
        return rec;

    if (strcmp(rec->fs_type, "ext4") == 0 || strcmp(rec->fs_type, "f2fs") == 0 ||
            strcmp(rec->fs_type, "vfat") == 0) {
        char *detected_fs_type = blkid_get_tag_value(NULL, "TYPE", rec->blk_device);

        if (detected_fs_type == NULL)
            return rec;

        fstab_rec *fetched_rec = rec;
        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)
            return fetched_rec;
    }

    return rec;
}
Пример #2
0
/*
 * Returns the 1st matching mount point.
 * There might be more. To look for others, use fs_mgr_get_entry_for_mount_point_after()
 * and give the fstab_rec from the previous search.
 */
struct fstab_rec *fs_mgr_get_entry_for_mount_point(struct fstab *fstab, const char *path)
{
    return fs_mgr_get_entry_for_mount_point_after(NULL, fstab, path);
}