int v9fs_device_realize_common(V9fsState *s, Error **errp)

{

    int i, len;

    struct stat stat;

    FsDriverEntry *fse;

    V9fsPath path;

    int rc = 1;



    /* initialize pdu allocator */

    QLIST_INIT(&s->free_list);

    QLIST_INIT(&s->active_list);

    for (i = 0; i < (MAX_REQ - 1); i++) {

        QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);

        s->pdus[i].s = s;

        s->pdus[i].idx = i;

    }



    v9fs_path_init(&path);



    fse = get_fsdev_fsentry(s->fsconf.fsdev_id);



    if (!fse) {

        /* We don't have a fsdev identified by fsdev_id */

        error_setg(errp, "9pfs device couldn't find fsdev with the "

                   "id = %s",

                   s->fsconf.fsdev_id ? s->fsconf.fsdev_id : "NULL");

        goto out;

    }



    if (!s->fsconf.tag) {

        /* we haven't specified a mount_tag */

        error_setg(errp, "fsdev with id %s needs mount_tag arguments",

                   s->fsconf.fsdev_id);

        goto out;

    }



    s->ctx.export_flags = fse->export_flags;

    s->ctx.fs_root = g_strdup(fse->path);

    s->ctx.exops.get_st_gen = NULL;

    len = strlen(s->fsconf.tag);

    if (len > MAX_TAG_LEN - 1) {

        error_setg(errp, "mount tag '%s' (%d bytes) is longer than "

                   "maximum (%d bytes)", s->fsconf.tag, len, MAX_TAG_LEN - 1);

        goto out;

    }



    s->tag = g_strdup(s->fsconf.tag);

    s->ctx.uid = -1;



    s->ops = fse->ops;



    s->fid_list = NULL;

    qemu_co_rwlock_init(&s->rename_lock);



    if (s->ops->init(&s->ctx) < 0) {

        error_setg(errp, "9pfs Failed to initialize fs-driver with id:%s"

                   " and export path:%s", s->fsconf.fsdev_id, s->ctx.fs_root);

        goto out;

    }



    /*

     * Check details of export path, We need to use fs driver

     * call back to do that. Since we are in the init path, we don't

     * use co-routines here.

     */

    if (s->ops->name_to_path(&s->ctx, NULL, "/", &path) < 0) {

        error_setg(errp,

                   "error in converting name to path %s", strerror(errno));

        goto out;

    }

    if (s->ops->lstat(&s->ctx, &path, &stat)) {

        error_setg(errp, "share path %s does not exist", fse->path);

        goto out;

    } else if (!S_ISDIR(stat.st_mode)) {

        error_setg(errp, "share path %s is not a directory", fse->path);

        goto out;

    }

    v9fs_path_free(&path);



    rc = 0;

out:

    if (rc) {

        if (s->ops->cleanup && s->ctx.private) {

            s->ops->cleanup(&s->ctx);

        }

        g_free(s->tag);

        g_free(s->ctx.fs_root);

        v9fs_path_free(&path);

    }

    return rc;

}

int v9fs_device_realize_common(V9fsState *s, Error **errp)

{

    int i, len;

    struct stat stat;

    FsDriverEntry *fse;

    V9fsPath path;

    int rc = 1;



    

    QLIST_INIT(&s->free_list);

    QLIST_INIT(&s->active_list);

    for (i = 0; i < (MAX_REQ - 1); i++) {

        QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);

        s->pdus[i].s = s;

        s->pdus[i].idx = i;

    }



    v9fs_path_init(&path);



    fse = get_fsdev_fsentry(s->fsconf.fsdev_id);



    if (!fse) {

        

        error_setg(errp, "9pfs device couldn't find fsdev with the "

                   "id = %s",

                   s->fsconf.fsdev_id ? s->fsconf.fsdev_id : "NULL");

        goto out;

    }



    if (!s->fsconf.tag) {

        

        error_setg(errp, "fsdev with id %s needs mount_tag arguments",

                   s->fsconf.fsdev_id);

        goto out;

    }



    s->ctx.export_flags = fse->export_flags;

    s->ctx.fs_root = g_strdup(fse->path);

    s->ctx.exops.get_st_gen = NULL;

    len = strlen(s->fsconf.tag);

    if (len > MAX_TAG_LEN - 1) {

        error_setg(errp, "mount tag '%s' (%d bytes) is longer than "

                   "maximum (%d bytes)", s->fsconf.tag, len, MAX_TAG_LEN - 1);

        goto out;

    }



    s->tag = g_strdup(s->fsconf.tag);

    s->ctx.uid = -1;



    s->ops = fse->ops;



    s->fid_list = NULL;

    qemu_co_rwlock_init(&s->rename_lock);



    if (s->ops->init(&s->ctx) < 0) {

        error_setg(errp, "9pfs Failed to initialize fs-driver with id:%s"

                   " and export path:%s", s->fsconf.fsdev_id, s->ctx.fs_root);

        goto out;

    }



    









    if (s->ops->name_to_path(&s->ctx, NULL, "/", &path) < 0) {

        error_setg(errp,

                   "error in converting name to path %s", strerror(errno));

        goto out;

    }

    if (s->ops->lstat(&s->ctx, &path, &stat)) {

        error_setg(errp, "share path %s does not exist", fse->path);

        goto out;

    } else if (!S_ISDIR(stat.st_mode)) {

        error_setg(errp, "share path %s is not a directory", fse->path);

        goto out;

    }

    v9fs_path_free(&path);



    rc = 0;

out:

    if (rc) {

        if (s->ops->cleanup && s->ctx.private) {

            s->ops->cleanup(&s->ctx);

        }

        g_free(s->tag);

        g_free(s->ctx.fs_root);

        v9fs_path_free(&path);

    }

    return rc;

}

        if (s->ops->cleanup && s->ctx.private) {
int FUNC_0(V9fsState *VAR_0, Error **VAR_1)

{

    int VAR_2, VAR_3;

    struct VAR_4 VAR_4;

    FsDriverEntry *fse;

    V9fsPath path;

    int VAR_5 = 1;



    

    QLIST_INIT(&VAR_0->free_list);

    QLIST_INIT(&VAR_0->active_list);

    for (VAR_2 = 0; VAR_2 < (MAX_REQ - 1); VAR_2++) {

        QLIST_INSERT_HEAD(&VAR_0->free_list, &VAR_0->pdus[VAR_2], next);

        VAR_0->pdus[VAR_2].VAR_0 = VAR_0;

        VAR_0->pdus[VAR_2].idx = VAR_2;

    }



    v9fs_path_init(&path);



    fse = get_fsdev_fsentry(VAR_0->fsconf.fsdev_id);



    if (!fse) {

        

        error_setg(VAR_1, "9pfs device couldn't find fsdev with the "

                   "id = %VAR_0",

                   VAR_0->fsconf.fsdev_id ? VAR_0->fsconf.fsdev_id : "NULL");

        goto out;

    }



    if (!VAR_0->fsconf.tag) {

        

        error_setg(VAR_1, "fsdev with id %VAR_0 needs mount_tag arguments",

                   VAR_0->fsconf.fsdev_id);

        goto out;

    }



    VAR_0->ctx.export_flags = fse->export_flags;

    VAR_0->ctx.fs_root = g_strdup(fse->path);

    VAR_0->ctx.exops.get_st_gen = NULL;

    VAR_3 = strlen(VAR_0->fsconf.tag);

    if (VAR_3 > MAX_TAG_LEN - 1) {

        error_setg(VAR_1, "mount tag '%VAR_0' (%d bytes) is longer than "

                   "maximum (%d bytes)", VAR_0->fsconf.tag, VAR_3, MAX_TAG_LEN - 1);

        goto out;

    }



    VAR_0->tag = g_strdup(VAR_0->fsconf.tag);

    VAR_0->ctx.uid = -1;



    VAR_0->ops = fse->ops;



    VAR_0->fid_list = NULL;

    qemu_co_rwlock_init(&VAR_0->rename_lock);



    if (VAR_0->ops->init(&VAR_0->ctx) < 0) {

        error_setg(VAR_1, "9pfs Failed to initialize fs-driver with id:%VAR_0"

                   " and export path:%VAR_0", VAR_0->fsconf.fsdev_id, VAR_0->ctx.fs_root);

        goto out;

    }



    









    if (VAR_0->ops->name_to_path(&VAR_0->ctx, NULL, "/", &path) < 0) {

        error_setg(VAR_1,

                   "error in converting name to path %VAR_0", strerror(errno));

        goto out;

    }

    if (VAR_0->ops->lstat(&VAR_0->ctx, &path, &VAR_4)) {

        error_setg(VAR_1, "share path %VAR_0 does not exist", fse->path);

        goto out;

    } else if (!S_ISDIR(VAR_4.st_mode)) {

        error_setg(VAR_1, "share path %VAR_0 is not a directory", fse->path);

        goto out;

    }

    v9fs_path_free(&path);



    VAR_5 = 0;

out:

    if (VAR_5) {

        if (VAR_0->ops->cleanup && VAR_0->ctx.private) {

            VAR_0->ops->cleanup(&VAR_0->ctx);

        }

        g_free(VAR_0->tag);

        g_free(VAR_0->ctx.fs_root);

        v9fs_path_free(&path);

    }

    return VAR_5;

}

int FUNC_0(V9fsState *VAR_0, Error **VAR_1)
{ int VAR_2, VAR_3; struct VAR_4 VAR_4; FsDriverEntry *fse; V9fsPath path; int VAR_5 = 1; QLIST_INIT(&VAR_0->free_list); QLIST_INIT(&VAR_0->active_list); for (VAR_2 = 0; VAR_2 < (MAX_REQ - 1); VAR_2++) { QLIST_INSERT_HEAD(&VAR_0->free_list, &VAR_0->pdus[VAR_2], next); VAR_0->pdus[VAR_2].VAR_0 = VAR_0; VAR_0->pdus[VAR_2].idx = VAR_2; } v9fs_path_init(&path); fse = get_fsdev_fsentry(VAR_0->fsconf.fsdev_id); if (!fse) { error_setg(VAR_1, "9pfs device couldn't find fsdev with the "
"id = %VAR_0",
VAR_0->fsconf.fsdev_id ? VAR_0->fsconf.fsdev_id : "NULL"); goto out; } if (!VAR_0->fsconf.tag) { error_setg(VAR_1, "fsdev with id %VAR_0 needs mount_tag arguments",
VAR_0->fsconf.fsdev_id); goto out; } VAR_0->ctx.export_flags = fse->export_flags; VAR_0->ctx.fs_root = g_strdup(fse->path); VAR_0->ctx.exops.get_st_gen = NULL; VAR_3 = strlen(VAR_0->fsconf.tag); if (VAR_3 > MAX_TAG_LEN - 1) { error_setg(VAR_1, "mount tag '%VAR_0' (%d bytes) is longer than "
"maximum (%d bytes)", VAR_0->fsconf.tag, VAR_3, MAX_TAG_LEN - 1); goto out; } VAR_0->tag = g_strdup(VAR_0->fsconf.tag); VAR_0->ctx.uid = -1; VAR_0->ops = fse->ops; VAR_0->fid_list = NULL; qemu_co_rwlock_init(&VAR_0->rename_lock); if (VAR_0->ops->init(&VAR_0->ctx) < 0) { error_setg(VAR_1, "9pfs Failed to initialize fs-driver with id:%VAR_0"
" and export path:%VAR_0", VAR_0->fsconf.fsdev_id, VAR_0->ctx.fs_root); goto out; } if (VAR_0->ops->name_to_path(&VAR_0->ctx, NULL, "/", &path) < 0) { error_setg(VAR_1,
"error in converting name to path %VAR_0", strerror(errno)); goto out; } if (VAR_0->ops->lstat(&VAR_0->ctx, &path, &VAR_4)) { error_setg(VAR_1, "share path %VAR_0 does not exist", fse->path); goto out; } else if (!S_ISDIR(VAR_4.st_mode)) { error_setg(VAR_1, "share path %VAR_0 is not a directory", fse->path); goto out; } v9fs_path_free(&path); VAR_5 = 0; out:
if (VAR_5) { if (VAR_0->ops->cleanup && VAR_0->ctx.private) { VAR_0->ops->cleanup(&VAR_0->ctx); } g_free(VAR_0->tag); g_free(VAR_0->ctx.fs_root); v9fs_path_free(&path); } return VAR_5; }