static int local_set_mapped_file_attr(FsContext *ctx,

                                      const char *path, FsCred *credp)

{

    FILE *fp;

    int ret = 0;

    char buf[ATTR_MAX];

    char attr_path[PATH_MAX];

    int uid = -1, gid = -1, mode = -1, rdev = -1;



    fp = local_fopen(local_mapped_attr_path(ctx, path, attr_path), "r");

    if (!fp) {

        goto create_map_file;

    }

    memset(buf, 0, ATTR_MAX);

    while (fgets(buf, ATTR_MAX, fp)) {

        if (!strncmp(buf, "virtfs.uid", 10)) {

            uid = atoi(buf+11);

        } else if (!strncmp(buf, "virtfs.gid", 10)) {

            gid = atoi(buf+11);

        } else if (!strncmp(buf, "virtfs.mode", 11)) {

            mode = atoi(buf+12);

        } else if (!strncmp(buf, "virtfs.rdev", 11)) {

            rdev = atoi(buf+12);

        }

        memset(buf, 0, ATTR_MAX);

    }

    fclose(fp);

    goto update_map_file;



create_map_file:

    ret = local_create_mapped_attr_dir(ctx, path);

    if (ret < 0) {

        goto err_out;

    }



update_map_file:

    fp = local_fopen(attr_path, "w");

    if (!fp) {

        ret = -1;

        goto err_out;

    }



    if (credp->fc_uid != -1) {

        uid = credp->fc_uid;

    }

    if (credp->fc_gid != -1) {

        gid = credp->fc_gid;

    }

    if (credp->fc_mode != -1) {

        mode = credp->fc_mode;

    }

    if (credp->fc_rdev != -1) {

        rdev = credp->fc_rdev;

    }





    if (uid != -1) {

        fprintf(fp, "virtfs.uid=%d\n", uid);

    }

    if (gid != -1) {

        fprintf(fp, "virtfs.gid=%d\n", gid);

    }

    if (mode != -1) {

        fprintf(fp, "virtfs.mode=%d\n", mode);

    }

    if (rdev != -1) {

        fprintf(fp, "virtfs.rdev=%d\n", rdev);

    }

    fclose(fp);



err_out:

    return ret;

}

static int local_set_mapped_file_attr(FsContext *ctx,

                                      const char *path, FsCred *credp)

{

    FILE *fp;

    int ret = 0;

    char buf[ATTR_MAX];

    char attr_path[PATH_MAX];

    int uid = -1, gid = -1, mode = -1, rdev = -1;



    fp = local_fopen(local_mapped_attr_path(ctx, path, attr_path), "r");

    if (!fp) {

        goto create_map_file;

    }

    memset(buf, 0, ATTR_MAX);

    while (fgets(buf, ATTR_MAX, fp)) {

        if (!strncmp(buf, "virtfs.uid", 10)) {

            uid = atoi(buf+11);

        } else if (!strncmp(buf, "virtfs.gid", 10)) {

            gid = atoi(buf+11);

        } else if (!strncmp(buf, "virtfs.mode", 11)) {

            mode = atoi(buf+12);

        } else if (!strncmp(buf, "virtfs.rdev", 11)) {

            rdev = atoi(buf+12);

        }

        memset(buf, 0, ATTR_MAX);

    }

    fclose(fp);

    goto update_map_file;



create_map_file:

    ret = local_create_mapped_attr_dir(ctx, path);

    if (ret < 0) {

        goto err_out;

    }



update_map_file:

    fp = local_fopen(attr_path, "w");

    if (!fp) {

        ret = -1;

        goto err_out;

    }



    if (credp->fc_uid != -1) {

        uid = credp->fc_uid;

    }

    if (credp->fc_gid != -1) {

        gid = credp->fc_gid;

    }

    if (credp->fc_mode != -1) {

        mode = credp->fc_mode;

    }

    if (credp->fc_rdev != -1) {

        rdev = credp->fc_rdev;

    }





    if (uid != -1) {

        fprintf(fp, "virtfs.uid=%d\n", uid);

    }

    if (gid != -1) {

        fprintf(fp, "virtfs.gid=%d\n", gid);

    }

    if (mode != -1) {

        fprintf(fp, "virtfs.mode=%d\n", mode);

    }

    if (rdev != -1) {

        fprintf(fp, "virtfs.rdev=%d\n", rdev);

    }

    fclose(fp);



err_out:

    return ret;

}

static int FUNC_0(FsContext *VAR_0,

                                      const char *VAR_1, FsCred *VAR_2)

{

    FILE *fp;

    int VAR_3 = 0;

    char VAR_4[ATTR_MAX];

    char VAR_5[PATH_MAX];

    int VAR_6 = -1, VAR_7 = -1, VAR_8 = -1, VAR_9 = -1;



    fp = local_fopen(local_mapped_attr_path(VAR_0, VAR_1, VAR_5), "r");

    if (!fp) {

        goto create_map_file;

    }

    memset(VAR_4, 0, ATTR_MAX);

    while (fgets(VAR_4, ATTR_MAX, fp)) {

        if (!strncmp(VAR_4, "virtfs.VAR_6", 10)) {

            VAR_6 = atoi(VAR_4+11);

        } else if (!strncmp(VAR_4, "virtfs.VAR_7", 10)) {

            VAR_7 = atoi(VAR_4+11);

        } else if (!strncmp(VAR_4, "virtfs.VAR_8", 11)) {

            VAR_8 = atoi(VAR_4+12);

        } else if (!strncmp(VAR_4, "virtfs.VAR_9", 11)) {

            VAR_9 = atoi(VAR_4+12);

        }

        memset(VAR_4, 0, ATTR_MAX);

    }

    fclose(fp);

    goto update_map_file;



create_map_file:

    VAR_3 = local_create_mapped_attr_dir(VAR_0, VAR_1);

    if (VAR_3 < 0) {

        goto err_out;

    }



update_map_file:

    fp = local_fopen(VAR_5, "w");

    if (!fp) {

        VAR_3 = -1;

        goto err_out;

    }



    if (VAR_2->fc_uid != -1) {

        VAR_6 = VAR_2->fc_uid;

    }

    if (VAR_2->fc_gid != -1) {

        VAR_7 = VAR_2->fc_gid;

    }

    if (VAR_2->fc_mode != -1) {

        VAR_8 = VAR_2->fc_mode;

    }

    if (VAR_2->fc_rdev != -1) {

        VAR_9 = VAR_2->fc_rdev;

    }





    if (VAR_6 != -1) {

        fprintf(fp, "virtfs.VAR_6=%d\n", VAR_6);

    }

    if (VAR_7 != -1) {

        fprintf(fp, "virtfs.VAR_7=%d\n", VAR_7);

    }

    if (VAR_8 != -1) {

        fprintf(fp, "virtfs.VAR_8=%d\n", VAR_8);

    }

    if (VAR_9 != -1) {

        fprintf(fp, "virtfs.VAR_9=%d\n", VAR_9);

    }

    fclose(fp);



err_out:

    return VAR_3;

}

static int FUNC_0(FsContext *VAR_0,
const char *VAR_1, FsCred *VAR_2)
{ FILE *fp; int VAR_3 = 0; char VAR_4[ATTR_MAX]; char VAR_5[PATH_MAX]; int VAR_6 = -1, VAR_7 = -1, VAR_8 = -1, VAR_9 = -1; fp = local_fopen(local_mapped_attr_path(VAR_0, VAR_1, VAR_5), "r"); if (!fp) { goto create_map_file; } memset(VAR_4, 0, ATTR_MAX); while (fgets(VAR_4, ATTR_MAX, fp)) { if (!strncmp(VAR_4, "virtfs.VAR_6", 10)) { VAR_6 = atoi(VAR_4+11); } else if (!strncmp(VAR_4, "virtfs.VAR_7", 10)) { VAR_7 = atoi(VAR_4+11); } else if (!strncmp(VAR_4, "virtfs.VAR_8", 11)) { VAR_8 = atoi(VAR_4+12); } else if (!strncmp(VAR_4, "virtfs.VAR_9", 11)) { VAR_9 = atoi(VAR_4+12); } memset(VAR_4, 0, ATTR_MAX); } fclose(fp); goto update_map_file; create_map_file:
VAR_3 = local_create_mapped_attr_dir(VAR_0, VAR_1); if (VAR_3 < 0) { goto err_out; } update_map_file:
fp = local_fopen(VAR_5, "w"); if (!fp) { VAR_3 = -1; goto err_out; } if (VAR_2->fc_uid != -1) { VAR_6 = VAR_2->fc_uid; } if (VAR_2->fc_gid != -1) { VAR_7 = VAR_2->fc_gid; } if (VAR_2->fc_mode != -1) { VAR_8 = VAR_2->fc_mode; } if (VAR_2->fc_rdev != -1) { VAR_9 = VAR_2->fc_rdev; } if (VAR_6 != -1) { fprintf(fp, "virtfs.VAR_6=%d\n", VAR_6); } if (VAR_7 != -1) { fprintf(fp, "virtfs.VAR_7=%d\n", VAR_7); } if (VAR_8 != -1) { fprintf(fp, "virtfs.VAR_8=%d\n", VAR_8); } if (VAR_9 != -1) { fprintf(fp, "virtfs.VAR_9=%d\n", VAR_9); } fclose(fp); err_out:
return VAR_3; }