static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)

{

    V9fsFidState *fidp;

    if (err < 0) {

        goto out;

    }



    if (vs->v9stat.name.size != 0) {

        char *old_name, *new_name;

        char *end;



        old_name = vs->fidp->path.data;

        end = strrchr(old_name, '/');

        if (end) {

            end++;

        } else {

            end = old_name;

        }



        new_name = qemu_mallocz(end - old_name + vs->v9stat.name.size + 1);



        memcpy(new_name, old_name, end - old_name);

        memcpy(new_name + (end - old_name), vs->v9stat.name.data,

                vs->v9stat.name.size);

        vs->nname.data = new_name;

        vs->nname.size = strlen(new_name);



        if (strcmp(new_name, vs->fidp->path.data) != 0) {

            if (v9fs_do_rename(s, &vs->fidp->path, &vs->nname)) {

                err = -errno;

            } else {

                /*

                 * Fixup fid's pointing to the old name to

                 * start pointing to the new name

                 */

                for (fidp = s->fid_list; fidp; fidp = fidp->next) {



                    if (vs->fidp == fidp) {

                        /*

                         * we replace name of this fid towards the end

                         * so that our below strcmp will work

                         */

                        continue;

                    }

                    if (!strncmp(vs->fidp->path.data, fidp->path.data,

                                 strlen(vs->fidp->path.data))) {

                        /* replace the name */

                        v9fs_fix_path(&fidp->path, &vs->nname,

                                      strlen(vs->fidp->path.data));

                    }

                }

                v9fs_string_copy(&vs->fidp->path, &vs->nname);

            }

        }

    }

    v9fs_wstat_post_rename(s, vs, err);

    return;



out:

    v9fs_stat_free(&vs->v9stat);

    complete_pdu(s, vs->pdu, err);

    qemu_free(vs);

}

static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)

{

    V9fsFidState *fidp;

    if (err < 0) {

        goto out;

    }



    if (vs->v9stat.name.size != 0) {

        char *old_name, *new_name;

        char *end;



        old_name = vs->fidp->path.data;

        end = strrchr(old_name, '/');

        if (end) {

            end++;

        } else {

            end = old_name;

        }



        new_name = qemu_mallocz(end - old_name + vs->v9stat.name.size + 1);



        memcpy(new_name, old_name, end - old_name);

        memcpy(new_name + (end - old_name), vs->v9stat.name.data,

                vs->v9stat.name.size);

        vs->nname.data = new_name;

        vs->nname.size = strlen(new_name);



        if (strcmp(new_name, vs->fidp->path.data) != 0) {

            if (v9fs_do_rename(s, &vs->fidp->path, &vs->nname)) {

                err = -errno;

            } else {

                







                for (fidp = s->fid_list; fidp; fidp = fidp->next) {



                    if (vs->fidp == fidp) {

                        







                        continue;

                    }

                    if (!strncmp(vs->fidp->path.data, fidp->path.data,

                                 strlen(vs->fidp->path.data))) {

                        

                        v9fs_fix_path(&fidp->path, &vs->nname,

                                      strlen(vs->fidp->path.data));

                    }

                }

                v9fs_string_copy(&vs->fidp->path, &vs->nname);

            }

        }

    }

    v9fs_wstat_post_rename(s, vs, err);

    return;



out:

    v9fs_stat_free(&vs->v9stat);

    complete_pdu(s, vs->pdu, err);

    qemu_free(vs);

}

static void FUNC_0(V9fsState *VAR_0, V9fsWstatState *VAR_1, int VAR_2)

{

    V9fsFidState *fidp;

    if (VAR_2 < 0) {

        goto out;

    }



    if (VAR_1->v9stat.name.size != 0) {

        char *VAR_3, *VAR_4;

        char *VAR_5;



        VAR_3 = VAR_1->fidp->path.data;

        VAR_5 = strrchr(VAR_3, '/');

        if (VAR_5) {

            VAR_5++;

        } else {

            VAR_5 = VAR_3;

        }



        VAR_4 = qemu_mallocz(VAR_5 - VAR_3 + VAR_1->v9stat.name.size + 1);



        memcpy(VAR_4, VAR_3, VAR_5 - VAR_3);

        memcpy(VAR_4 + (VAR_5 - VAR_3), VAR_1->v9stat.name.data,

                VAR_1->v9stat.name.size);

        VAR_1->nname.data = VAR_4;

        VAR_1->nname.size = strlen(VAR_4);



        if (strcmp(VAR_4, VAR_1->fidp->path.data) != 0) {

            if (v9fs_do_rename(VAR_0, &VAR_1->fidp->path, &VAR_1->nname)) {

                VAR_2 = -errno;

            } else {

                







                for (fidp = VAR_0->fid_list; fidp; fidp = fidp->next) {



                    if (VAR_1->fidp == fidp) {

                        







                        continue;

                    }

                    if (!strncmp(VAR_1->fidp->path.data, fidp->path.data,

                                 strlen(VAR_1->fidp->path.data))) {

                        

                        v9fs_fix_path(&fidp->path, &VAR_1->nname,

                                      strlen(VAR_1->fidp->path.data));

                    }

                }

                v9fs_string_copy(&VAR_1->fidp->path, &VAR_1->nname);

            }

        }

    }

    v9fs_wstat_post_rename(VAR_0, VAR_1, VAR_2);

    return;



out:

    v9fs_stat_free(&VAR_1->v9stat);

    complete_pdu(VAR_0, VAR_1->pdu, VAR_2);

    qemu_free(VAR_1);

}

static void FUNC_0(V9fsState *VAR_0, V9fsWstatState *VAR_1, int VAR_2)
{ V9fsFidState *fidp; if (VAR_2 < 0) { goto out; } if (VAR_1->v9stat.name.size != 0) { char *VAR_3, *VAR_4; char *VAR_5; VAR_3 = VAR_1->fidp->path.data; VAR_5 = strrchr(VAR_3, '/'); if (VAR_5) { VAR_5++; } else { VAR_5 = VAR_3; } VAR_4 = qemu_mallocz(VAR_5 - VAR_3 + VAR_1->v9stat.name.size + 1); memcpy(VAR_4, VAR_3, VAR_5 - VAR_3); memcpy(VAR_4 + (VAR_5 - VAR_3), VAR_1->v9stat.name.data,
VAR_1->v9stat.name.size); VAR_1->nname.data = VAR_4; VAR_1->nname.size = strlen(VAR_4); if (strcmp(VAR_4, VAR_1->fidp->path.data) != 0) { if (v9fs_do_rename(VAR_0, &VAR_1->fidp->path, &VAR_1->nname)) { VAR_2 = -errno; } else { for (fidp = VAR_0->fid_list; fidp; fidp = fidp->next) { if (VAR_1->fidp == fidp) { continue; } if (!strncmp(VAR_1->fidp->path.data, fidp->path.data,
strlen(VAR_1->fidp->path.data))) { v9fs_fix_path(&fidp->path, &VAR_1->nname,
strlen(VAR_1->fidp->path.data)); } } v9fs_string_copy(&VAR_1->fidp->path, &VAR_1->nname); } } } v9fs_wstat_post_rename(VAR_0, VAR_1, VAR_2); return; out:
v9fs_stat_free(&VAR_1->v9stat); complete_pdu(VAR_0, VAR_1->pdu, VAR_2); qemu_free(VAR_1); }