static void build_fs_mount_list(FsMountList *mounts, Error **errp)

{

    FsMount *mount;

    char const *mountinfo = "/proc/self/mountinfo";

    FILE *fp;

    char *line = NULL, *dash;

    size_t n;

    char check;

    unsigned int devmajor, devminor;

    int ret, dir_s, dir_e, type_s, type_e, dev_s, dev_e;



    fp = fopen(mountinfo, "r");

    if (!fp) {

        build_fs_mount_list_from_mtab(mounts, errp);

        return;

    }



    while (getline(&line, &n, fp) != -1) {

        ret = sscanf(line, "%*u %*u %u:%u %*s %n%*s%n%c",

                     &devmajor, &devminor, &dir_s, &dir_e, &check);

        if (ret < 3) {

            continue;

        }

        dash = strstr(line + dir_e, " - ");

        if (!dash) {

            continue;

        }

        ret = sscanf(dash, " - %n%*s%n %n%*s%n%c",

                     &type_s, &type_e, &dev_s, &dev_e, &check);

        if (ret < 1) {

            continue;

        }

        line[dir_e] = 0;

        dash[type_e] = 0;

        dash[dev_e] = 0;

        decode_mntname(line + dir_s, dir_e - dir_s);

        decode_mntname(dash + dev_s, dev_e - dev_s);

        if (devmajor == 0) {

            /* btrfs reports major number = 0 */

            if (strcmp("btrfs", dash + type_s) != 0 ||

                dev_major_minor(dash + dev_s, &devmajor, &devminor) < 0) {

                continue;

            }

        }



        mount = g_malloc0(sizeof(FsMount));

        mount->dirname = g_strdup(line + dir_s);

        mount->devtype = g_strdup(dash + type_s);

        mount->devmajor = devmajor;

        mount->devminor = devminor;



        QTAILQ_INSERT_TAIL(mounts, mount, next);

    }

    free(line);



    fclose(fp);

}

static void build_fs_mount_list(FsMountList *mounts, Error **errp)

{

    FsMount *mount;

    char const *mountinfo = "/proc/self/mountinfo";

    FILE *fp;

    char *line = NULL, *dash;

    size_t n;

    char check;

    unsigned int devmajor, devminor;

    int ret, dir_s, dir_e, type_s, type_e, dev_s, dev_e;



    fp = fopen(mountinfo, "r");

    if (!fp) {

        build_fs_mount_list_from_mtab(mounts, errp);

        return;

    }



    while (getline(&line, &n, fp) != -1) {

        ret = sscanf(line, "%*u %*u %u:%u %*s %n%*s%n%c",

                     &devmajor, &devminor, &dir_s, &dir_e, &check);

        if (ret < 3) {

            continue;

        }

        dash = strstr(line + dir_e, " - ");

        if (!dash) {

            continue;

        }

        ret = sscanf(dash, " - %n%*s%n %n%*s%n%c",

                     &type_s, &type_e, &dev_s, &dev_e, &check);

        if (ret < 1) {

            continue;

        }

        line[dir_e] = 0;

        dash[type_e] = 0;

        dash[dev_e] = 0;

        decode_mntname(line + dir_s, dir_e - dir_s);

        decode_mntname(dash + dev_s, dev_e - dev_s);

        if (devmajor == 0) {

            

            if (strcmp("btrfs", dash + type_s) != 0 ||

                dev_major_minor(dash + dev_s, &devmajor, &devminor) < 0) {

                continue;

            }

        }



        mount = g_malloc0(sizeof(FsMount));

        mount->dirname = g_strdup(line + dir_s);

        mount->devtype = g_strdup(dash + type_s);

        mount->devmajor = devmajor;

        mount->devminor = devminor;



        QTAILQ_INSERT_TAIL(mounts, mount, next);

    }

    free(line);



    fclose(fp);

}

        mount = g_malloc0(sizeof(FsMount));         mount = g_malloc0(sizeof(FsMount));
static void FUNC_0(FsMountList *VAR_0, Error **VAR_1)

{

    FsMount *mount;

    char const *VAR_2 = "/proc/self/VAR_2";

    FILE *fp;

    char *VAR_3 = NULL, *VAR_4;

    size_t n;

    char VAR_5;

    unsigned int VAR_6, VAR_7;

    int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;



    fp = fopen(VAR_2, "r");

    if (!fp) {

        build_fs_mount_list_from_mtab(VAR_0, VAR_1);

        return;

    }



    while (getline(&VAR_3, &n, fp) != -1) {

        VAR_8 = sscanf(VAR_3, "%*u %*u %u:%u %*s %n%*s%n%c",

                     &VAR_6, &VAR_7, &VAR_9, &VAR_10, &VAR_5);

        if (VAR_8 < 3) {

            continue;

        }

        VAR_4 = strstr(VAR_3 + VAR_10, " - ");

        if (!VAR_4) {

            continue;

        }

        VAR_8 = sscanf(VAR_4, " - %n%*s%n %n%*s%n%c",

                     &VAR_11, &VAR_12, &VAR_13, &VAR_14, &VAR_5);

        if (VAR_8 < 1) {

            continue;

        }

        VAR_3[VAR_10] = 0;

        VAR_4[VAR_12] = 0;

        VAR_4[VAR_14] = 0;

        decode_mntname(VAR_3 + VAR_9, VAR_10 - VAR_9);

        decode_mntname(VAR_4 + VAR_13, VAR_14 - VAR_13);

        if (VAR_6 == 0) {

            

            if (strcmp("btrfs", VAR_4 + VAR_11) != 0 ||

                dev_major_minor(VAR_4 + VAR_13, &VAR_6, &VAR_7) < 0) {

                continue;

            }

        }



        mount = g_malloc0(sizeof(FsMount));

        mount->dirname = g_strdup(VAR_3 + VAR_9);

        mount->devtype = g_strdup(VAR_4 + VAR_11);

        mount->VAR_6 = VAR_6;

        mount->VAR_7 = VAR_7;



        QTAILQ_INSERT_TAIL(VAR_0, mount, next);

    }

    free(VAR_3);



    fclose(fp);

}

static void FUNC_0(FsMountList *VAR_0, Error **VAR_1)
{ FsMount *mount; char const *VAR_2 = "/proc/self/VAR_2"; FILE *fp; char *VAR_3 = NULL, *VAR_4; size_t n; char VAR_5; unsigned int VAR_6, VAR_7; int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14; fp = fopen(VAR_2, "r"); if (!fp) { build_fs_mount_list_from_mtab(VAR_0, VAR_1); return; } while (getline(&VAR_3, &n, fp) != -1) { VAR_8 = sscanf(VAR_3, "%*u %*u %u:%u %*s %n%*s%n%c",
&VAR_6, &VAR_7, &VAR_9, &VAR_10, &VAR_5); if (VAR_8 < 3) { continue; } VAR_4 = strstr(VAR_3 + VAR_10, " - "); if (!VAR_4) { continue; } VAR_8 = sscanf(VAR_4, " - %n%*s%n %n%*s%n%c",
&VAR_11, &VAR_12, &VAR_13, &VAR_14, &VAR_5); if (VAR_8 < 1) { continue; } VAR_3[VAR_10] = 0; VAR_4[VAR_12] = 0; VAR_4[VAR_14] = 0; decode_mntname(VAR_3 + VAR_9, VAR_10 - VAR_9); decode_mntname(VAR_4 + VAR_13, VAR_14 - VAR_13); if (VAR_6 == 0) { if (strcmp("btrfs", VAR_4 + VAR_11) != 0 ||
dev_major_minor(VAR_4 + VAR_13, &VAR_6, &VAR_7) < 0) { continue; } } mount = g_malloc0(sizeof(FsMount)); mount->dirname = g_strdup(VAR_3 + VAR_9); mount->devtype = g_strdup(VAR_4 + VAR_11); mount->VAR_6 = VAR_6; mount->VAR_7 = VAR_7; QTAILQ_INSERT_TAIL(VAR_0, mount, next); } free(VAR_3); fclose(fp); }