static void v9fs_wstat(void *opaque)

{

    int32_t fid;

    int err = 0;

    int16_t unused;

    V9fsStat v9stat;

    size_t offset = 7;

    struct stat stbuf;

    V9fsFidState *fidp;

    V9fsPDU *pdu = opaque;

    V9fsState *s = pdu->s;



    pdu_unmarshal(pdu, offset, "dwS", &fid, &unused, &v9stat);

    trace_v9fs_wstat(pdu->tag, pdu->id, fid,

                     v9stat.mode, v9stat.atime, v9stat.mtime);



    fidp = get_fid(pdu, fid);

    if (fidp == NULL) {

        err = -EINVAL;

        goto out_nofid;

    }

    /* do we need to sync the file? */

    if (donttouch_stat(&v9stat)) {

        err = v9fs_co_fsync(pdu, fidp, 0);

        goto out;

    }

    if (v9stat.mode != -1) {

        uint32_t v9_mode;

        err = v9fs_co_lstat(pdu, &fidp->path, &stbuf);

        if (err < 0) {

            goto out;

        }

        v9_mode = stat_to_v9mode(&stbuf);

        if ((v9stat.mode & P9_STAT_MODE_TYPE_BITS) !=

            (v9_mode & P9_STAT_MODE_TYPE_BITS)) {

            /* Attempting to change the type */

            err = -EIO;

            goto out;

        }

        err = v9fs_co_chmod(pdu, &fidp->path,

                            v9mode_to_mode(v9stat.mode,

                                           &v9stat.extension));

        if (err < 0) {

            goto out;

        }

    }

    if (v9stat.mtime != -1 || v9stat.atime != -1) {

        struct timespec times[2];

        if (v9stat.atime != -1) {

            times[0].tv_sec = v9stat.atime;

            times[0].tv_nsec = 0;

        } else {

            times[0].tv_nsec = UTIME_OMIT;

        }

        if (v9stat.mtime != -1) {

            times[1].tv_sec = v9stat.mtime;

            times[1].tv_nsec = 0;

        } else {

            times[1].tv_nsec = UTIME_OMIT;

        }

        err = v9fs_co_utimensat(pdu, &fidp->path, times);

        if (err < 0) {

            goto out;

        }

    }

    if (v9stat.n_gid != -1 || v9stat.n_uid != -1) {

        err = v9fs_co_chown(pdu, &fidp->path, v9stat.n_uid, v9stat.n_gid);

        if (err < 0) {

            goto out;

        }

    }

    if (v9stat.name.size != 0) {

        err = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name);

        if (err < 0) {

            goto out;

        }

    }

    if (v9stat.length != -1) {

        err = v9fs_co_truncate(pdu, &fidp->path, v9stat.length);

        if (err < 0) {

            goto out;

        }

    }

    err = offset;

out:

    put_fid(pdu, fidp);

out_nofid:

    v9fs_stat_free(&v9stat);

    complete_pdu(s, pdu, err);

}

static void v9fs_wstat(void *opaque)

{

    int32_t fid;

    int err = 0;

    int16_t unused;

    V9fsStat v9stat;

    size_t offset = 7;

    struct stat stbuf;

    V9fsFidState *fidp;

    V9fsPDU *pdu = opaque;

    V9fsState *s = pdu->s;



    pdu_unmarshal(pdu, offset, "dwS", &fid, &unused, &v9stat);

    trace_v9fs_wstat(pdu->tag, pdu->id, fid,

                     v9stat.mode, v9stat.atime, v9stat.mtime);



    fidp = get_fid(pdu, fid);

    if (fidp == NULL) {

        err = -EINVAL;

        goto out_nofid;

    }

    

    if (donttouch_stat(&v9stat)) {

        err = v9fs_co_fsync(pdu, fidp, 0);

        goto out;

    }

    if (v9stat.mode != -1) {

        uint32_t v9_mode;

        err = v9fs_co_lstat(pdu, &fidp->path, &stbuf);

        if (err < 0) {

            goto out;

        }

        v9_mode = stat_to_v9mode(&stbuf);

        if ((v9stat.mode & P9_STAT_MODE_TYPE_BITS) !=

            (v9_mode & P9_STAT_MODE_TYPE_BITS)) {

            

            err = -EIO;

            goto out;

        }

        err = v9fs_co_chmod(pdu, &fidp->path,

                            v9mode_to_mode(v9stat.mode,

                                           &v9stat.extension));

        if (err < 0) {

            goto out;

        }

    }

    if (v9stat.mtime != -1 || v9stat.atime != -1) {

        struct timespec times[2];

        if (v9stat.atime != -1) {

            times[0].tv_sec = v9stat.atime;

            times[0].tv_nsec = 0;

        } else {

            times[0].tv_nsec = UTIME_OMIT;

        }

        if (v9stat.mtime != -1) {

            times[1].tv_sec = v9stat.mtime;

            times[1].tv_nsec = 0;

        } else {

            times[1].tv_nsec = UTIME_OMIT;

        }

        err = v9fs_co_utimensat(pdu, &fidp->path, times);

        if (err < 0) {

            goto out;

        }

    }

    if (v9stat.n_gid != -1 || v9stat.n_uid != -1) {

        err = v9fs_co_chown(pdu, &fidp->path, v9stat.n_uid, v9stat.n_gid);

        if (err < 0) {

            goto out;

        }

    }

    if (v9stat.name.size != 0) {

        err = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name);

        if (err < 0) {

            goto out;

        }

    }

    if (v9stat.length != -1) {

        err = v9fs_co_truncate(pdu, &fidp->path, v9stat.length);

        if (err < 0) {

            goto out;

        }

    }

    err = offset;

out:

    put_fid(pdu, fidp);

out_nofid:

    v9fs_stat_free(&v9stat);

    complete_pdu(s, pdu, err);

}

static void FUNC_0(void *VAR_0)

{

    int32_t fid;

    int VAR_1 = 0;

    int16_t unused;

    V9fsStat v9stat;

    size_t offset = 7;

    struct stat VAR_2;

    V9fsFidState *fidp;

    V9fsPDU *pdu = VAR_0;

    V9fsState *s = pdu->s;



    pdu_unmarshal(pdu, offset, "dwS", &fid, &unused, &v9stat);

    trace_v9fs_wstat(pdu->tag, pdu->id, fid,

                     v9stat.mode, v9stat.atime, v9stat.mtime);



    fidp = get_fid(pdu, fid);

    if (fidp == NULL) {

        VAR_1 = -EINVAL;

        goto out_nofid;

    }

    

    if (donttouch_stat(&v9stat)) {

        VAR_1 = v9fs_co_fsync(pdu, fidp, 0);

        goto out;

    }

    if (v9stat.mode != -1) {

        uint32_t v9_mode;

        VAR_1 = v9fs_co_lstat(pdu, &fidp->path, &VAR_2);

        if (VAR_1 < 0) {

            goto out;

        }

        v9_mode = stat_to_v9mode(&VAR_2);

        if ((v9stat.mode & P9_STAT_MODE_TYPE_BITS) !=

            (v9_mode & P9_STAT_MODE_TYPE_BITS)) {

            

            VAR_1 = -EIO;

            goto out;

        }

        VAR_1 = v9fs_co_chmod(pdu, &fidp->path,

                            v9mode_to_mode(v9stat.mode,

                                           &v9stat.extension));

        if (VAR_1 < 0) {

            goto out;

        }

    }

    if (v9stat.mtime != -1 || v9stat.atime != -1) {

        struct timespec VAR_3[2];

        if (v9stat.atime != -1) {

            VAR_3[0].tv_sec = v9stat.atime;

            VAR_3[0].tv_nsec = 0;

        } else {

            VAR_3[0].tv_nsec = UTIME_OMIT;

        }

        if (v9stat.mtime != -1) {

            VAR_3[1].tv_sec = v9stat.mtime;

            VAR_3[1].tv_nsec = 0;

        } else {

            VAR_3[1].tv_nsec = UTIME_OMIT;

        }

        VAR_1 = v9fs_co_utimensat(pdu, &fidp->path, VAR_3);

        if (VAR_1 < 0) {

            goto out;

        }

    }

    if (v9stat.n_gid != -1 || v9stat.n_uid != -1) {

        VAR_1 = v9fs_co_chown(pdu, &fidp->path, v9stat.n_uid, v9stat.n_gid);

        if (VAR_1 < 0) {

            goto out;

        }

    }

    if (v9stat.name.size != 0) {

        VAR_1 = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name);

        if (VAR_1 < 0) {

            goto out;

        }

    }

    if (v9stat.length != -1) {

        VAR_1 = v9fs_co_truncate(pdu, &fidp->path, v9stat.length);

        if (VAR_1 < 0) {

            goto out;

        }

    }

    VAR_1 = offset;

out:

    put_fid(pdu, fidp);

out_nofid:

    v9fs_stat_free(&v9stat);

    complete_pdu(s, pdu, VAR_1);

}

static void FUNC_0(void *VAR_0)
{ int32_t fid; int VAR_1 = 0; int16_t unused; V9fsStat v9stat; size_t offset = 7; struct stat VAR_2; V9fsFidState *fidp; V9fsPDU *pdu = VAR_0; V9fsState *s = pdu->s; pdu_unmarshal(pdu, offset, "dwS", &fid, &unused, &v9stat); trace_v9fs_wstat(pdu->tag, pdu->id, fid,
v9stat.mode, v9stat.atime, v9stat.mtime); fidp = get_fid(pdu, fid); if (fidp == NULL) { VAR_1 = -EINVAL; goto out_nofid; } if (donttouch_stat(&v9stat)) { VAR_1 = v9fs_co_fsync(pdu, fidp, 0); goto out; } if (v9stat.mode != -1) { uint32_t v9_mode; VAR_1 = v9fs_co_lstat(pdu, &fidp->path, &VAR_2); if (VAR_1 < 0) { goto out; } v9_mode = stat_to_v9mode(&VAR_2); if ((v9stat.mode & P9_STAT_MODE_TYPE_BITS) !=
(v9_mode & P9_STAT_MODE_TYPE_BITS)) { VAR_1 = -EIO; goto out; } VAR_1 = v9fs_co_chmod(pdu, &fidp->path,
v9mode_to_mode(v9stat.mode,
&v9stat.extension)); if (VAR_1 < 0) { goto out; } } if (v9stat.mtime != -1 || v9stat.atime != -1) { struct timespec VAR_3[2]; if (v9stat.atime != -1) { VAR_3[0].tv_sec = v9stat.atime; VAR_3[0].tv_nsec = 0; } else { VAR_3[0].tv_nsec = UTIME_OMIT; } if (v9stat.mtime != -1) { VAR_3[1].tv_sec = v9stat.mtime; VAR_3[1].tv_nsec = 0; } else { VAR_3[1].tv_nsec = UTIME_OMIT; } VAR_1 = v9fs_co_utimensat(pdu, &fidp->path, VAR_3); if (VAR_1 < 0) { goto out; } } if (v9stat.n_gid != -1 || v9stat.n_uid != -1) { VAR_1 = v9fs_co_chown(pdu, &fidp->path, v9stat.n_uid, v9stat.n_gid); if (VAR_1 < 0) { goto out; } } if (v9stat.name.size != 0) { VAR_1 = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name); if (VAR_1 < 0) { goto out; } } if (v9stat.length != -1) { VAR_1 = v9fs_co_truncate(pdu, &fidp->path, v9stat.length); if (VAR_1 < 0) { goto out; } } VAR_1 = offset; out:
put_fid(pdu, fidp); out_nofid:
v9fs_stat_free(&v9stat); complete_pdu(s, pdu, VAR_1); }